Version: svn - 562901 (using KDE KDE 3.5.0) Installed from: Slackware Packages Compiler: gcc 3.4.4 OS: Linux steps to reproduce: - with recent svn, import the class below - drag class to class diagram problems: - package visible member vars and methods are incorrect - visibility of package visible class is tagged as public package test; class Pack { int one; int two; Pack() { } void test() { } }
The patch below appears to address this bug. regards jp jape@puma:~$ diff -c svn/kdesdk/umbrello/umbrello/javaimport.cpp kdesdk/umbrello/umbrello/javaimport.cpp *** svn/kdesdk/umbrello/umbrello/javaimport.cpp 2006-07-16 09:27:38.000000000 -0400 --- kdesdk/umbrello/umbrello/javaimport.cpp 2006-07-16 14:56:38.000000000 -0400 *************** *** 143,148 **** --- 143,152 ---- kdError() << "importJava: unexpected: " << m_source[m_srcIndex] << endl; skipStmt(); } + // the default visibilty for java is implementation, since the absence of a modifier (like public) + // means package visibility (which maps to implementation). + // + m_currentAccess = Uml::Visibility::Implementation; return true; } if (keyword == "class" || keyword == "interface") { *************** *** 152,157 **** --- 156,162 ---- m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns); m_klass->setAbstract(m_isAbstract); m_klass->setStatic(m_isStatic); + m_klass->setVisibility( m_currentAccess ); m_isAbstract = m_isStatic = false; if (advance() == ";") // forward declaration return true; *************** *** 320,325 **** --- 325,332 ---- 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; // At this point we do not know whether the method has a body or not. do { nextToken = advance(); *************** *** 365,371 **** name = advance(); nextToken = advance(); } ! m_currentAccess = Uml::Visibility::Public; if (m_source[m_srcIndex] != ";") { kdError() << "importJava: ignoring trailing items at " << name << endl; skipStmt(); --- 372,379 ---- name = advance(); nextToken = advance(); } ! // reset visibility to default ! m_currentAccess = Uml::Visibility::Implementation; if (m_source[m_srcIndex] != ";") { kdError() << "importJava: ignoring trailing items at " << name << endl; skipStmt();
SVN commit 563157 by okellogg: Patches from JP Fournier fix setting of method staticness and package visibility. BUG:130926 BUG:130932 M +3 -0 ChangeLog M +14 -3 umbrello/codeimport/javaimport.cpp --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #563156:563157 @@ -5,10 +5,13 @@ * Fix crash when importing classes from a java file (129107, 130093) * Crash after single click on the "UML Model" tree window (126560/129252) * Cannot insert transition/association TO fork/join node in activity diagram (129914) +* Importing java files that reference their own class name crashes (130735) * Importing java class (enum pattern) cause umbrello to hang (130792) * Importing java subinterface before superinterface results in superinterface not being treated as an interface (130793) * Java import: method and class visibility ignored (130794) +* Java import - static not handled correctly (130926) +* Java import - package visibility incorrectly represented (130932) Version 1.5.3 --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #563156:563157 @@ -143,6 +143,9 @@ 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") { @@ -152,6 +155,7 @@ m_scope[++m_scopeIndex] = m_klass = static_cast<UMLClassifier*>(ns); m_klass->setAbstract(m_isAbstract); m_klass->setStatic(m_isStatic); + m_klass->setVisibility(m_currentAccess); m_isAbstract = m_isStatic = false; if (advance() == ";") // forward declaration return true; @@ -320,6 +324,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; // At this point we do not know whether the method has a body or not. do { nextToken = advance(); @@ -358,14 +364,19 @@ } nextToken = advance(); } - UMLObject *o = Import_Utils::insertAttribute(m_klass, m_currentAccess, name, typeName, m_comment); + UMLObject *o = Import_Utils::insertAttribute(m_klass, m_currentAccess, name, + typeName, m_comment, m_isStatic); UMLAttribute *attr = static_cast<UMLAttribute*>(o); - if (nextToken != ",") + if (nextToken != ",") { + // reset the modifiers + m_isStatic = m_isAbstract = false; break; + } name = advance(); nextToken = advance(); } - m_currentAccess = Uml::Visibility::Public; + // reset visibility to default + m_currentAccess = Uml::Visibility::Implementation; if (m_source[m_srcIndex] != ";") { kdError() << "importJava: ignoring trailing items at " << name << endl; skipStmt();