[ https://issues.apache.org/jira/browse/NETBEANS-4095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094511#comment-17094511 ]
Eirik Bakke edited comment on NETBEANS-4095 at 4/28/20, 1:42 PM: ----------------------------------------------------------------- I managed to reproduce it again on a fresh build of NetBeans 11.3 on Java 14, with nbjavac installed and CoS enabled. It did not seem to occur without nbjavac installed. I'm using a Java maven project. At some point it wasn't triggering the error, so I added System.out.println("hello, world"); in the body of the for loop (to force a recompilation--not sure what kinds of changes will do so). That triggered the error again. That was with source level 14, too. was (Author: ebakke): I managed to reproduce it again on a fresh build of NetBeans 11.3 on Java 14, with nbjavac installed and CoS enabled. It did not seem to occur without nbjavac installed. I'm using a Java maven project. At some point it wasn't triggering the error, so I added ystem.out.println("hello, world"); in the body of the for loop (to force a recompilation--not sure what kinds of changes will do so). That triggered the error again. That was with source level 14, too. > NPE saving Java file with type error in for-each > ------------------------------------------------ > > Key: NETBEANS-4095 > URL: https://issues.apache.org/jira/browse/NETBEANS-4095 > Project: NetBeans > Issue Type: Bug > Components: java - Source > Affects Versions: 11.3 > Environment: Java 14, NetBeans with nbjavac plugin installed > Reporter: Eirik Bakke > Assignee: Arunava Sinha > Priority: Major > Labels: nbjavac > > If, during editing, a for-each loop appears with an incorrect pair of types, > an error dialog shows up showing a NullPointerException every time the Java > source file is saved, interrupting the user. A minimized example exhibiting > this behavior is as follows: > {code:java} > public final class CausesVisitIterableForeachLoopNPE { > public static final void main(String args[]) { > final Map<String,Object> someMap = null; > for (Object someVar : someMap) { } > } > } > {code} > This example causes the IDE to throw the following exception: > {noformat} > java.lang.NullPointerException > at > com.sun.tools.javac.comp.Lower.visitIterableForeachLoop(Lower.java:3275) > at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:3162) > at > com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:1176) > at > com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) > at com.sun.tools.javac.comp.Lower.translate(Lower.java:2080) > at > com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70) > at > com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167) > at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3347) > at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1036) > at > com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) > at com.sun.tools.javac.comp.Lower.translate(Lower.java:2080) > at > com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:150) > at > com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2538) > at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2448) > at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:882) > at > com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) > at com.sun.tools.javac.comp.Lower.translate(Lower.java:2080) > at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:2219) > at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:788) > at > com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58) > at com.sun.tools.javac.comp.Lower.translate(Lower.java:2080) > at com.sun.tools.javac.comp.Lower.translate(Lower.java:2099) > at > com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:3813) > at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1691) > at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1532) > at > com.sun.tools.javac.api.JavacTaskImpl$2.process(JavacTaskImpl.java:574) > at > com.sun.tools.javac.api.JavacTaskImpl$Filter.run(JavacTaskImpl.java:651) > at > com.sun.tools.javac.api.JavacTaskImpl.generate(JavacTaskImpl.java:577) > [catch] at > org.netbeans.modules.java.source.nbjavac.indexing.MultiPassCompileWorker.compile(MultiPassCompileWorker.java:303) > at > org.netbeans.modules.java.source.indexing.JavaCustomIndexer.index(JavaCustomIndexer.java:361) > at > org.netbeans.modules.parsing.spi.indexing.Indexable$MyAccessor$2.run(Indexable.java:138) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runIndexer(RepositoryUpdater.java:275) > at > org.netbeans.modules.parsing.spi.indexing.Indexable$MyAccessor.index(Indexable.java:136) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doIndex(RepositoryUpdater.java:2750) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.access$800(RepositoryUpdater.java:2154) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work$1.run(RepositoryUpdater.java:2636) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work$1.run(RepositoryUpdater.java:2634) > at > org.netbeans.modules.parsing.impl.indexing.errors.TaskCache.refreshTransaction(TaskCache.java:540) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.index(RepositoryUpdater.java:2634) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work$3.call(RepositoryUpdater.java:3300) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work$3.call(RepositoryUpdater.java:3255) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$4.run(RepositoryUpdater.java:2127) > at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runInContext(RepositoryUpdater.java:2123) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runInContext(RepositoryUpdater.java:2104) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.access$1500(RepositoryUpdater.java:136) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.scanFiles(RepositoryUpdater.java:3255) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$FileListWork.getDone(RepositoryUpdater.java:3785) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doTheWork(RepositoryUpdater.java:3420) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task._run(RepositoryUpdater.java:6183) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.access$4300(RepositoryUpdater.java:5834) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2$1.run(RepositoryUpdater.java:6099) > at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279) > at > org.netbeans.modules.parsing.impl.RunWhenScanFinishedSupport.performScan(RunWhenScanFinishedSupport.java:83) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.call(RepositoryUpdater.java:6095) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.call(RepositoryUpdater.java:6091) > at > org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153) > at > org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335) > at > org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118) > at > org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67) > at > org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.run(RepositoryUpdater.java:6091) > at > java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418) > at > org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45) > at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278) > at > org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033) > {noformat} > The problem occurs whether Compile-or-Save is enabled or not. Tested in a > Maven Java project on Java 14. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists