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 254646 - Anonymous subclass with annotated type parameter causes "java.lang.AssertionError: Could not determine position of tree..."
Summary: Anonymous subclass with annotated type parameter causes "java.lang.AssertionE...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 8.1
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-24 09:40 UTC by brychcy
Modified: 2015-09-10 01:27 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brychcy 2015-08-24 09:40:45 UTC
With Netbeans 8.1 beta (I didn't test with earlier versions), create a java project with the following classes:

=== bug/Nullable.java ===
package bug;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE_USE })
public @interface Nullable {
    // no body
}

==== bug/Bug.java
package bug;

import java.util.function.Consumer;

class Bug {
    Object f() {
        return new Consumer<@Nullable String>() {
            public void accept(@Nullable String t) {}
        };
    }
}


An error is returned with the following Stacktrace:
---------
Caused: java.lang.AssertionError: Could not determine position of tree Consumer<@Nullable() String> within frame new Consumer<@Nullable() String>(){
    
    () {
        super();
    }
    
    public void accept(@Nullable()
    String t) {
    }
}
	at com.sun.tools.javac.util.Assert.error(Assert.java:133)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:711)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:791)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:937)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.findPosition(TypeAnnotations.java:1346)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitAnnotatedType(TypeAnnotations.java:1219)
	at com.sun.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:2379)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.tree.TreeScanner.visitTypeApply(TreeScanner.java:287)
	at com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:2141)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitNewClass(TypeAnnotations.java:1282)
	at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1522)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.tree.TreeScanner.visitReturn(TreeScanner.java:185)
	at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1390)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitBlock(TypeAnnotations.java:1212)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:915)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1113)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:784)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1046)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:698)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:279)
	at com.sun.tools.javac.code.TypeAnnotations.organizeTypeAnnotationsBodies(TypeAnnotations.java:155)
	at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4594)
	at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4462)
	at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4390)
	at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4365)
	at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1317)
	at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1290)
	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:641)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:496)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:162)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:631)
	at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:262)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:798)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:304)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:725)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:686)
	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:1443)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
-------------


Actually, the error already happens even if the involved types are unknown:
package bug;

class Bug {
    Object f() {
        return new Y<@X String>(){};
    }
}
Comment 2 Quality Engineering 2015-09-10 01:27:53 UTC
Integrated into 'main-silver', will be available in build *201509100002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/64c05ad29ebb
User: Dusan Balek <dbalek@netbeans.org>
Log: Issues #243699 and #254646 fixed.