javac crash for annotation on lambda formal parameter type

Alex Buckley alex.buckley at oracle.com
Fri Dec 6 17:50:27 PST 2013


Filed JDK-8029721 to cover the future change to jdk8/tl/langtools.

Alex

On 12/5/2013 4:47 PM, Alex Buckley wrote:
> Starting at JDK8 b91, and continuing through b118, this innocuous
> program crashes javac:
>
> --
> import java.lang.annotation.*;
> import java.util.function.*;
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.TYPE_USE)
> @interface TA {}
>
> class LambdaFormal {
>    IntUnaryOperator x = (@TA int y) -> 1;
> }
> --
>
> with:
>
> java.lang.NullPointerException
>          at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:302)
>
>          at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitLambda(TypeAnnotations.java:1080)
>
>          at
> com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1607)
>          at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
> ...
>
> This is weird because I'm sure I've annotated lambda formals in this
> fashion since b90. It's due to TYPE_USE - if TA's target is PARAMETER,
> then the program rightly compiles, while if TA's target is FIELD, you
> get the expected applicability error.
>
> Before I file a P2 bug for this, can anyone add some color to the
> situation?
>
> Alex
>
> P.S. With a TA target of TYPE_USE, b90 produces a class file without the
> expected RuntimeVisibleTypeAnnotations attribute for @TA. But that's
> less of a concern right now.
>


More information about the type-annotations-dev mailing list