Bug 131327 - java import - importing interfaces - absent visibility treated as package instead of public
Summary: java import - importing interfaces - absent visibility treated as package ins...
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-25 02:59 UTC by JP Fournier
Modified: 2006-08-03 23:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
patch to fix interface visibility problem (4.19 KB, patch)
2006-07-25 03:12 UTC, JP Fournier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JP Fournier 2006-07-25 02:59:23 UTC
Version:           svn 565677 (using KDE KDE 3.5.0)
Installed from:    Slackware Packages
Compiler:          gcc 3.4.4 
OS:                Linux

When importing the class below, the methods are tagged as package visible, when they should be public:

public interface Int7{
	void update3();
	void update2();
}
Comment 1 JP Fournier 2006-07-25 03:12:06 UTC
Created attachment 17123 [details]
patch to fix interface visibility problem

diff -c svn/kdesdk/umbrello/umbrello/codeimport/
kdesdk/umbrello/umbrello/codeimport/ > interfacevis.diff
Comment 2 Oliver Kellogg 2006-07-31 01:09:54 UTC
SVN commit 568047 by okellogg:

Apply attachment 121723 [details] from JP Fournier. Note that this goes to trunk
because the 3.5 branch is currently frozen for release.
BUG:131327


 M  +6 -0      ChangeLog  
 M  +12 -6     umbrello/codeimport/javaimport.cpp  
 M  +5 -0      umbrello/codeimport/javaimport.h  


--- trunk/KDE/kdesdk/umbrello/ChangeLog #568046:568047
@@ -1,3 +1,9 @@
+Version 2.0
+
+* Bugs/wishes from http://bugs.kde.org:
+* Java import - importing interfaces - absent visibility treated as package
+  instead of public (131327)
+
 Version 1.5.4
 
 * Bugs/wishes from http://bugs.kde.org:
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #568046:568047
@@ -229,6 +229,11 @@
 void JavaImport::parseFile(QString filename) {
     m_currentFileName= filename;
     m_imports.clear();
+    // default visibility is Impl, unless we are an interface, then it is 
+    // public for member vars and methods
+    m_defaultCurrentAccess = Uml::Visibility::Implementation;
+    m_currentAccess = m_defaultCurrentAccess;
+
     NativeImportBase::parseFile(filename);
 }
 
@@ -253,9 +258,6 @@
             kError() << "importJava: unexpected: " << m_source[m_srcIndex] << endl;
             skipStmt();
         }
-        // The default visibilty for java is implementation, since the absence
-        // of a modifier means package visibility (which maps to implementation).
-        m_currentAccess = Uml::Visibility::Implementation;
         return true;
     }
     if (keyword == "class" || keyword == "interface") {
@@ -271,6 +273,10 @@
         // change it.
         m_klass->setInterface(keyword == "interface");
         m_isAbstract = m_isStatic = false;
+        // if no modifier is specified in an interface, then it means public
+        if ( m_klass->isInterface() ) {
+            m_defaultCurrentAccess =  Uml::Visibility::Public;
+        }
         if (advance() == ";")   // forward declaration
             return true;
         if (m_source[m_srcIndex] == "<") {
@@ -466,8 +472,8 @@
                                    m_isStatic, m_isAbstract, false /*isFriend*/,
                                    false /*isConstructor*/, m_comment);
         m_isAbstract = m_isStatic = false;
-        // Default visibility for java is implementation (package vis.)
-        m_currentAccess = Uml::Visibility::Implementation;
+        // reset the default visibility
+        m_currentAccess = m_defaultCurrentAccess;
         // At this point we do not know whether the method has a body or not.
         do {
             nextToken = advance();
@@ -526,7 +532,7 @@
         nextToken = advance();
     }
     // reset visibility to default
-    m_currentAccess = Uml::Visibility::Implementation;
+    m_currentAccess = m_defaultCurrentAccess;
     if (m_source[m_srcIndex] != ";") {
         kError() << "importJava: ignoring trailing items at " << name << endl;
         skipStmt();
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.h #568046:568047
@@ -85,7 +85,12 @@
      */
     QStringList m_imports;
 
+    /**
+     * The current visibility for when the visibility is absent
+     */
+    Uml::Visibility m_defaultCurrentAccess;
 
+
 };
 
 #endif
Comment 3 Oliver Kellogg 2006-08-03 23:04:01 UTC
SVN commit 569451 by okellogg:

Patch by JP Fournier fixes interface visibility problem (trunk: r568047)
CCBUG:131327


 M  +12 -6     javaimport.cpp  
 M  +5 -0      javaimport.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #569450:569451
@@ -229,6 +229,11 @@
 void JavaImport::parseFile(QString filename) {
     m_currentFileName= filename;
     m_imports.clear();
+    // default visibility is Impl, unless we are an interface, then it is 
+    // public for member vars and methods
+    m_defaultCurrentAccess = Uml::Visibility::Implementation;
+    m_currentAccess = m_defaultCurrentAccess;
+
     NativeImportBase::parseFile(filename);
 }
 
@@ -253,9 +258,6 @@
             kdError() << "importJava: unexpected: " << m_source[m_srcIndex] << endl;
             skipStmt();
         }
-        // The default visibilty for java is implementation, since the absence
-        // of a modifier means package visibility (which maps to implementation).
-        m_currentAccess = Uml::Visibility::Implementation;
         return true;
     }
     if (keyword == "class" || keyword == "interface") {
@@ -271,6 +273,10 @@
         // change it.
         m_klass->setInterface(keyword == "interface");
         m_isAbstract = m_isStatic = false;
+        // if no modifier is specified in an interface, then it means public
+        if ( m_klass->isInterface() ) {
+            m_defaultCurrentAccess =  Uml::Visibility::Public;
+        }
         if (advance() == ";")   // forward declaration
             return true;
         if (m_source[m_srcIndex] == "<") {
@@ -466,8 +472,8 @@
                                    m_isStatic, m_isAbstract, false /*isFriend*/,
                                    false /*isConstructor*/, m_comment);
         m_isAbstract = m_isStatic = false;
-        // Default visibility for java is implementation (package vis.)
-        m_currentAccess = Uml::Visibility::Implementation;
+        // reset the default visibility
+        m_currentAccess = m_defaultCurrentAccess;
         // At this point we do not know whether the method has a body or not.
         do {
             nextToken = advance();
@@ -526,7 +532,7 @@
         nextToken = advance();
     }
     // reset visibility to default
-    m_currentAccess = Uml::Visibility::Implementation;
+    m_currentAccess = m_defaultCurrentAccess;
     if (m_source[m_srcIndex] != ";") {
         kdError() << "importJava: ignoring trailing items at " << name << endl;
         skipStmt();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.h #569450:569451
@@ -85,7 +85,12 @@
      */
     QStringList m_imports;
 
+    /**
+     * The current visibility for when the visibility is absent
+     */
+    Uml::Visibility m_defaultCurrentAccess;
 
+
 };
 
 #endif