Bug 127160 - Crash on importing Java 1.5 classes containing annotations
Summary: Crash on importing Java 1.5 classes containing annotations
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 1.5.2
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-11 20:45 UTC by Meni Livne
Modified: 2006-05-16 07:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example class causing crash on import (264 bytes, text/x-java)
2006-05-11 20:49 UTC, Meni Livne
Details

Note You need to log in before you can comment on or make changes to this bug.
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 == "}") {