JSR_308 - Fix for target location and duplicate attributes for method return type
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index b57d097..1205365 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -1975,10 +1975,10 @@
}
}
Annotation[] annotations = methodDeclaration.annotations;
- if (annotations != null) {
+ if (annotations != null && binding.returnType.id != T_void) {
methodDeclaration.getAllAnnotationContexts(AnnotationTargetTypeConstants.METHOD_RETURN_TYPE, allTypeAnnotationContexts);
}
- if (!methodDeclaration.isConstructor() && !methodDeclaration.isClinit()) {
+ if (!methodDeclaration.isConstructor() && !methodDeclaration.isClinit() && binding.returnType.id != T_void) {
MethodDeclaration declaration = (MethodDeclaration) methodDeclaration;
TypeReference typeReference = declaration.returnType;
if ((typeReference.bits & ASTNode.HasTypeAnnotations) != 0) {
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index 0c23a3f..594474d 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -519,7 +519,8 @@
long metaTagBits = annotationBinding.getAnnotationTagBits(); // could be forward reference
// jsr 308
// we need to filter out type use and type parameter annotations
- if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0) {
+ if ((metaTagBits & (TagBits.AnnotationTargetMASK)) != 0
+ && ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0)) {
return false;
}
@@ -535,7 +536,8 @@
return false;
}
long metaTagBits = annotationBinding.getAnnotationTagBits();
- if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0) {
+ if ((metaTagBits & (TagBits.AnnotationTargetMASK)) != 0
+ && ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0)) {
return false;
}
if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)