You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
javac: java.lang.AssertionError: Unexpected tree error #6822
Just realized that attempting to access Javadoc ([Ctrl]-mouse hover) in this specific source file does not work and throws this exception. It does not matter whether I am trying to access JavaDoc defined within the source file or within the JDK (e.g., attempting to access the Collections Javadoc).
Based on a quick overview of the error message (line 484 of log), it looks like the folder it's trying to access is already being read by some other thread, which has locked the files inside it..
Are you running two instances of Netbeans, or is the file already under lock by some other process?
First, my apologies on how ugly the code is. I did not realize how much I depended on syntax highlighting. I cleaned the code up and then started playing around with it, seeing if I could find a way to trigger the error intentionally, and I did.
What I found is that I can use the generic to declare the Collection and to get and set the collection. But the moment I change the parameter in the addEntry(), doesEntryExist(), and removeEntry() methods from a concrete class to the generic, the exception gets triggered and I lose syntax highlighting and Javadoc access.
For example, the following declaration will not trigger the exception (although it does create an error in the method) :
public boolean addEntry( String entry ) throws IllegalArgumentException
Changing the declaration to the following then triggers the exception immediately:
public boolean addEntry( <?> entry ) throws IllegalArgumentException
Messages log and code attached. Thanks again for your help.
@luvunix if you would manage to create a small reproducer for this exception - that would be great. We might have to file this against OpenJDK.
exception from the log for copy/paste convenience:
Caused: java.lang.AssertionError: Unexpected tree: (ERROR) ? (ERROR) > entry : (ERROR) with kind: CONDITIONAL_EXPRESSION within: (ERROR) ? (ERROR) > entry : (ERROR) with kind: CONDITIONAL_EXPRESSION
at com.sun.tools.javac.util.Assert.error(Assert.java:162)
at com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.validateAnnotatedType(Attr.java:5918)
at com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitVarDef(Attr.java:5764)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1022)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:50)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:58)
at com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitMethodDef(Attr.java:5754)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:916)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:50)
at com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitClassDef(Attr.java:5817)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:814)
at com.sun.tools.javac.comp.Attr.validateTypeAnnotations(Attr.java:5714)
at com.sun.tools.javac.code.TypeAnnotations.lambda$validateTypeAnnotationsSignatures$1(TypeAnnotations.java:144)
at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:200)
at com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:144)
at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:157)
at com.sun.tools.javac.main.JavaCompiler.enterDone(JavaCompiler.java:1820)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1074)
at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:345)
at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:282)
at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:748)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:541)
at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:142)
at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:608)
at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:241)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:775)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1420)
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:2035)
I checked and this is still reproducible in NB 23 rc1. Since the the code is invalid (type is missing) and it seems to be specific to method params this particular scenario will hopefully rarely happen out in the wild.
Activity
luvunix commentedon Dec 9, 2023
Just realized that attempting to access Javadoc ([Ctrl]-mouse hover) in this specific source file does not work and throws this exception. It does not matter whether I am trying to access JavaDoc defined within the source file or within the JDK (e.g., attempting to access the Collections Javadoc).
luvunix commentedon Dec 9, 2023
Also, code completion works, but syntax errors are not highlighted.
palaashatri commentedon Dec 10, 2023
Based on a quick overview of the error message (line 484 of log), it looks like the folder it's trying to access is already being read by some other thread, which has locked the files inside it..
Are you running two instances of Netbeans, or is the file already under lock by some other process?
luvunix commentedon Dec 10, 2023
First, my apologies on how ugly the code is. I did not realize how much I depended on syntax highlighting. I cleaned the code up and then started playing around with it, seeing if I could find a way to trigger the error intentionally, and I did.
What I found is that I can use the generic to declare the Collection and to get and set the collection. But the moment I change the parameter in the
addEntry(),doesEntryExist(), andremoveEntry()methods from a concrete class to the generic, the exception gets triggered and I lose syntax highlighting and Javadoc access.For example, the following declaration will not trigger the exception (although it does create an error in the method) :
public boolean addEntry( String entry ) throws IllegalArgumentExceptionChanging the declaration to the following then triggers the exception immediately:
public boolean addEntry( <?> entry ) throws IllegalArgumentExceptionMessages log and code attached. Thanks again for your help.
messages.log
CollectionsCache.zip
mbien commentedon Dec 11, 2023
@luvunix if you would manage to create a small reproducer for this exception - that would be great. We might have to file this against OpenJDK.
exception from the log for copy/paste convenience:
luvunix commentedon Dec 11, 2023
As requested (if I am understanding the request). Create an class with the following method:
public void addEntry( <?> entry ) {// "<?> in the parameter declaration triggers the bug}Change the "" to "String", and things are normal. Change back to "" and the exception is triggered immediately.
If I misunderstood the request let me know and I'll try again.
Thank you once again!
[-]java.lang.AssertionError: Unexpected tree error[/-][+]javac: java.lang.AssertionError: Unexpected tree error[/+]mbien commentedon Aug 5, 2024
I checked and this is still reproducible in NB 23 rc1. Since the the code is invalid (type is missing) and it seems to be specific to method params this particular scenario will hopefully rarely happen out in the wild.