JDK-8033132 : Javac should recognize a constant string in annotations on a nested static class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6,7,8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2014-01-29
  • Updated: 2025-03-21
  • Resolved: 2024-11-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Relates :  
Description
The following should compie:

@interface Annot {
    String str();
}

public class Test {
    final String CONST_STR="something";

    @Annot( str = CONST_STR )
    static class Foo {}

    @Annot( str = CONST_STR )
    static void f(){}
}

Comments
After looking at the spec, this does not seem like a bug. I have brought this up with people offline before, I can't tell why this bug was filed.
29-11-2024

I saw this issue a while ago, and while it doesn't seem like a bug. I wanted to look at the spec and see why Joel filed this in case something can be done.
20-11-2024

This doesn't seem like a bug to me. Test.CONST_STR is not a static field, so it's not accessible in any static context. An annotation declaration is a static context.
19-11-2024

I *think* this is easy ... feel free to grab anyone
29-01-2014