JDK-8145489 NPE in javac during Attribute stage. Sequel

Plizga Vladimir v.plizga at ftc.ru
Thu Jun 23 05:05:21 UTC 2016

Hi Srikanth,

Yes, you're right - the issue was already closed and I had been watching it all that time. I don't know why my letter has been delivered just today.
Anyway thanks for your reply!

Kind regards,
Vladimir Plizga

-----Original Message-----
From: compiler-dev [mailto:compiler-dev-bounces at openjdk.java.net] On Behalf Of Srikanth
Sent: Thursday, June 23, 2016 10:32 AM
To: compiler-dev at openjdk.java.net
Subject: Re: JDK-8145489 NPE in javac during Attribute stage. Sequel

[This mail is dated 13th May, but showed up in my inbox today.]

Hi Plizga,

I suspect the problem you faced is the same as

which is addressed via


Perhaps you can check if the problem shows up on JDK9 tip


On Friday 13 May 2016 10:10 AM, Plizga Vladimir wrote:
> Hello!
> I'm the initiator of issue https://bugs.openjdk.java.net/browse/JDK-8145489 "NullPointerException while compiling certain annotations". The issue was closed because the assignee (Fairoz Matte) unfortunately couldn't reproduce it and I had no additional info by that moment.
> But the bug is still actual for our project  and recently I researched it in detail. I've sent the results by email to Fairoz a week ago but I didn't receive any answer. Hope you can help me.
> 1. I've significantly simplified the code snippet to reproduce the bug. Now it consists of just 3 short Java files located in 'mypackage' package:
> <File PackageAnnotation.java>
> package mypackage;
> public @interface PackageAnnotation {
>    Class<?> classyAnnotationMember();
> }
> </File PackageAnnotation.java>
> <File MyClass.java>
> package mypackage;
> public class MyClass {
>    public class MyInnerClass { }
> }
> </File MyClass.java>
> <File package-info.java>
> @PackageAnnotation(classyAnnotationMember = 
> MyClass.MyInnerClass.class) package mypackage; </File 
> package-info.java>
> An attempt to compile this files with javac 1.8.0_92 will end up with NullPointerException during Attribute stage (see the stacktrace in JDK-8145489).
> 2. The source of the error is condition “!env.next.tree.hasTag(REFERENCE)” in com/sun/tools/javac/comp/Attr.java:3335 line that was added in JDK 1.8.
> AFAIU there is no enclosing environment for some class-type members of annotations at the topmost (package) level. That's why "env.next == null" and "env.next.tree" fails with NPE.
> 3. As a temporal workaround (in order to proceed with my current task) I’ve fixed the problem in 1.8.0_92 compiler’s source code by prepending the new condition with a naive checking for enclosing environment nullness:
>     (env.next != null && !env.next.tree.hasTag(REFERENCE)) and rebuilt 
> the compiler. This fix has not affected the amount of successfully 
> passed tests run with jtreg and has allowed me to proceed. I believe 
> Oracle engineers would find a truly proper way to fix it:)
> I hope this information would be enough to reproduce and fix the bug. If not, you are welcome to request anything else.
> Thanks,
> Vladimir Plizga

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 9282 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20160623/ff3be45b/smime.p7s>

More information about the compiler-dev mailing list