Bug 127160

Summary: Crash on importing Java 1.5 classes containing annotations
Product: [Applications] umbrello Reporter: Meni Livne <livne>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 1.5.2   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Example class causing crash on import

Description Meni Livne 2006-05-11 20:45:15 UTC
Version:           1.5.2 (using KDE Devel)
Installed from:    Compiled sources
Compiler:          g++ (GCC) 4.0.1 
OS:                Linux

Java 1.5 allows annotations to be inserted into the code (these are not inside comments, see http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html).
Importing the source of a class containing an annotation (such as "@Override") crashes Umbrello.
Comment 1 Meni Livne 2006-05-11 20:49:04 UTC
Created attachment 16030 [details]
Example class causing crash on import
Comment 2 Oliver Kellogg 2006-05-16 07:02:57 UTC
SVN commit 541373 by okellogg:

parseStmt(): Skip annotations for now.
TODO: Investigate how to forward them to the model.
BUG:127160


 M  +1 -0      ChangeLog  
 M  +6 -0      umbrello/javaimport.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #541372:541373
@@ -14,6 +14,7 @@
 * Crash loading xmi file (125331, 126968)
 * User interaction with UMLWidget improvements (126391)
 * Comments are cut short when generating PHP code (126480)
+* Crash on importing Java 1.5 classes containing annotations (127160)
 
 Version 1.5.2
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/javaimport.cpp #541372:541373
@@ -259,6 +259,12 @@
         skipStmt();
         return true;
     }
+    if (keyword == "@") {  // annotation
+        advance();
+        if (m_source[m_srcIndex] == "(")
+            skipToClosing('(');
+        return true;
+    }
     if (keyword == "}") {
         if (m_scopeIndex)
             m_klass = dynamic_cast<UMLClassifier*>(m_scope[--m_scopeIndex]);
Comment 3 Oliver Kellogg 2006-05-16 07:21:06 UTC
SVN commit 541374 by okellogg:

parseStmt(): Skip normal annotations too.
CCBUG:127160


 M  +3 -1      javaimport.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/javaimport.cpp #541373:541374
@@ -261,8 +261,10 @@
     }
     if (keyword == "@") {  // annotation
         advance();
-        if (m_source[m_srcIndex] == "(")
+        if (m_source[m_srcIndex + 1] == "(") {
+            advance();
             skipToClosing('(');
+        }
         return true;
     }
     if (keyword == "}") {