Skip to content

Commit 4bd649c

Browse files
authored
JSR308 style annotations require explicit @target annotation (#13)
Reverting JDT Bug 552082-Fix the applicability of a no-@target annotation type updates, as the behavior is not compatible with JDK 11 and also with latest javac. For jdt.core, refer to https://bugs.eclipse.org/bugs/show_bug.cgi?id=552082 for more details. For javac, refer to https://bugs.openjdk.org/browse/JDK-8231435 and https://bugs.openjdk.org/browse/JDK-8231436 for more details. Signed-off-by: Saravanakumar Srinivasan <s.srinivasan@salesforce.com>
1 parent a065a38 commit 4bd649c

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

compiler/src/main/ecj/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ We are using a patched version of ECJ 4.23 to incorporate fixes for:
55
* Issue [844](https://github.com/eclipse-jdt/eclipse.jdt.core/issues/844) [PR 845](https://github.com/eclipse-jdt/eclipse.jdt.core/pull/845)
66
(Bugzilla: [574111](https://bugs.eclipse.org/bugs/show_bug.cgi?id=574111) [Gerrit](https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/181728))
77

8+
* Bugzilla [533199](https://bugs.eclipse.org/bugs/show_bug.cgi?id=533199)
9+
- Reverting part of commit [Bug 552082 - Fix the applicability of a no-@target annotation type](https://github.com/eclipse-jdt/eclipse.jdt.core/commit/c07bc1c3061d9d8cee7ea123d74e67f097c7ad56)
10+
- [JDK specification discussion](https://mail.openjdk.org/pipermail/compiler-dev/2019-September/013705.html)
811

912
## Issue with source/target and JDKs
1013

compiler/src/main/ecj/org/eclipse/jdt/internal/compiler/ast/Annotation.java

+13-10
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,12 @@ public boolean isRuntimeTypeInvisible() {
775775
}
776776
long metaTagBits = annotationBinding.getAnnotationTagBits(); // could be forward reference
777777

778-
if ((metaTagBits & (TagBits.AnnotationTargetMASK)) != 0) {
779-
if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0) {
780-
return false;
781-
}
782-
} // else: no-@Target always applicable
778+
if ((metaTagBits & (TagBits.AnnotationTargetMASK)) == 0) { // explicit target required for JSR308 style annotations.
779+
return false;
780+
}
781+
if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0) {
782+
return false;
783+
}
783784

784785
if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)
785786
return true; // by default the retention is CLASS
@@ -794,11 +795,13 @@ public boolean isRuntimeTypeVisible() {
794795
}
795796
long metaTagBits = annotationBinding.getAnnotationTagBits();
796797

797-
if ((metaTagBits & (TagBits.AnnotationTargetMASK)) != 0) {
798-
if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0) {
799-
return false;
800-
}
801-
} // else: no-@Target always applicable
798+
if ((metaTagBits & (TagBits.AnnotationTargetMASK)) == 0) { // explicit target required for JSR308 style annotations.
799+
return false;
800+
}
801+
if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0) {
802+
return false;
803+
}
804+
802805
if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)
803806
return false; // by default the retention is CLASS
804807

0 commit comments

Comments
 (0)