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.
The javacore module throws exceptions when performing some actions in the UML module. These exceptions do not happen when the UML elements (and Java source counterparts) are in a named package. We are aware that JDK doesn't support some behavior from or within the default package, but we need some sort of workaround or fix for this so that it does result in exceptions. If there is something we can do on our end to prevent it, we are happy to do so. See the issues blocking this issue for UML reproduction scenarios.
This report is not complete. Please follow http://qa.netbeans.org/bugzilla/rules.html
The common case in those dependent issues is that UML calls API JavaClass.getContents.add(Object innerClass); Both outer and inner classes are in default package, but the outer class source was not updated, that's the perceived issue. The root cause is at Java model processing source text for elements in default package. It seems to expect a first token "package", while in default pakcage case, it throws below NPE when getSourceText() is invoked. ====================================== java.lang.NullPointerException at org.netbeans.modules.javacore.jmiimpl.javamodel.IndentUtil.getGarbage(IndentUtil.java:286) at org.netbeans.modules.javacore.jmiimpl.javamodel.IndentUtil.printHeadGarbage(IndentUtil.java:281) at org.netbeans.modules.javacore.jmiimpl.javamodel.IndentUtil.reformatHeadGarbage(IndentUtil.java:325) at org.netbeans.modules.javacore.jmiimpl.javamodel.FeatureImpl.generateNewModifiers(FeatureImpl.java:467) at org.netbeans.modules.javacore.jmiimpl.javamodel.JavaClassImpl.getRawText(JavaClassImpl.java:802) at org.netbeans.modules.javacore.jmiimpl.javamodel.MetadataElement.getSourceText(MetadataElement.java:728) at org.netbeans.modules.javacore.jmiimpl.javamodel.ResourceImpl.getSourceText(ResourceImpl.java:1256)
change summary and remove "incomplete" keyword
I did not find any way how to reproduce it in IDE manually, I will create a test which will reproduce the issue.
I have created a test which tries to reproduce it, but I haven't got any exception. My usecase: - having two classes in default package A and B, - got a B class and added to A.getContents().add(B). class was successfuly moved to A. But your comment seems to be correct, do you have any idea what is different in my and your usecase? (Tested on current trunk build.)
I developed a small test case ( a NB module, source is attached ) to simulate UML module interaction with Java Model API, I can reproduce the issue on NB 5.0, 5.5 and 6.0 latest qbuild(200608141200). The difference between your use case and ours is that we set class modifier to the inner class (B) before calling A.getContents().add(B), the NPE was caught in ExclusiveMutex.leave(boolean fail) which results in cancellation of planned changes to the source. If I manually manipulate the java source to add package statement ( the source is still in default package ), the NPE is gone and class B will be added to A as an inner class. Please delete two test java sources and recreate them each time you test the case to avoid some cache problems I encountered. If you still cannot reproduce with provided test case and would like to debug through uml code, please follow build instructions on http://nbbuild.netbeans.org/entpack/build_ep55.html look for NBEventProcessor.moveInnerClass()
Created attachment 33627 [details] source to simulate interactions with java model api
Thanks for the class. It is the same as my testcase, I didn't test it correctly, I thought the exception will be visible in the log file... Now, I'm able to reproduce it, so I will provide fix soon.
Fixed in trunk build. Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java,v <-- IndentUtil.java new revision: 1.15; previous revision: 1.14 done Checking in test/cfg-unit.xml; /cvs/java/javacore/test/cfg-unit.xml,v <-- cfg-unit.xml new revision: 1.53; previous revision: 1.52 done RCS file: /cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/DefaultTest/AKlas.pass,v done Checking in test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/DefaultTest/AKlas.pass; /cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/DefaultTest/AKlas.pass,v <-- AKlas.pass initial revision: 1.1 done RCS file: /cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/DefaultTest/BKlas.pass,v done Checking in test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/DefaultTest/BKlas.pass; /cvs/java/javacore/test/unit/data/goldenfiles/org/netbeans/jmi/javamodel/codegen/DefaultTest/BKlas.pass,v <-- BKlas.pass initial revision: 1.1 done RCS file: /cvs/java/javacore/test/unit/data/projects/default/src/AKlas.java,v done Checking in test/unit/data/projects/default/src/AKlas.java; /cvs/java/javacore/test/unit/data/projects/default/src/AKlas.java,v <-- AKlas.java initial revision: 1.1 done RCS file: /cvs/java/javacore/test/unit/data/projects/default/src/BKlas.java,v done Checking in test/unit/data/projects/default/src/BKlas.java; /cvs/java/javacore/test/unit/data/projects/default/src/BKlas.java,v <-- BKlas.java initial revision: 1.1 done RCS file: /cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/codegen/DefaultTest.java,v done Checking in test/unit/src/org/netbeans/jmi/javamodel/codegen/DefaultTest.java; /cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/codegen/DefaultTest.java,v <-- DefaultTest.java initial revision: 1.1 done
Created attachment 33641 [details] patch, use when you want to test on different branches
The fix is safe.
Merged from trunk. Checking in src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/jmiimpl/javamodel/IndentUtil.java,v <-- IndentUtil.java new revision: 1.9.2.2.2.2; previous revision: 1.9.2.2.2.1 done
Reorganization of java component