-
Bug
-
Resolution: Fixed
-
P3
-
8u11
-
b37
-
x86_64
-
linux_ubuntu
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085431 | emb-9 | Joel Borggrén-Franck | P3 | Resolved | Fixed | team |
JDK-8064061 | 8u45 | Joel Borggrén-Franck | P3 | Resolved | Fixed | b01 |
JDK-8062027 | 8u40 | Joel Borggrén-Franck | P3 | Resolved | Fixed | b13 |
JDK-8070281 | emb-8u47 | Joel Borggrén-Franck | P3 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux cnl1478 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Annotation values on an inner class in an anonymous class cannot reference attributes of that inner class.
REGRESSION. Last worked in version 7u65
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Invoke javac with the attached source file as an argument
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should compile just fine.
ACTUAL -
Compilation fails with one error.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
.../J8Issue.java:13: error: cannot find symbol
@Annotation(AnonymousClass.ID)
^
symbol: variable ID
location: class <anonymous OuterBaseClass>.AnonymousClass
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class J8Issue
{
public static void main(String[] args) {
Object withAttribute = new OuterBaseClass()
{
private void method() {
// This compiles OK in Java 7 update 50, 60 and 65, and Java 8 update 5 and 11
System.out.println(AnonymousClass.ID);
}
// This compiles OK in Java 7 update 50, 60 and 65
// This WONT compile in Java 8 update 5 and 11
@Annotation(AnonymousClass.ID)
abstract class AnonymousClass
{
static final String ID = "B";
}
};
}
}
class OuterBaseClass
{
}
@interface Annotation
{
String value();
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Copy the value of the referenced field and put it at the Annotation's value. That requires duplication, and is therefore not preferable.
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux cnl1478 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Annotation values on an inner class in an anonymous class cannot reference attributes of that inner class.
REGRESSION. Last worked in version 7u65
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Invoke javac with the attached source file as an argument
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should compile just fine.
ACTUAL -
Compilation fails with one error.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
.../J8Issue.java:13: error: cannot find symbol
@Annotation(AnonymousClass.ID)
^
symbol: variable ID
location: class <anonymous OuterBaseClass>.AnonymousClass
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class J8Issue
{
public static void main(String[] args) {
Object withAttribute = new OuterBaseClass()
{
private void method() {
// This compiles OK in Java 7 update 50, 60 and 65, and Java 8 update 5 and 11
System.out.println(AnonymousClass.ID);
}
// This compiles OK in Java 7 update 50, 60 and 65
// This WONT compile in Java 8 update 5 and 11
@Annotation(AnonymousClass.ID)
abstract class AnonymousClass
{
static final String ID = "B";
}
};
}
}
class OuterBaseClass
{
}
@interface Annotation
{
String value();
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Copy the value of the referenced field and put it at the Annotation's value. That requires duplication, and is therefore not preferable.
- backported by
-
JDK-8062027 (ann) Cannot reference field of inner class in an anonymous class
-
- Resolved
-
-
JDK-8064061 (ann) Cannot reference field of inner class in an anonymous class
-
- Resolved
-
-
JDK-8070281 (ann) Cannot reference field of inner class in an anonymous class
-
- Resolved
-
-
JDK-8085431 (ann) Cannot reference field of inner class in an anonymous class
-
- Resolved
-
- relates to
-
JDK-8033132 Javac should recognize a constant string in annotations on a nested static class
-
- Closed
-