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

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-2 / +2 lines)
Lines 2437-2444 Link Here
2437
			}
2437
			}
2438
		}
2438
		}
2439
		if (rulesOK) {
2439
		if (rulesOK) {
2440
			AccessRuleSet accessRuleSet = new AccessRuleSet(
2440
			AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules);
2441
					accessRules, "{0}"); //$NON-NLS-1$
2441
			// TODO Maxime double check access rules diagnostics in batch compiler
2442
			FileSystem.Classpath currentClasspath = FileSystem
2442
			FileSystem.Classpath currentClasspath = FileSystem
2443
					.getClasspath(currentClasspathName,
2443
					.getClasspath(currentClasspathName,
2444
							customEncoding, 0, accessRuleSet);
2444
							customEncoding, 0, accessRuleSet);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +30 lines)
Lines 269-274 Link Here
269
			// ignore cases where field is used from within inside itself 
269
			// ignore cases where field is used from within inside itself 
270
			field.modifiers |= AccLocallyUsed;
270
			field.modifiers |= AccLocallyUsed;
271
		}
271
		}
272
		
273
//		if (field.hasRestrictedAccess()) {
274
		if ((field.modifiers & AccRestrictedAccess) != 0) {
275
			AccessRestriction restriction = scope.environment().getAccessRestriction(field.declaringClass);
276
			if (restriction != null) {
277
				scope.problemReporter().forbiddenReference(field, this, 
278
						restriction.getFieldAccessMessageTemplate(), restriction.getProblemId());
279
			}
280
		}
272
	
281
	
273
		if (!field.isViewedAsDeprecated()) return false;
282
		if (!field.isViewedAsDeprecated()) return false;
274
	
283
	
Lines 288-307 Link Here
288
	/* Answer true if the method use is considered deprecated.
297
	/* Answer true if the method use is considered deprecated.
289
	* An access in the same compilation unit is allowed.
298
	* An access in the same compilation unit is allowed.
290
	*/
299
	*/
291
	public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope) {
300
	public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, boolean isExplicitUse) {
292
301
293
		if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) {
302
		if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) {
294
			// ignore cases where method is used from within inside itself (e.g. direct recursions)
303
			// ignore cases where method is used from within inside itself (e.g. direct recursions)
295
			method.original().modifiers |= AccLocallyUsed;
304
			method.original().modifiers |= AccLocallyUsed;
296
		}
305
		}
297
		
306
		
307
		if (isExplicitUse && (method.modifiers & AccRestrictedAccess) != 0) {
308
			// note: explicit constructors calls warnings are kept despite the 'new C1()' case (two
309
			//       warnings, one on type, the other on constructor), because of the 'super()' case.
310
			AccessRestriction restriction = scope.environment().getAccessRestriction(method.declaringClass);
311
			if (restriction != null) 
312
				if (method.isConstructor())
313
					scope.problemReporter().forbiddenReference(method, this, 
314
							restriction.getConstructorAccessMessageTemplate(), restriction.getProblemId());
315
				else
316
					scope.problemReporter().forbiddenReference(method, this, 
317
						restriction.getMethodAccessMessageTemplate(), restriction.getProblemId());
318
		}
319
298
		if (!method.isViewedAsDeprecated()) return false;
320
		if (!method.isViewedAsDeprecated()) return false;
299
321
300
		// inside same unit - no report
322
		// inside same unit - no report
301
		if (scope.isDefinedInSameUnit(method.declaringClass)) return false;
323
		if (scope.isDefinedInSameUnit(method.declaringClass)) return false;
324
325
		// if non explicit use, but explicitly deprecated still warn
326
		if (!isExplicitUse && (method.modifiers & AccDeprecated) == 0) return false;
302
		
327
		
303
		// if context is deprecated, may avoid reporting
328
		// if context is deprecated, may avoid reporting
304
		if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
329
		if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
330
		
305
		return true;
331
		return true;
306
	}
332
	}
307
333
Lines 338-343 Link Here
338
				scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId());
364
				scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId());
339
			}
365
			}
340
		}
366
		}
367
		if (refType instanceof SourceTypeBinding)
368
			((SourceTypeBinding) refType).checkDeprecatedAnnotation();
369
		  // WORK look force annotations resolution before deciding whether the type may be deprecated
341
		if (!refType.isViewedAsDeprecated()) return false;
370
		if (!refType.isViewedAsDeprecated()) return false;
342
		
371
		
343
		// inside same unit - no report
372
		// inside same unit - no report
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-1 / +1 lines)
Lines 310-316 Link Here
310
			scope.problemReporter().invalidConstructor(this, binding);
310
			scope.problemReporter().invalidConstructor(this, binding);
311
			return this.resolvedType;
311
			return this.resolvedType;
312
		}
312
		}
313
		if (isMethodUseDeprecated(binding, scope))
313
		if (isMethodUseDeprecated(binding, scope, true))
314
			scope.problemReporter().deprecatedMethod(binding, this);
314
			scope.problemReporter().deprecatedMethod(binding, this);
315
		checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
315
		checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
316
316
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java (-1 / +1 lines)
Lines 325-331 Link Here
325
				argumentTypes = new TypeBinding[] { scope.getJavaLangString(), BaseTypes.IntBinding };
325
				argumentTypes = new TypeBinding[] { scope.getJavaLangString(), BaseTypes.IntBinding };
326
			}
326
			}
327
			if ((binding = scope.getConstructor(receiverType, argumentTypes, this)).isValidBinding()) {
327
			if ((binding = scope.getConstructor(receiverType, argumentTypes, this)).isValidBinding()) {
328
				if (isMethodUseDeprecated(binding, scope))
328
				if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ImplicitSuper))
329
					scope.problemReporter().deprecatedMethod(binding, this);
329
					scope.problemReporter().deprecatedMethod(binding, this);
330
				checkInvocationArguments(scope, null, receiverType, binding, this.arguments, argumentTypes, argsContainCast, this);
330
				checkInvocationArguments(scope, null, receiverType, binding, this.arguments, argumentTypes, argsContainCast, this);
331
				if (binding.isPrivate() || receiverType.isLocalType()) {
331
				if (binding.isPrivate() || receiverType.isLocalType()) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java (-1 / +1 lines)
Lines 120-126 Link Here
120
				}
120
				}
121
			}
121
			}
122
		}
122
		}
123
		if (isMethodUseDeprecated(this.binding, scope)) {
123
		if (isMethodUseDeprecated(this.binding, scope, true)) {
124
			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
124
			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
125
		}
125
		}
126
		return allocationType;
126
		return allocationType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java (-1 / +1 lines)
Lines 164-170 Link Here
164
				}
164
				}
165
			}
165
			}
166
		}
166
		}
167
		if (isMethodUseDeprecated(this.binding, scope)) {
167
		if (isMethodUseDeprecated(this.binding, scope, true)) {
168
			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
168
			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
169
		}
169
		}
170
170
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-1 / +1 lines)
Lines 381-387 Link Here
381
		}
381
		}
382
		// abstract private methods cannot occur nor abstract static............
382
		// abstract private methods cannot occur nor abstract static............
383
	}
383
	}
384
	if (isMethodUseDeprecated(binding, scope))
384
	if (isMethodUseDeprecated(binding, scope, true))
385
		scope.problemReporter().deprecatedMethod(binding, this);
385
		scope.problemReporter().deprecatedMethod(binding, this);
386
386
387
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
387
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-1 / +1 lines)
Lines 296-302 Link Here
296
				return this.resolvedType = receiverType;
296
				return this.resolvedType = receiverType;
297
			}
297
			}
298
			if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
298
			if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
299
				if (isMethodUseDeprecated(binding, scope)) {
299
				if (isMethodUseDeprecated(binding, scope, true)) {
300
					scope.problemReporter().deprecatedMethod(this.binding, this);
300
					scope.problemReporter().deprecatedMethod(this.binding, this);
301
				}
301
				}
302
				checkInvocationArguments(scope, null, allocationType, binding, this.arguments, argumentTypes, argsContainCast, this);
302
				checkInvocationArguments(scope, null, allocationType, binding, this.arguments, argumentTypes, argsContainCast, this);
(-)compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java (-4 / +16 lines)
Lines 13-22 Link Here
13
public class AccessRestriction {
13
public class AccessRestriction {
14
14
15
	private AccessRule accessRule;
15
	private AccessRule accessRule;
16
	private String messageTemplate;
16
	private String[] messageTemplates;
17
	public AccessRestriction(AccessRule accessRule, String messageTemplate) {
17
	public AccessRestriction(AccessRule accessRule, String [] messageTemplates) {
18
		this.accessRule = accessRule;
18
		this.accessRule = accessRule;
19
		this.messageTemplate = messageTemplate;
19
		this.messageTemplates = messageTemplates;
20
	}
20
	}
21
	
21
	
22
	/**
22
	/**
Lines 25-33 Link Here
25
	 * e.g. "{0} has restricted access"
25
	 * e.g. "{0} has restricted access"
26
	 */
26
	 */
27
	public String getMessageTemplate() {
27
	public String getMessageTemplate() {
28
		return this.messageTemplate;
28
		return this.messageTemplates[0];
29
	}
29
	}
30
	
30
	
31
	public String getConstructorAccessMessageTemplate() {
32
		return this.messageTemplates[1];
33
	}
34
35
	public String getMethodAccessMessageTemplate() {
36
		return this.messageTemplates[2];
37
	}
38
39
	public String getFieldAccessMessageTemplate() {
40
		return this.messageTemplates[3];
41
	}
42
31
	public int getProblemId() {
43
	public int getProblemId() {
32
		return this.accessRule.problemId;
44
		return this.accessRule.problemId;
33
	}
45
	}
(-)compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java (-11 / +31 lines)
Lines 19-34 Link Here
19
public class AccessRuleSet {
19
public class AccessRuleSet {
20
20
21
	private AccessRule[] accessRules;
21
	private AccessRule[] accessRules;
22
	public String messageTemplate;
22
	public String[] messageTemplates;
23
	public static final int MESSAGE_TEMPLATES_LENGTH = 4;
23
	
24
	
24
	
25
	
25
	public AccessRuleSet(AccessRule[] accessRules) {
26
	public AccessRuleSet(AccessRule[] accessRules) {
26
		this.accessRules = accessRules;
27
		this(accessRules, null);
27
	}
28
	}
28
	public AccessRuleSet(AccessRule[] accessRules, String messageTemplate) {
29
	
30
	/**
31
	 * Make a new set of access rules.
32
	 * @param accessRules the access rules to be contained by the new set
33
	 * @param messageTemplates a Sting[4] array specifying the messages for type, 
34
	 * constructor, method and field access violation; each should contain as many
35
	 * placeholders as expected by the respective access violation message (that is,
36
	 * one for type and constructor, two for method and field).
37
	 */
38
	// TODO Maxime move to better support
39
	public AccessRuleSet(AccessRule[] accessRules, String[] messageTemplates) {
29
		this.accessRules = accessRules;
40
		this.accessRules = accessRules;
30
		this.messageTemplate = messageTemplate;
41
		if (messageTemplates != null && messageTemplates.length == MESSAGE_TEMPLATES_LENGTH)
42
			this.messageTemplates = messageTemplates;
43
		else
44
			this.messageTemplates = new String[] {"{0}", "{0}", "{0} {1}", "{0} {1}"};  //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
31
	}
45
	}
46
	
32
	/**
47
	/**
33
	 * @see java.lang.Object#equals(java.lang.Object)
48
	 * @see java.lang.Object#equals(java.lang.Object)
34
	 */
49
	 */
Lines 38-45 Link Here
38
		if (!(object instanceof AccessRuleSet))
53
		if (!(object instanceof AccessRuleSet))
39
			return false;
54
			return false;
40
		AccessRuleSet otherRuleSet = (AccessRuleSet) object;
55
		AccessRuleSet otherRuleSet = (AccessRuleSet) object;
41
		if (!this.messageTemplate.equals(otherRuleSet.messageTemplate)) 
56
		if (this.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH ||
42
			return false;
57
				otherRuleSet.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH)
58
			return false; // guard
59
		for (int i = 0; i < MESSAGE_TEMPLATES_LENGTH; i++) 
60
			if (!this.messageTemplates[i].equals(otherRuleSet.messageTemplates[i])) 
61
				return false;
62
			// WORK look clarify internal contracting policy with Philippe
43
		int rulesLength = this.accessRules.length;
63
		int rulesLength = this.accessRules.length;
44
		if (rulesLength != otherRuleSet.accessRules.length) return false;
64
		if (rulesLength != otherRuleSet.accessRules.length) return false;
45
		for (int i = 0; i < rulesLength; i++)
65
		for (int i = 0; i < rulesLength; i++)
Lines 64-70 Link Here
64
				switch (accessRule.problemId) {
84
				switch (accessRule.problemId) {
65
					case IProblem.ForbiddenReference:
85
					case IProblem.ForbiddenReference:
66
					case IProblem.DiscouragedReference:
86
					case IProblem.DiscouragedReference:
67
						return new AccessRestriction(accessRule, this.messageTemplate);
87
						return new AccessRestriction(accessRule, this.messageTemplates);
68
					default:
88
					default:
69
						return null;
89
						return null;
70
				}
90
				}
Lines 92-101 Link Here
92
			else if (i < length-1)
112
			else if (i < length-1)
93
				buffer.append(", "); //$NON-NLS-1$
113
				buffer.append(", "); //$NON-NLS-1$
94
		}
114
		}
95
		buffer
115
		buffer.append("} [templates:\""); //$NON-NLS-1$
96
			.append("} [template:\"") //$NON-NLS-1$
116
		for (int i = 0; i < messageTemplates.length; i++)
97
			.append(this.messageTemplate)
117
			buffer.append(this.messageTemplates[i]);
98
			.append("\"]"); //$NON-NLS-1$
118
		buffer.append("\"]"); //$NON-NLS-1$
99
		return buffer.toString();
119
		return buffer.toString();
100
	}
120
	}
101
}
121
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (+6 lines)
Lines 274-279 Link Here
274
			this.fields = new FieldBinding[size];
274
			this.fields = new FieldBinding[size];
275
			boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5;
275
			boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5;
276
			boolean isViewedAsDeprecated = isViewedAsDeprecated();
276
			boolean isViewedAsDeprecated = isViewedAsDeprecated();
277
			boolean hasRestrictedAccess = hasRestrictedAccess();
277
			for (int i = 0; i < size; i++) {
278
			for (int i = 0; i < size; i++) {
278
				IBinaryField binaryField = iFields[i];
279
				IBinaryField binaryField = iFields[i];
279
				char[] fieldSignature = use15specifics ? binaryField.getGenericSignature() : null;
280
				char[] fieldSignature = use15specifics ? binaryField.getGenericSignature() : null;
Lines 292-297 Link Here
292
					field.tagBits |= binaryField.getTagBits();
293
					field.tagBits |= binaryField.getTagBits();
293
				if (isViewedAsDeprecated && !field.isDeprecated())
294
				if (isViewedAsDeprecated && !field.isDeprecated())
294
					field.modifiers |= AccDeprecatedImplicitly;
295
					field.modifiers |= AccDeprecatedImplicitly;
296
				if (hasRestrictedAccess)
297
					field.modifiers |= AccRestrictedAccess;
295
				if (fieldSignature != null)
298
				if (fieldSignature != null)
296
					field.modifiers |= AccGenericSignature;
299
					field.modifiers |= AccGenericSignature;
297
				this.fields[i] = field;
300
				this.fields[i] = field;
Lines 446-457 Link Here
446
	}
449
	}
447
450
448
	boolean isViewedAsDeprecated = isViewedAsDeprecated();
451
	boolean isViewedAsDeprecated = isViewedAsDeprecated();
452
	boolean hasRestrictedAccess = hasRestrictedAccess();
449
	this.methods = new MethodBinding[total];
453
	this.methods = new MethodBinding[total];
450
	if (total == initialTotal) {
454
	if (total == initialTotal) {
451
		for (int i = 0; i < initialTotal; i++) {
455
		for (int i = 0; i < initialTotal; i++) {
452
			MethodBinding method = createMethod(iMethods[i], sourceLevel);
456
			MethodBinding method = createMethod(iMethods[i], sourceLevel);
453
			if (isViewedAsDeprecated && !method.isDeprecated())
457
			if (isViewedAsDeprecated && !method.isDeprecated())
454
				method.modifiers |= AccDeprecatedImplicitly;
458
				method.modifiers |= AccDeprecatedImplicitly;
459
			if (hasRestrictedAccess)
460
				method.modifiers |= AccRestrictedAccess;
455
			this.methods[i] = method;
461
			this.methods[i] = method;
456
		}
462
		}
457
	} else {
463
	} else {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (+8 lines)
Lines 603-608 Link Here
603
	}
603
	}
604
	return uniqueKey;
604
	return uniqueKey;
605
}
605
}
606
public void checkDeprecatedAnnotation () {
607
	if ((this.getAnnotationTagBits() & AnnotationDeprecated) != 0) // TODO Maxime inline bypass test on annotations loading
608
		this.modifiers |= AccDeprecated;
609
}
606
void faultInTypesForFieldsAndMethods() {
610
void faultInTypesForFieldsAndMethods() {
607
	// check @Deprecated annotation
611
	// check @Deprecated annotation
608
	if ((this.getAnnotationTagBits() & AnnotationDeprecated) != 0) {
612
	if ((this.getAnnotationTagBits() & AnnotationDeprecated) != 0) {
Lines 1147-1152 Link Here
1147
	}
1151
	}
1148
	if (isViewedAsDeprecated() && !field.isDeprecated())
1152
	if (isViewedAsDeprecated() && !field.isDeprecated())
1149
		field.modifiers |= AccDeprecatedImplicitly;	
1153
		field.modifiers |= AccDeprecatedImplicitly;	
1154
	if (hasRestrictedAccess()) 
1155
		field.modifiers |= AccRestrictedAccess;
1150
	FieldDeclaration[] fieldDecls = scope.referenceContext.fields;
1156
	FieldDeclaration[] fieldDecls = scope.referenceContext.fields;
1151
	for (int f = 0, length = fieldDecls.length; f < length; f++) {
1157
	for (int f = 0, length = fieldDecls.length; f < length; f++) {
1152
		if (fieldDecls[f].binding != field)
1158
		if (fieldDecls[f].binding != field)
Lines 1202-1207 Link Here
1202
	}
1208
	}
1203
	if (isViewedAsDeprecated() && !method.isDeprecated())
1209
	if (isViewedAsDeprecated() && !method.isDeprecated())
1204
		method.modifiers |= AccDeprecatedImplicitly;
1210
		method.modifiers |= AccDeprecatedImplicitly;
1211
	if (hasRestrictedAccess())
1212
		method.modifiers |= AccRestrictedAccess;
1205
			
1213
			
1206
	AbstractMethodDeclaration methodDecl = method.sourceMethod();
1214
	AbstractMethodDeclaration methodDecl = method.sourceMethod();
1207
	if (methodDecl == null) return null; // method could not be resolved in previous iteration
1215
	if (methodDecl == null) return null; // method could not be resolved in previous iteration
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-4 / +49 lines)
Lines 614-623 Link Here
614
		case IProblem.JavadocUsingDeprecatedConstructor:
614
		case IProblem.JavadocUsingDeprecatedConstructor:
615
		case IProblem.JavadocUsingDeprecatedMethod:
615
		case IProblem.JavadocUsingDeprecatedMethod:
616
		case IProblem.JavadocUsingDeprecatedType:
616
		case IProblem.JavadocUsingDeprecatedType:
617
			if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef)) {
617
			if (!(this.options.reportInvalidJavadocTags && 
618
				return ProblemSeverities.Ignore;
618
				  this.options.reportInvalidJavadocTagsDeprecatedRef &&
619
			}
619
				  this.options.docCommentSupport)) 
620
			break;
620
				return Ignore;
621
			else if (this.options.getSeverity(CompilerOptions.InvalidJavadoc) != Error)
622
				return Warning;
623
			else if (this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI) != Error)
624
				return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI);
625
					// could even be Ignore
626
			else 
627
				return Error;
628
			// WORK look review
629
621
		/*
630
		/*
622
		 * Javadoc invalid tags due to non-visible references
631
		 * Javadoc invalid tags due to non-visible references
623
		 */
632
		 */
Lines 1184-1189 Link Here
1184
		location.sourceStart,
1193
		location.sourceStart,
1185
		location.sourceEnd);
1194
		location.sourceEnd);
1186
}
1195
}
1196
public void forbiddenReference(MethodBinding method, ASTNode location, 
1197
		String messageTemplate, int problemId) {
1198
	if (method.isConstructor())
1199
		this.handle(
1200
			problemId,
1201
			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
1202
			new String[] { 
1203
				MessageFormat.format(messageTemplate,
1204
						new String[]{new String(method.shortReadableName())})},
1205
			location.sourceStart,
1206
			location.sourceEnd);
1207
	else
1208
		this.handle(
1209
			problemId,
1210
			new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
1211
			new String[] { 
1212
				MessageFormat.format(messageTemplate, 
1213
					new String[]{
1214
						new String(method.shortReadableName()),
1215
				        new String(method.declaringClass.shortReadableName())})},
1216
			location.sourceStart,
1217
			location.sourceEnd);
1218
}
1219
public void forbiddenReference(FieldBinding field, ASTNode location, 
1220
		String messageTemplate, int problemId) {
1221
	this.handle(
1222
		problemId,
1223
		new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose
1224
		new String[] { 
1225
			MessageFormat.format(messageTemplate, 
1226
				new String[]{
1227
					new String(field.shortReadableName()),
1228
			        new String(field.declaringClass.shortReadableName())})},
1229
		location.sourceStart,
1230
		location.sourceEnd);
1231
}
1187
public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
1232
public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
1188
	this.handle(
1233
	this.handle(
1189
		IProblem.ReferenceToForwardField,
1234
		IProblem.ReferenceToForwardField,
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java (-1 / +1 lines)
Lines 190-196 Link Here
190
			return this.resolvedType;
190
			return this.resolvedType;
191
		}
191
		}
192
	}
192
	}
193
	if (isMethodUseDeprecated(this.binding, scope)) {
193
	if (isMethodUseDeprecated(this.binding, scope, true)) {
194
		scope.problemReporter().deprecatedMethod(this.binding, this);
194
		scope.problemReporter().deprecatedMethod(this.binding, this);
195
	}
195
	}
196
	if (arguments != null) {
196
	if (arguments != null) {
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java (-1 / +1 lines)
Lines 334-340 Link Here
334
		}
334
		}
335
		// abstract private methods cannot occur nor abstract static............
335
		// abstract private methods cannot occur nor abstract static............
336
	}
336
	}
337
	if (isMethodUseDeprecated(binding, scope))
337
	if (isMethodUseDeprecated(binding, scope, true))
338
		scope.problemReporter().deprecatedMethod(binding, this);
338
		scope.problemReporter().deprecatedMethod(binding, this);
339
339
340
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
340
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-4 / +24 lines)
Lines 207-213 Link Here
207
		AccessRuleSet ruleSet = createAccessRuleSet(accessRules);
207
		AccessRuleSet ruleSet = createAccessRuleSet(accessRules);
208
		if (ruleSet != null) {
208
		if (ruleSet != null) {
209
			// compute message template
209
			// compute message template
210
			ruleSet.messageTemplate = getMessageTemplate();
210
			ruleSet.messageTemplates = getMessageTemplates();
211
		}
211
		}
212
		this.accessRuleSet = ruleSet;
212
		this.accessRuleSet = ruleSet;
213
		
213
		
Lines 781-791 Link Here
781
		return this.extraAttributes;
781
		return this.extraAttributes;
782
	}
782
	}
783
	
783
	
784
	private String getMessageTemplate() {
784
	private String[] getMessageTemplates() {
785
		String [] result = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
785
		if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling
786
		if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling
786
			return Messages.bind(
787
			result[0] = Messages.bind(
787
				org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_project,
788
				org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_project,
788
				new String[] {"{0}", getPath().segment(0)});  //$NON-NLS-1$
789
				new String[] {"{0}", getPath().segment(0)});  //$NON-NLS-1$
790
			result[1] = Messages.bind(
791
					org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_project,
792
					new String[] {"{0}", getPath().segment(0)});  //$NON-NLS-1$
793
			result[2] = Messages.bind(
794
					org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_method_project,
795
					new String[] {"{0}", "{1}", getPath().segment(0)});  //$NON-NLS-1$ //$NON-NLS-2$
796
			result[3] = Messages.bind(
797
					org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_field_project,
798
					new String[] {"{0}", "{1}", getPath().segment(0)});  //$NON-NLS-1$ //$NON-NLS-2$
789
		} else {
799
		} else {
790
			IPath libPath = getPath();
800
			IPath libPath = getPath();
791
			Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), libPath, false);
801
			Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), libPath, false);
Lines 794-803 Link Here
794
				pathString = libPath.toOSString();
804
				pathString = libPath.toOSString();
795
			else
805
			else
796
				pathString = libPath.makeRelative().toString();
806
				pathString = libPath.makeRelative().toString();
797
			return Messages.bind(
807
			result[0] = Messages.bind(
798
				org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_library,
808
				org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_library,
799
				new String[] {"{0}", pathString}); //$NON-NLS-1$ 
809
				new String[] {"{0}", pathString}); //$NON-NLS-1$ 
810
			result[1] = Messages.bind(
811
					org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_library,
812
					new String[] {"{0}", pathString}); //$NON-NLS-1$ 
813
			result[2] = Messages.bind(
814
					org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_method_library,
815
					new String[] {"{0}", "{1}", pathString}); //$NON-NLS-1$ //$NON-NLS-2$ 
816
			result[3] = Messages.bind(
817
					org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_field_library,
818
					new String[] {"{0}", "{1}", pathString}); //$NON-NLS-1$ //$NON-NLS-2$ 
800
		}
819
		}
820
		return result;
801
	}
821
	}
802
822
803
	/**
823
	/**
(-)model/org/eclipse/jdt/internal/core/builder/State.java (-3 / +7 lines)
Lines 330-338 Link Here
330
		int problemId = in.readInt();
330
		int problemId = in.readInt();
331
		accessRules[i] = new ClasspathAccessRule(pattern, problemId);
331
		accessRules[i] = new ClasspathAccessRule(pattern, problemId);
332
	}
332
	}
333
	String messageTemplate = in.readUTF();
333
	String[] messageTemplates = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
334
	for (int i = 0; i < 3; i++) {
335
		messageTemplates[i] = in.readUTF();
336
	}
334
	AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules);
337
	AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules);
335
	accessRuleSet.messageTemplate = messageTemplate;
338
	accessRuleSet.messageTemplates = messageTemplates;
336
	return accessRuleSet;
339
	return accessRuleSet;
337
}
340
}
338
341
Lines 601-607 Link Here
601
				writeName(accessRule.pattern, out);
604
				writeName(accessRule.pattern, out);
602
				out.writeInt(accessRule.problemId);
605
				out.writeInt(accessRule.problemId);
603
			}
606
			}
604
			out.writeUTF(accessRuleSet.messageTemplate);
607
			for (int i = 0; i < accessRuleSet.messageTemplates.length; i++)
608
				out.writeUTF(accessRuleSet.messageTemplates[i]);
605
		}
609
		}
606
	}
610
	}
607
}
611
}
(-)model/org/eclipse/jdt/internal/core/util/Messages.java (-1 / +8 lines)
Lines 166-173 Link Here
166
	public static String cache_invalidLoadFactor;
166
	public static String cache_invalidLoadFactor;
167
	public static String savedState_jobName;
167
	public static String savedState_jobName;
168
	public static String javamodel_initialization;
168
	public static String javamodel_initialization;
169
	public static String restrictedAccess_project;
169
	public static String restrictedAccess_project; 
170
	// WORK look ask Philippe if we could rename this to restrictedAccess_type_project or add it
170
	public static String restrictedAccess_library;
171
	public static String restrictedAccess_library;
172
	public static String restrictedAccess_constructor_project;
173
	public static String restrictedAccess_constructor_library;
174
	public static String restrictedAccess_field_project;
175
	public static String restrictedAccess_field_library;
176
	public static String restrictedAccess_method_project;
177
	public static String restrictedAccess_method_library;
171
	public static String convention_unit_nullName;
178
	public static String convention_unit_nullName;
172
	public static String convention_unit_notJavaName;
179
	public static String convention_unit_notJavaName;
173
	public static String convention_classFile_nullName;
180
	public static String convention_classFile_nullName;
(-)model/org/eclipse/jdt/internal/core/util/messages.properties (+6 lines)
Lines 178-183 Link Here
178
### access restrictions
178
### access restrictions
179
restrictedAccess_project = The type {0} is not accessible due to restriction on required project {1}
179
restrictedAccess_project = The type {0} is not accessible due to restriction on required project {1}
180
restrictedAccess_library = The type {0} is not accessible due to restriction on required library {1}
180
restrictedAccess_library = The type {0} is not accessible due to restriction on required library {1}
181
restrictedAccess_constructor_project = The constructor {0} is not accessible due to restriction on required project {1}
182
restrictedAccess_constructor_library = The constructor {0} is not accessible due to restriction on required library {1}
183
restrictedAccess_field_project = The field {0} from the type {1} is not accessible due to restriction on required project {2}
184
restrictedAccess_field_library = The field {0} from the type {1} is not accessible due to restriction on required library {2}
185
restrictedAccess_method_project = The method {0} from the type {1} is not accessible due to restriction on required project {2}
186
restrictedAccess_method_library = The method {0} from the type {1} is not accessible due to restriction on required library {2}
181
187
182
### java conventions
188
### java conventions
183
convention_unit_nullName = Compilation unit name must not be null
189
convention_unit_nullName = Compilation unit name must not be null

Return to bug 76266