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 271275 - NullPointerException at com.sun.source.util.TreePath.<init>
Summary: NullPointerException at com.sun.source.util.TreePath.<init>
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-12 14:08 UTC by Marian Petras
Modified: 2017-08-20 03:01 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 221989


Attachments
stacktrace (2.14 KB, text/plain)
2017-08-12 14:08 UTC, Marian Petras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Petras 2017-08-12 14:08:17 UTC
Build: NetBeans IDE 8.1 (Build 201510222201)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.144-b01, Java(TM) SE Runtime Environment, 1.8.0_144-b01
OS: Linux

User Comments:
GUEST: Please review this problem

scanti: Editing a .java file

mpetras: Probable steps I did before I got the exception:
1) I create a nested enum class.
2) In one of the outer class' methods, I changed the argument type from 'int' to the just-created enum
3) Started replacing the int values with the enum values in a switch-statement. The value being compared by the switch-statement was taken from the respective argument. So I started replacing int constants in the switch-statement with enum values from the nested enum class.

I think I got the exception at the moment I tried to use code-completion for completing the enum value in the case-statement.




Stacktrace: 
java.lang.NullPointerException
   at com.sun.source.util.TreePath.<init>(TreePath.java:97)
   at org.netbeans.modules.java.completion.JavaCompletionTask.addEnumConstants(JavaCompletionTask.java:3356)
   at org.netbeans.modules.java.completion.JavaCompletionTask.insideCase(JavaCompletionTask.java:2069)
   at org.netbeans.modules.java.completion.JavaCompletionTask.resolve(JavaCompletionTask.java:370)
   at org.netbeans.modules.java.completion.BaseTask.run(BaseTask.java:92)
   at org.netbeans.modules.java.completion.JavaCompletionTask.run(JavaCompletionTask.java:80)
Comment 1 Marian Petras 2017-08-12 14:08:20 UTC
Created attachment 164934 [details]
stacktrace
Comment 2 Marian Petras 2017-08-12 14:22:16 UTC
Additional information:

The declaration of the nested enum class contained no modifiers (such as "public" or "static"). So the classes looked like this:


public class OuterClass {

    enum NestedEnum {
        FIRST_VALUE(1),
        SECOND_VALUE(2),
        THIRD_VALUE(3),
        ...
        EIGHTH_VALUE(10),
        ;

        private final int id;

        private NestedEnum(final int id) {
            this.id = id;
        }
    }

    ...

    public static String perform(..., TaskList what, ...) {
        ...
        switch (what) {
            default:
                log.warn("...");
                //fall-through
            case FIRS<<caret>>
                ...
                break;
            case ...
                ...
            ...
        }
        ...
    }

    ...

}
Comment 3 Dusan Balek 2017-08-18 15:57:15 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/f62f94befb0b
Comment 4 Quality Engineering 2017-08-20 03:01:42 UTC
Integrated into 'main-silver', will be available in build *201708200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f62f94befb0b
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #271275 - NullPointerException at com.sun.source.util.TreePath.<init> - fixed.