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 52522 - SourceElementImpl throws NPE with some types of Annotations
Summary: SourceElementImpl throws NPE with some types of Annotations
Status: RESOLVED DUPLICATE of bug 52036
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: All Linux
: P3 blocker (vote)
Assignee: Daniel Prusa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-15 20:56 UTC by ischneid
Modified: 2005-01-21 15:21 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ischneid 2004-12-15 20:56:39 UTC
I noticed this with rc2, and meant to submit this
bug, but didn't do it soon enough.

When attempting to expand a source package which
had annotations testing classes in it, I noticed
the folder was empty. It took a while to figure
out the offending class as FolderChildren just
chokes and dies when creating nodes. Anyhoo, heres
the source of the class file (like I said, it was
a test):


import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;

@Retention(RetentionPolicy.RUNTIME)
@interface Test {
    String value();
}

@Test("Hello") public class AnnotationTest {
    
    @Test("Method") public static void
main(@Test("argument") String[] args) {
        System.out.println(AnnotationTest.class);
        
        for (Annotation ann :
AnnotationTest.class.getAnnotations()) {
            System.out.println("Class :" + ann);
        }
    }
}


To (hopefully) duplicate this, stick this in a
project source directory and use the command line
to compile it. Now reresh the folder. If that
fails, close the project and reopen it and attempt
to open the folder again.

For both ide sanity and my own (I also make
modules) it'd be nice if FolderChildren was
friendlier with logging which of its children
caused a problem. In this case, I wrote a shell
script which removed each class one by one,
pausing long enough for me to hit the refresh
button on the folder.

Heres that stack trace:
java.lang.NullPointerException
        at
org.netbeans.modules.clazz.SourceElementImpl.initializeData(SourceElementImpl.java:108)
        at
org.netbeans.modules.clazz.SourceElementImpl.attachedToElement(SourceElementImpl.java:91)
        at
org.openide.src.Element.<init>(Element.java:54)
        at
org.openide.src.SourceElement.<init>(SourceElement.java:49)
        at
org.netbeans.modules.clazz.ClassDataObject.getSource(ClassDataObject.java:174)
        at
org.netbeans.modules.clazz.ClassDataNode.initialize(ClassDataNode.java:96)
        at
org.netbeans.modules.clazz.ClassDataNode.<init>(ClassDataNode.java:76)
        at
org.netbeans.modules.clazz.ClassDataNode.<init>(ClassDataNode.java:71)
        at
org.netbeans.modules.clazz.CompiledDataNode.<init>(CompiledDataNode.java:57)
        at
org.netbeans.modules.clazz.CompiledDataObject.createNodeDelegate(CompiledDataObject.java:107)
        at
org.openide.loaders.DataObject$1.run(DataObject.java:249)
        at
org.openide.util.Mutex.readAccess(Mutex.java:246)
        at
org.openide.loaders.DataObject.getNodeDelegate(DataObject.java:245)
        at
org.openide.loaders.DataObject.getClonedNodeDelegate(DataObject.java:270)
        at
org.openide.loaders.FolderChildren.createNodes(FolderChildren.java:143)
        at
org.openide.nodes.Children$Keys$KE.nodes(Children.java:2028)
        at
org.openide.nodes.ChildrenArray.nodesFor(ChildrenArray.java:112)
        at
org.openide.nodes.Children$Info.nodes(Children.java:1125)
        at
org.openide.nodes.Children.updateAdd(Children.java:933)
        at
org.openide.nodes.Children.setEntries(Children.java:720)
        at
org.openide.nodes.Children$5.run(Children.java:1919)
        at
org.openide.util.Mutex.postRequest(Mutex.java:987)
        at
org.openide.util.Mutex.postWriteRequest(Mutex.java:438)
        at
org.openide.nodes.Children$Keys.applyKeys(Children.java:1927)
        at
org.openide.nodes.Children$Keys.setKeys(Children.java:1886)
        at
org.openide.loaders.FolderChildren.access$500(FolderChildren.java:33)
        at
org.openide.loaders.FolderChildren$ChildrenRefreshRunnable.run(FolderChildren.java:251)
        at org.openide.util.Task.run(Task.java:136)
        at
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:686)
Comment 1 ischneid 2004-12-15 21:11:31 UTC
At least part of the problem may have been caused because there was
another class named Test in the package as well...
Comment 2 Martin Matula 2004-12-21 12:08:28 UTC
Dan, please look at this.
Comment 3 Daniel Prusa 2005-01-21 15:17:42 UTC

*** This issue has been marked as a duplicate of 52030 ***
Comment 4 Daniel Prusa 2005-01-21 15:20:59 UTC
should be duplicate of issue 52036, not issue 52030
Comment 5 Daniel Prusa 2005-01-21 15:21:32 UTC

*** This issue has been marked as a duplicate of 52036 ***