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.
Summary: | Netbeans hangs when trying to save after getting exception from "::" in method reference | ||
---|---|---|---|
Product: | java | Reporter: | naquada |
Component: | Compiler | Assignee: | Dusan Balek <dbalek> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | sdedic |
Priority: | P1 | ||
Version: | 8.0.2 | ||
Hardware: | Other | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | Subset of Netbeans options/preferences |
I tried the same with the latest java sdk -- 1.8.0_45-b14 and get the same result. It seems a workaround is to avoid using a method reference expression within a lambda expression: NetBeansCrash nbc = new NetBeansCrash(); SomeInterface nbc1 = nbc::someMethod; fcn(nbc1, o); or fcn(nbc::someMethod, o); I don't know if any of this is sytlistically correct (or even semantically correct, for that matter, since I'm just experimenting), but I don't think the IDE shouldn't hang (and need to be stopped from the shell command line) regardless of what I type into the editor buffer. After some more experimenting editing the buffer in various ways to get the same final text, I've not consistently experienced the hanging problem (although continue to see the exception notification), depending on how I make the edits and save the buffer. But I can reliably replicate the hang this way: (1) Start Netbeans and load the sample code. (2) type "::" before "someMethod" in the exec() method. (3) Save the buffer. It would appear that some specific combination(s) of edits/saves that are taken following the exception/notification leads to the hang. (In reply to naquada from comment #2) > > It would appear that some specific combination(s) of edits/saves that are > taken following the exception/notification leads to the hang. Please create a thread dump (attach results here) when the IDE hangs after the exception. I tried doing a kill -QUIT pid as the Netbeans web page says, but it does nothing. I need to do kill -9 to get it to terminate. Fixed in jet-main. http://hg.netbeans.org/jet-main/rev/cda1a55676ce http://hg.netbeans.org/main/nb-javac/rev/beecb3fff88f Integrated into 'main-silver', will be available in build *201506230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/cda1a55676ce User: Dusan Balek <dbalek@netbeans.org> Log: Issue #252566 - Netbeans hangs when trying to save after getting exception from "::" in method reference - fixed. |
Created attachment 153837 [details] Subset of Netbeans options/preferences Product Version: NetBeans IDE 8.0.2 (Build 201411181905) Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 1 Java: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03 Runtime: Java(TM) SE Runtime Environment 1.8.0_11-b12 System: Linux version 3.9.4-200.fc18.x86_64 running on amd64; UTF-8; en_US The code below (between dashed lines at the end of description) is fine. But if you type "::" before "someMethod" in the exec() method, you get a red notification balloon. It says that Netbeans had an exception -- stack trace below following code. You can still do things in the editor. However, once this happens, if you try to save the file, Netbeans hangs. I've attached my editor and java format preferences, as well. I know it should be filed as a separate issue, but it may be related to this one -- the formatting of a line with a method reference using "::" is not correct -- the final ")" in the function call containing the method reference is on a line by itself, or several lines farther down with blank lines before it. If the hang-on-save problem is fixed, I'd be happy to file a separate issue on that. ---------------------------------------- package junk; import org.testng.annotations.Test; public class NetBeansCrash { @FunctionalInterface public interface SomeInterface { public String apply(Object o); } public String someMethod(Object o) { System.out.println("SOME METHOD object = " + o.toString()); return new String(); } public void fcn(SomeInterface lf, Object o) { lf.apply(o); } @Test public void exec() { Object o = new Object(); fcn(x -> someMethod(x), o); } } ---------------------------------------- Caused: java.lang.NullPointerException at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1666) at com.sun.tools.javac.comp.Resolve$MethodReferenceLookupHelper.lookup(Resolve.java:3180) at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3336) at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3321) at com.sun.tools.javac.comp.Resolve.getMemberReference(Resolve.java:2729) at com.sun.tools.javac.comp.DeferredAttr$DeferredChecker.visitReference(DeferredAttr.java:1207) at com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:1979) at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49) at com.sun.tools.javac.comp.DeferredAttr$FilterScanner.scan(DeferredAttr.java:938) at com.sun.tools.javac.comp.DeferredAttr.isDeferred(DeferredAttr.java:1125) at com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:707) at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1868) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1471) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:613) at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:662) at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1646) at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1302) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:613) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:682) at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:698) at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1167) at org.netbeans.lib.nbjavac.services.NBAttr.visitBlock(NBAttr.java:82) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:915) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:613) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:682) at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1055) at org.netbeans.lib.nbjavac.services.NBAttr.visitMethodDef(NBAttr.java:76) at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:784) at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:613) at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:682) at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4572) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4474) at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4402) at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4377) at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1311) at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1284) at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:469) at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:448) at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:664) at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:519) at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:174) at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:620) at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:256) [catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:733) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)