- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    11, 17, 23, 24
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8355590 | 21.0.9-oracle | Kieran Farrell | P4 | Resolved | Fixed | b01 | 
| JDK-8364603 | 21.0.9 | Goetz Lindenmaier | P4 | Resolved | Fixed | b02 | 
| JDK-8355591 | 17.0.17-oracle | Kieran Farrell | P4 | Resolved | Fixed | b01 | 
| JDK-8364607 | 17.0.17 | Goetz Lindenmaier | P4 | Resolved | Fixed | b02 | 
javac throws an internal java compiler error when compiling code with annotations on constants in @interface
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Java class containing an annotation (@interface) with a constant field that applies an annotation to the constant.
Define a @Target(ElementType.TYPE_USE) annotation in the @interface.
Attempt to compile the following code:
package com.my.company;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
public class Client {
public void packs3_new() {
// Attempt to use the constant in the code
float y = Client.ThreeFieldPack.EMPTY_PACK;
}
@Target(ElementType.TYPE_USE)
public @interface ThreeFieldPack {
// Invalid annotation usage on a constant field
@Client.ThreeFieldPack float EMPTY_PACK = (@Client.ThreeFieldPack float) 0;
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should compile successfully, and the annotation @Client.ThreeFieldPack should be applied correctly in places where type annotations are supported, such as variable declarations or method parameters. Specifically:
The annotation should not be applied to constants within the annotation itself.
ACTUAL -
When attempting to compile the code with javac, the following error is encountered:
java: Compilation failed: internal java compiler error
The error message does not provide specific details or a helpful stack trace to diagnose the cause of the failure.
- backported by
- 
                    JDK-8355590 Internal java compiler error with type annotations in constants expression in constant fields -           
- Resolved
 
-         
- 
                    JDK-8355591 Internal java compiler error with type annotations in constants expression in constant fields -           
- Resolved
 
-         
- 
                    JDK-8364603 Internal java compiler error with type annotations in constants expression in constant fields -           
- Resolved
 
-         
- 
                    JDK-8364607 Internal java compiler error with type annotations in constants expression in constant fields -           
- Resolved
 
-         
- links to
- 
                     Commit(master)
        openjdk/jdk17u-dev/e695177f Commit(master)
        openjdk/jdk17u-dev/e695177f
- 
                     Commit(master)
        openjdk/jdk21u-dev/669026af Commit(master)
        openjdk/jdk21u-dev/669026af
- 
                     Commit(master)
        openjdk/jdk/0395593a Commit(master)
        openjdk/jdk/0395593a
- 
                     Review(master)
        openjdk/jdk17u-dev/3790 Review(master)
        openjdk/jdk17u-dev/3790
- 
                     Review(master)
        openjdk/jdk21u-dev/2026 Review(master)
        openjdk/jdk21u-dev/2026
- 
                     Review(master)
        openjdk/jdk/23029 Review(master)
        openjdk/jdk/23029