Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Java Refactoring threw java.lang.IllegalStateException: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getThrownTypes()" because "tree.meth.type" is null #6335

Closed
swpalmer opened this issue Aug 13, 2023 · 5 comments · Fixed by #7153
Labels
duplicate Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix nb-javac Run nb-javac integration tests

Comments

@swpalmer
Copy link
Contributor

Apache NetBeans version

Apache NetBeans 19 release candidate

What happened

Was doing a rename refactoring when a dialog popped up telling me to report this issue. I was using NB 19-rc4, but I believe I have seen this in 18:

Module Java Refactoring threw java.lang.IllegalStateException: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getThrownTypes()" because "tree.meth.type" is null. Please report a bug against Java Refactoring module and attach your var/log/messages.log.

How to reproduce

No response

Did this work correctly in an earlier version?

No / Don't know

Operating System

macOS Ventura 13.5 - Intel

JDK

openjdk 20.0.1 2023-04-18 OpenJDK Runtime Environment Zulu20.30+11-CA (build 20.0.1+9) OpenJDK 64-Bit Server VM Zulu20.30+11-CA (build 20.0.1+9, mixed mode, sharing)

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

message.log contains:

SEVERE [org.openide.util.Exceptions]
An error occurred during parsing of '/Users/scott/dev/Personal/Glide/src/main/java/com/analogideas/grade/EditorContext.java'. Please report a bug against java/source and attach dump file '/Users/scott/Library/Application Support/NetBeans/19-rc4/var/log/EditorContext.dump'.
An error occurred during parsing of '/Users/scott/dev/Personal/Glide/src/main/java/com/analogideas/grade/EditorContext.java'. Please report a bug against java/source and attach dump file '/Users/scott/Library/Application Support/NetBeans/19-rc4/var/log/EditorContext.dump'.
Caused: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getThrownTypes()" because "tree.meth.type" is null
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1595)
	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1817)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:446)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitReturn(Flow.java:1571)
	at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1729)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:446)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:1340)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1088)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:446)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitMethodDef(Flow.java:1306)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:446)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitClassDef(Flow.java:1269)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:810)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:446)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1688)
	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1678)
	at com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:225)
	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1391)
	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1355)
	at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:404)
	at com.sun.tools.javac.api.JavacTaskImpl.lambda$analyze$1(JavacTaskImpl.java:379)
	at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
	at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:379)
Caused: java.lang.IllegalStateException
	at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
	at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:770)
	at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.toPhase(CompilationInfoImpl.java:426)
	at org.netbeans.api.java.source.CompilationController.toPhase(CompilationController.java:90)
	at org.netbeans.api.java.source.WorkingCopy.toPhase(WorkingCopy.java:192)
	at org.netbeans.modules.refactoring.java.spi.RefactoringVisitor.setWorkingCopy(RefactoringVisitor.java:111)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin$TransformTask.run(JavaRefactoringPlugin.java:437)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin$TransformTask.run(JavaRefactoringPlugin.java:420)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin.lambda$processFiles$1(JavaRefactoringPlugin.java:325)
	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:675)
	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:665)
	at org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:504)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586)
	at org.netbeans.modules.parsing.api.ParserManager$MultiUserTaskAction.run(ParserManager.java:169)
	at org.netbeans.modules.parsing.api.ParserManager$MultiUserTaskAction.run(ParserManager.java:140)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178)
	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.TaskProcessor.runUserTask(TaskProcessor.java:178)
	at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:85)
	at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:454)
	at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:425)
	at org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:686)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin.processFiles(JavaRefactoringPlugin.java:323)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin.processFiles(JavaRefactoringPlugin.java:264)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin.processFiles(JavaRefactoringPlugin.java:246)
	at org.netbeans.modules.refactoring.java.spi.JavaRefactoringPlugin.createAndAddElements(JavaRefactoringPlugin.java:338)
	at org.netbeans.modules.refactoring.java.plugins.RenameRefactoringPlugin.prepare(RenameRefactoringPlugin.java:627)
[catch] at org.netbeans.modules.refactoring.api.AbstractRefactoring.pluginsPrepare2(AbstractRefactoring.java:417)
	at org.netbeans.modules.refactoring.api.AbstractRefactoring.pluginsPrepare(AbstractRefactoring.java:401)
	at org.netbeans.modules.refactoring.api.AbstractRefactoring.prepare(AbstractRefactoring.java:212)
	at org.netbeans.modules.refactoring.spi.impl.ParametersPanel$Prepare.run(ParametersPanel.java:1063)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1419)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2034)
ALL [null]: An error occurred during parsing of '/Users/scott/dev/Personal/Glide/src/main/java/com/analogideas/grade/EditorContext.java'. Please report a bug against java/source and attach dump file '/Users/scott/Library/Application Support/NetBeans/19-rc4/var/log/EditorContext.dump'.
SEVERE [null]: Last record repeated again.

EditorContext.dump.gz

Are you willing to submit a pull request?

No

@swpalmer swpalmer added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Aug 13, 2023
@lkishalmi
Copy link
Contributor

@jlahoda AFAIK you were/are deeply involved in JavaC/NBJavac Could you give a hint/guidance how we shall approach these kind of NPE-s? These are happening every now and then. I wish I could do something about them.

@mbien
Copy link
Member

mbien commented Aug 14, 2023

duplicate of #3725, #5272 , #5496, #5508, #5642

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) and removed needs:triage Requires attention from one of the committers labels Aug 14, 2023
@mbien
Copy link
Member

mbien commented Aug 14, 2023

We have many reports like this, I looked through them a few days ago and wasn't able to come up with a reproducer unfortunately.

There is an old and closed JDK bug: https://bugs.openjdk.org/browse/JDK-8262095

And a curious case of a user posting a gradle stack trace at #3725 (comment) and is reporting that he could fix it by updating from JDK 17.0.2 to 17.0.8.
This is interesting since this might indicate that updating javac mitigates this issue.

If we would have a reproducer, we could easily test this by uninstalling nb-javac and running on the latest update release of the JDK, or using master which should have a fairly recent javac build (JDK 21+26).

@lahodaj
Copy link
Contributor

lahodaj commented Aug 14, 2023

The best is to have a way to reproduce - that it can be reported against javac and fixed there (and it is not rare that bugs like this are fixed in javac). The main trouble with this bug is that the point where the exception happens is not doing anything really wrong. In most cases, it is that something should have happened (typically error recovery), but didn't, or didn't properly/fully.

@mbien mbien added the nb-javac Run nb-javac integration tests label Oct 7, 2023
@jjazzboss
Copy link
Contributor

I also very often encounter this super annoying bug... It seems a reproducible case is now available in #3725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix nb-javac Run nb-javac integration tests
Projects
None yet
5 participants