Bug 130735 - Importing java files that reference their own class name (eg. singleton objects) crashes umbrello
Summary: Importing java files that reference their own class name (eg. singleton objec...
Status: RESOLVED WORKSFORME
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: Oliver Kellogg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-13 05:32 UTC by Clinton Grant
Modified: 2006-07-16 09:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Clinton Grant 2006-07-13 05:32:18 UTC
Version:           1.5.3 (using KDE KDE 3.5.3)
Installed from:    Fedora RPMs
Compiler:          gcc 4.1.1 
OS:                Linux

I have patched my version of the source to include the changes in 1.5.4 for java import issues.

However, if you import this code umbrello will crash:

public class TestClass
{

	public TestClass getInstance ()
	{
		return instance;
	}

	private TestClass()
	{
	}
	
	public void SomeMethod()
	{
	}

	String aString;
	String anotherString; 
	TestClass instance = new TestClass();
	
}


I debugged the crash, and it can be prevented with this change:

@@ -286,7 +286,7 @@
     }
     QString typeName = joinTypename();
     QString name;
-    if ( (typeName == m_klass->getName())) {
+    if ((m_klass != NULL) && (typeName == m_klass->getName())) {
         // Constructor.
         name = typeName;
         typeName = QString::null;

If this is done, the import still doesn't work because the importer gets confused over the getInstance method and instance member. This appears to be because the class is referencing instances of itself.
Comment 1 Oliver Kellogg 2006-07-16 01:17:38 UTC
SVN commit 562838 by okellogg:

parseStmt(): Check for m_klass being NULL before dereferencing it.
Thanks to Clinton Grant for spotting this.
CCBUG:130735


 M  +1 -1      javaimport.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/javaimport.cpp #562837:562838
@@ -286,7 +286,7 @@
     }
     QString typeName = joinTypename();
     QString name;
-    if (typeName == m_klass->getName()) {
+    if (m_klass != NULL && typeName == m_klass->getName()) {
         // Constructor.
         name = typeName;
         typeName = QString::null;
Comment 2 Oliver Kellogg 2006-07-16 09:22:41 UTC
Works for me now, probably due to commit 562848 (see bug 130792)