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 - NPE in setSimpleName
Summary: NPE in setSimpleName
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Jan Becicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-05 15:40 UTC by Ondrej Rypacek
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
exception stack trace (1.85 KB, text/plain)
2004-08-05 15:41 UTC, Ondrej Rypacek
Details

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