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 271772 - 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: Compiler (show other bugs)
Version: Dev
Hardware: All All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-08 21:11 UTC by dtrebbien
Modified: 2017-12-27 01:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 230272


Attachments
stacktrace (4.18 KB, text/plain)
2017-11-08 21:11 UTC, dtrebbien
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dtrebbien 2017-11-08 21:11:12 UTC
Build: NetBeans IDE Dev (Build 20171026-unknown-revn)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.152-b16, Java(TM) SE Runtime Environment, 1.8.0_152-b16
OS: Mac OS X

User Comments:
dtrebbien: Starting from this code:
package hintstest;

import java.util.function.Consumer;

public interface Test2 {
    Consumer<CharSequence> CONSUMER = new Consumer<CharSequence>() {
        @Override
        public void accept(CharSequence cs) {
            final String str = (String) cs;
            System.out.println(str.length());
        }
    };
}

I had just selected '(CharSequence cs) {' and deleted, ending up with the erroneous code:
package hintstest;

import java.util.function.Consumer;

public interface Test2 {
    Consumer<CharSequence> CONSUMER = new Consumer<CharSequence>() {
        @Override
        public void accept
            final String str = (String) cs;
            System.out.println(str.length());
        }
    };
}

GUEST: I was typing




Stacktrace: 
java.lang.NullPointerException
   at com.sun.source.util.TreePath.<init>(TreePath.java:111)
   at org.netbeans.lib.nbjavac.services.NBJavadocMemberEnter.visitMethodDef(NBJavadocMemberEnter.java:71)
   at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
   at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:171)
   at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:183)
   at com.sun.tools.javac.comp.MemberEnter.visitErroneous(MemberEnter.java:611)
Comment 1 dtrebbien 2017-11-08 21:11:15 UTC
Created attachment 165417 [details]
stacktrace
Comment 2 dtrebbien 2017-11-08 21:23:05 UTC
Debugging, I found that `trees.getPath(env.toplevel, env.enclClass)` was null.

I have opened a pull request that adds a null check: https://github.com/apache/incubator-netbeans/pull/262
Comment 3 dtrebbien 2017-12-27 01:09:05 UTC
Closing as PR 262 was merged.