This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 46942

Summary: NPE in setSimpleName
Product: java Reporter: Ondrej Rypacek <rypacek>
Component: UnsupportedAssignee: Jan Becicka <jbecicka>
Status: VERIFIED FIXED    
Severity: blocker    
Priority: P2    
Version: 4.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: exception stack trace

Description Ondrej Rypacek 2004-08-05 15:40:55 UTC
the following simple code throws a NPE at the
indicated line (inside the jmi code called there).

   JavaClass innerTester = 
((JavaModelPackage)tgtClass.
          refImmediatePackage()).
          getJavaClass().
          createJavaClass();
   innerTester.setSimpleName("TestClass"); // <<<
NPE HERE

tgtClass is another existing JavaClass, with
f.q.name set correctly.
Comment 1 Ondrej Rypacek 2004-08-05 15:41:53 UTC
Created attachment 16664 [details]
exception stack trace
Comment 2 Ondrej Rypacek 2004-08-05 15:44:52 UTC
Note that the code mentioned in the issue is a simplified snippet of
code from the TestCreator.fillTestClass method, in a version not in
the CVS, yet. 
Comment 3 Jan Becicka 2004-08-05 15:54:49 UTC
Simple workaround: use createJavaClass(name, annotations, modifiers,
javadocText, javadoc, features, superClassName, interfaceNames,
typeArguments)

instead of createJavaClass() and setSimpleName()

Comment 4 Jan Becicka 2004-08-05 16:09:50 UTC
Or more simple workaround: call setName() instead of setSimpleName().

Anyway it is fixed:

Checking in JavaClassImpl.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/JavaClassImpl.java,v
 <--  JavaClassImpl.java
new revision: 1.23; previous revision: 1.22
done
Comment 5 Ondrej Rypacek 2004-08-05 16:26:52 UTC
I thought there was a difference between simpleName and name. 
Anyway, thanks for the fix. 
Comment 6 Martin Matula 2004-08-05 16:48:36 UTC
Yes, there is a difference between setSimpleName and setName, but only
if simple name != fully qualified name (which in case of null name is
not true... :))
Comment 7 Quality Engineering 2007-09-20 11:57:06 UTC
Reorganization of java component