View | Details | Raw Unified | Return to bug 214948 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java (+15 lines)
Lines 205-210 Link Here
205
	return null;
205
	return null;
206
}
206
}
207
207
208
/**
209
 * Compute the tagbits for standard annotations. For source types, these could require
210
 * lazily resolving corresponding annotation nodes, in case of forward references.
211
 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#getAnnotationTagBits()
212
 */
213
public long getAnnotationTagBits() {
214
	if ((this.tagBits & TagBits.AnnotationResolved) == 0) {
215
		this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
216
		ReferenceBinding packageInfo = this.getType(TypeConstants.PACKAGE_INFO_NAME);
217
		if (packageInfo != null)			
218
			this.tagBits |= (packageInfo.getAnnotationTagBits() & TagBits.AllStandardAnnotationsMask);
219
	}
220
	return this.tagBits;
221
}
222
208
/* API
223
/* API
209
* Answer the receiver's binding type from Binding.BindingID.
224
* Answer the receiver's binding type from Binding.BindingID.
210
*/
225
*/
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (-1 / +1 lines)
Lines 1175-1181 Link Here
1175
 */
1175
 */
1176
public final boolean isViewedAsDeprecated() {
1176
public final boolean isViewedAsDeprecated() {
1177
	return (this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0
1177
	return (this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0
1178
			|| (getPackage().tagBits & TagBits.AnnotationDeprecated) != 0;
1178
			|| (getPackage().getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0;
1179
}
1179
}
1180
1180
1181
public ReferenceBinding[] memberTypes() {
1181
public ReferenceBinding[] memberTypes() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (-2 / +32 lines)
Lines 468-480 Link Here
468
		if (scope != null) {
468
		if (scope != null) {
469
			TypeDeclaration typeDecl = scope.referenceContext;
469
			TypeDeclaration typeDecl = scope.referenceContext;
470
			AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(originalMethod);
470
			AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(originalMethod);
471
			if (methodDecl != null)
471
			if (methodDecl != null) {
472
				ASTNode.resolveAnnotations(methodDecl.scope, methodDecl.annotations, originalMethod);
472
				ASTNode.resolveAnnotations(methodDecl.scope, methodDecl.annotations, originalMethod);
473
				if ((originalMethod.tagBits & TagBits.AnnotationDeprecated) != 0)
474
					originalMethod.modifiers |= ClassFileConstants.AccDeprecated;
475
			}
473
		}
476
		}
474
	}
477
	}
475
	return originalMethod.tagBits;
478
	return originalMethod.tagBits;
476
}
479
}
477
480
481
482
483
/**
484
 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#initializeDeprecatedAnnotationTagBits()
485
*/
486
public void initializeDeprecatedAnnotationTagBits() {
487
	MethodBinding originalMethod = original();
488
	if ((originalMethod.tagBits & TagBits.DeprecatedAnnotationResolved) == 0 && originalMethod.declaringClass instanceof SourceTypeBinding) {
489
		ClassScope scope = ((SourceTypeBinding) originalMethod.declaringClass).scope;
490
		if (scope != null) {
491
			TypeDeclaration typeDecl = scope.referenceContext;
492
			AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(originalMethod);
493
			if (methodDecl != null)
494
				ASTNode.resolveDeprecatedAnnotations(methodDecl.scope, methodDecl.annotations, originalMethod);
495
			originalMethod.tagBits |= TagBits.DeprecatedAnnotationResolved;
496
		}
497
		if ((originalMethod.tagBits & TagBits.AnnotationDeprecated) != 0)
498
			originalMethod.modifiers |= ClassFileConstants.AccDeprecated;
499
	}
500
}
501
478
/**
502
/**
479
 * @return the default value for this annotation method or <code>null</code> if there is no default value
503
 * @return the default value for this annotation method or <code>null</code> if there is no default value
480
 */
504
 */
Lines 776-782 Link Here
776
/* Answer true if the receiver's declaring type is deprecated (or any of its enclosing types)
800
/* Answer true if the receiver's declaring type is deprecated (or any of its enclosing types)
777
*/
801
*/
778
public final boolean isViewedAsDeprecated() {
802
public final boolean isViewedAsDeprecated() {
779
	return (this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0;
803
	if ((this.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0)
804
		return true;
805
	if (this.declaringClass != null) {
806
		this.declaringClass.initializeDeprecatedAnnotationTagBits();
807
	    return this.declaringClass.isViewedAsDeprecated();
808
	}
809
	return false;
780
}
810
}
781
811
782
public final int kind() {
812
public final int kind() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (+3 lines)
Lines 105-110 Link Here
105
				this.referenceContext.types[0].annotations = this.referenceContext.currentPackage.annotations;
105
				this.referenceContext.types[0].annotations = this.referenceContext.currentPackage.annotations;
106
		}
106
		}
107
		recordQualifiedReference(this.currentPackageName); // always dependent on your own package
107
		recordQualifiedReference(this.currentPackageName); // always dependent on your own package
108
		// Record a reference arc against "package-info", so a delta against package-info.java causes
109
		// the current unit to be compiled afresh
110
		recordQualifiedReference(CharOperation.arrayConcat(this.currentPackageName, TypeConstants.PACKAGE_INFO_NAME));
108
	}
111
	}
109
112
110
	// Skip typeDeclarations which know of previously reported errors
113
	// Skip typeDeclarations which know of previously reported errors
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-2 / +5 lines)
Lines 2807-2814 Link Here
2807
				if (!methodScope.isInsideInitializer()){
2807
				if (!methodScope.isInsideInitializer()){
2808
					// check method modifiers to see if deprecated
2808
					// check method modifiers to see if deprecated
2809
					MethodBinding context = ((AbstractMethodDeclaration)methodScope.referenceContext).binding;
2809
					MethodBinding context = ((AbstractMethodDeclaration)methodScope.referenceContext).binding;
2810
					if (context != null && context.isViewedAsDeprecated())
2810
					if (context != null) {
2811
						return true;
2811
						context.initializeDeprecatedAnnotationTagBits(); // may not have been resolved until then
2812
						if (context.isViewedAsDeprecated())
2813
							return true;
2814
					}
2812
				} else {
2815
				} else {
2813
					SourceTypeBinding type = ((BlockScope)this).referenceType().binding;
2816
					SourceTypeBinding type = ((BlockScope)this).referenceType().binding;
2814
					// inside field declaration ? check field modifier to see if deprecated
2817
					// inside field declaration ? check field modifier to see if deprecated
(-)compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java (+30 lines)
Lines 20-25 Link Here
20
import org.eclipse.jdt.internal.compiler.env.*;
20
import org.eclipse.jdt.internal.compiler.env.*;
21
import org.eclipse.jdt.internal.compiler.impl.Constant;
21
import org.eclipse.jdt.internal.compiler.impl.Constant;
22
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
22
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
23
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
23
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
24
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
24
import org.eclipse.jdt.internal.compiler.util.Util;
25
import org.eclipse.jdt.internal.compiler.util.Util;
25
26
Lines 917-922 Link Here
917
		} else if (newMissingTypes != null) {
918
		} else if (newMissingTypes != null) {
918
			return true;
919
			return true;
919
		}
920
		}
921
		
922
		/* As the original test case attached to https://bugs.eclipse.org/bugs/show_bug.cgi?id=258906
923
		 * shows, (non-standard) annotations attached to package-info have an influence outside of the
924
		 * file and so are structurally material.
925
		 */
926
		if (CharOperation.equals(this.getSourceName(), TypeConstants.PACKAGE_INFO_NAME)) {
927
			IBinaryAnnotation [] thisAnnotations = getAnnotations();
928
			IBinaryAnnotation [] newAnnotations = newClassFile.getAnnotations();
929
			int thisAnnotationsLength = thisAnnotations != null ? thisAnnotations.length : 0;
930
			int newAnnotationsLength = newAnnotations != null ? newAnnotations.length : 0;
931
			if (thisAnnotationsLength != newAnnotationsLength)
932
				return true;
933
			for (int i = 0; i < thisAnnotationsLength; i++) {
934
				if (!CharOperation.equals(thisAnnotations[i].getTypeName(), newAnnotations[i].getTypeName()))
935
					return true;
936
				IBinaryElementValuePair[] thisElementValuePairInfo = thisAnnotations[i].getElementValuePairs();
937
				IBinaryElementValuePair[] newElementValuePairInfo = newAnnotations[i].getElementValuePairs();
938
				int thisPairLength = thisElementValuePairInfo != null ? thisElementValuePairInfo.length : 0;
939
				int newPairLength = newElementValuePairInfo != null ? newElementValuePairInfo.length : 0;
940
				if (thisPairLength != newPairLength)
941
					return true;
942
				for (int j = 0; j < thisPairLength; j++) {
943
					if (!CharOperation.equals(thisElementValuePairInfo[j].getName(), newElementValuePairInfo[j].getName()))
944
						return true;
945
					// Comparing values is futile as they will be seen to be different by Object.equals
946
				}
947
			}
948
		}
949
920
		return false;
950
		return false;
921
	} catch (ClassFormatException e) {
951
	} catch (ClassFormatException e) {
922
		return true;
952
		return true;

Return to bug 214948