Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 32416 Details for
Bug 76266
[plan][compiler] Access restriction should also apply to inherited members
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New proposal, sync'd with v_631 level, workspace unified format
org.eclipse.jdt.core_whole_12_v_631.txt (text/plain), 54.66 KB, created by
Maxime Daniel
on 2006-01-03 11:31:04 EST
(
hide
)
Description:
New proposal, sync'd with v_631 level, workspace unified format
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2006-01-03 11:31:04 EST
Size:
54.66 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java,v >retrieving revision 1.23 >diff -u -r1.23 JavadocMessageSend.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 18 Nov 2005 16:46:21 -0000 1.23 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 3 Jan 2006 16:13:01 -0000 >@@ -165,7 +165,7 @@ > } > } > } >- if (isMethodUseDeprecated(this.binding, scope)) { >+ if (isMethodUseDeprecated(this.binding, scope, true)) { > scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers()); > } > >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java,v >retrieving revision 1.48 >diff -u -r1.48 ExplicitConstructorCall.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 24 Nov 2005 19:40:08 -0000 1.48 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 3 Jan 2006 16:13:01 -0000 >@@ -330,7 +330,7 @@ > argumentTypes = new TypeBinding[] { scope.getJavaLangString(), BaseTypes.IntBinding }; > } > if ((binding = scope.getConstructor(receiverType, argumentTypes, this)).isValidBinding()) { >- if (isMethodUseDeprecated(binding, scope)) >+ if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ImplicitSuper)) > scope.problemReporter().deprecatedMethod(binding, this); > checkInvocationArguments(scope, null, receiverType, binding, this.arguments, argumentTypes, argsContainCast, this); > if (binding.isPrivate() || receiverType.isLocalType()) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v >retrieving revision 1.71 >diff -u -r1.71 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 18 Nov 2005 16:46:22 -0000 1.71 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 3 Jan 2006 16:13:02 -0000 >@@ -303,7 +303,7 @@ > } > ReferenceBinding allocationType = (ReferenceBinding) receiverType; > if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { >- if (isMethodUseDeprecated(binding, scope)) { >+ if (isMethodUseDeprecated(binding, scope, true)) { > scope.problemReporter().deprecatedMethod(this.binding, this); > } > checkInvocationArguments(scope, null, allocationType, binding, this.arguments, argumentTypes, argsContainCast, this); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v >retrieving revision 1.55 >diff -u -r1.55 AllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 24 Nov 2005 19:40:08 -0000 1.55 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 3 Jan 2006 16:13:01 -0000 >@@ -319,7 +319,7 @@ > scope.problemReporter().invalidConstructor(this, binding); > return this.resolvedType; > } >- if (isMethodUseDeprecated(binding, scope)) >+ if (isMethodUseDeprecated(binding, scope, true)) > scope.problemReporter().deprecatedMethod(binding, this); > checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this); > >Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java,v >retrieving revision 1.23 >diff -u -r1.23 JavadocAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java 18 Nov 2005 16:46:21 -0000 1.23 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java 3 Jan 2006 16:13:01 -0000 >@@ -121,7 +121,7 @@ > } > } > } >- if (isMethodUseDeprecated(this.binding, scope)) { >+ if (isMethodUseDeprecated(this.binding, scope, true)) { > scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers()); > } > return allocationType; >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.55 >diff -u -r1.55 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 25 Nov 2005 17:46:33 -0000 1.55 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 3 Jan 2006 16:13:01 -0000 >@@ -265,6 +265,15 @@ > // ignore cases where field is used from within inside itself > field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } >+ >+ if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { >+ AccessRestriction restriction = >+ scope.environment().getAccessRestriction(field.declaringClass); >+ if (restriction != null) { >+ scope.problemReporter().forbiddenReference(field, this, >+ restriction.getFieldAccessMessageTemplate(), restriction.getProblemId()); >+ } >+ } > > if (!field.isViewedAsDeprecated()) return false; > >@@ -284,18 +293,45 @@ > /* Answer true if the method use is considered deprecated. > * An access in the same compilation unit is allowed. > */ >- public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope) { >- >+ public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, >+ boolean isExplicitUse) { > if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { > // ignore cases where method is used from within inside itself (e.g. direct recursions) > method.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } > >+ // TODO (maxime) consider separating concerns between deprecation and access restriction. >+ // Caveat: this was not the case when access restriction funtion was added. >+ if (isExplicitUse && (method.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { >+ // note: explicit constructors calls warnings are kept despite the 'new C1()' case (two >+ // warnings, one on type, the other on constructor), because of the 'super()' case. >+ AccessRestriction restriction = >+ scope.environment().getAccessRestriction(method.declaringClass); >+ if (restriction != null) { >+ if (method.isConstructor()) { >+ scope.problemReporter().forbiddenReference(method, this, >+ restriction.getConstructorAccessMessageTemplate(), >+ restriction.getProblemId()); >+ } >+ else { >+ scope.problemReporter().forbiddenReference(method, this, >+ restriction.getMethodAccessMessageTemplate(), >+ restriction.getProblemId()); >+ } >+ } >+ } >+ > if (!method.isViewedAsDeprecated()) return false; > > // inside same unit - no report > if (scope.isDefinedInSameUnit(method.declaringClass)) return false; > >+ // non explicit use and non explicitly deprecated - no report >+ if (!isExplicitUse && >+ (method.modifiers & ClassFileConstants.AccDeprecated) == 0) { >+ return false; >+ } >+ > // if context is deprecated, may avoid reporting > if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; > return true; >@@ -334,7 +370,10 @@ > scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId()); > } > } >- >+ >+ // force annotations resolution before deciding whether the type may be deprecated >+ refType.getAnnotationTagBits(); >+ > if (!refType.isViewedAsDeprecated()) return false; > > // inside same unit - no report >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v >retrieving revision 1.104 >diff -u -r1.104 MessageSend.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 5 Dec 2005 11:54:29 -0000 1.104 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 3 Jan 2006 16:13:02 -0000 >@@ -431,7 +431,7 @@ > } > // abstract private methods cannot occur nor abstract static............ > } >- if (isMethodUseDeprecated(binding, scope)) >+ if (isMethodUseDeprecated(binding, scope, true)) > scope.problemReporter().deprecatedMethod(binding, this); > > // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) >Index: model/org/eclipse/jdt/internal/core/builder/State.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java,v >retrieving revision 1.50 >diff -u -r1.50 State.java >--- model/org/eclipse/jdt/internal/core/builder/State.java 5 Dec 2005 20:28:06 -0000 1.50 >+++ model/org/eclipse/jdt/internal/core/builder/State.java 3 Jan 2006 16:13:04 -0000 >@@ -330,9 +330,12 @@ > int problemId = in.readInt(); > accessRules[i] = new ClasspathAccessRule(pattern, problemId); > } >- String messageTemplate = in.readUTF(); >+ String[] messageTemplates = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH]; >+ for (int i = 0; i < 3; i++) { >+ messageTemplates[i] = in.readUTF(); >+ } > AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules); >- accessRuleSet.messageTemplate = messageTemplate; >+ accessRuleSet.messageTemplates = messageTemplates; > return accessRuleSet; > } > >@@ -601,7 +604,8 @@ > writeName(accessRule.pattern, out); > out.writeInt(accessRule.problemId); > } >- out.writeUTF(accessRuleSet.messageTemplate); >+ for (int i = 0; i < accessRuleSet.messageTemplates.length; i++) >+ out.writeUTF(accessRuleSet.messageTemplates[i]); > } > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.275 >diff -u -r1.275 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 2 Dec 2005 15:50:14 -0000 1.275 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 3 Jan 2006 16:13:03 -0000 >@@ -1210,6 +1210,42 @@ > location.sourceStart, > location.sourceEnd); > } >+public void forbiddenReference(MethodBinding method, ASTNode location, >+ String messageTemplate, int problemId) { >+ if (method.isConstructor()) >+ this.handle( >+ problemId, >+ new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose >+ new String[] { >+ MessageFormat.format(messageTemplate, >+ new String[]{new String(method.shortReadableName())})}, >+ location.sourceStart, >+ location.sourceEnd); >+ else >+ this.handle( >+ problemId, >+ new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose >+ new String[] { >+ MessageFormat.format(messageTemplate, >+ new String[]{ >+ new String(method.shortReadableName()), >+ new String(method.declaringClass.shortReadableName())})}, >+ location.sourceStart, >+ location.sourceEnd); >+} >+public void forbiddenReference(FieldBinding field, ASTNode location, >+ String messageTemplate, int problemId) { >+ this.handle( >+ problemId, >+ new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose >+ new String[] { >+ MessageFormat.format(messageTemplate, >+ new String[]{ >+ new String(field.shortReadableName()), >+ new String(field.declaringClass.shortReadableName())})}, >+ location.sourceStart, >+ location.sourceEnd); >+} > public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) { > this.handle( > IProblem.ReferenceToForwardField, >Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.220 >diff -u -r1.220 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 25 Nov 2005 18:38:05 -0000 1.220 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 3 Jan 2006 16:13:01 -0000 >@@ -2533,8 +2533,7 @@ > } > } > if (rulesOK) { >- AccessRuleSet accessRuleSet = new AccessRuleSet( >- accessRules, "{0}"); //$NON-NLS-1$ >+ AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules); > FileSystem.Classpath currentClasspath = FileSystem > .getClasspath(currentClasspathName, > customEncoding, 0, accessRuleSet); >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java,v >retrieving revision 1.45 >diff -u -r1.45 CodeSnippetMessageSend.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 18 Nov 2005 16:46:23 -0000 1.45 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 3 Jan 2006 16:13:03 -0000 >@@ -335,7 +335,7 @@ > } > // abstract private methods cannot occur nor abstract static............ > } >- if (isMethodUseDeprecated(binding, scope)) >+ if (isMethodUseDeprecated(binding, scope, true)) > scope.problemReporter().deprecatedMethod(binding, this); > > // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java,v >retrieving revision 1.30 >diff -u -r1.30 CodeSnippetAllocationExpression.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java 18 Nov 2005 16:46:23 -0000 1.30 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java 3 Jan 2006 16:13:03 -0000 >@@ -191,7 +191,7 @@ > return this.resolvedType; > } > } >- if (isMethodUseDeprecated(this.binding, scope)) { >+ if (isMethodUseDeprecated(this.binding, scope, true)) { > scope.problemReporter().deprecatedMethod(this.binding, this); > } > if (arguments != null) { >Index: model/org/eclipse/jdt/internal/core/util/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties,v >retrieving revision 1.49 >diff -u -r1.49 messages.properties >--- model/org/eclipse/jdt/internal/core/util/messages.properties 5 Dec 2005 15:33:53 -0000 1.49 >+++ model/org/eclipse/jdt/internal/core/util/messages.properties 3 Jan 2006 16:13:04 -0000 >@@ -180,6 +180,12 @@ > ### access restrictions > restrictedAccess_project = The type {0} is not accessible due to restriction on required project {1} > restrictedAccess_library = The type {0} is not accessible due to restriction on required library {1} >+restrictedAccess_constructor_project = The constructor {0} is not accessible due to restriction on required project {1} >+restrictedAccess_constructor_library = The constructor {0} is not accessible due to restriction on required library {1} >+restrictedAccess_field_project = The field {0} from the type {1} is not accessible due to restriction on required project {2} >+restrictedAccess_field_library = The field {0} from the type {1} is not accessible due to restriction on required library {2} >+restrictedAccess_method_project = The method {0} from the type {1} is not accessible due to restriction on required project {2} >+restrictedAccess_method_library = The method {0} from the type {1} is not accessible due to restriction on required library {2} > > ### java conventions > convention_unit_nullName = Compilation unit name must not be null >Index: model/org/eclipse/jdt/internal/core/util/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Messages.java,v >retrieving revision 1.8 >diff -u -r1.8 Messages.java >--- model/org/eclipse/jdt/internal/core/util/Messages.java 5 Dec 2005 15:33:53 -0000 1.8 >+++ model/org/eclipse/jdt/internal/core/util/Messages.java 3 Jan 2006 16:13:04 -0000 >@@ -170,6 +170,12 @@ > public static String javamodel_initialization; > public static String restrictedAccess_project; > public static String restrictedAccess_library; >+ public static String restrictedAccess_constructor_project; >+ public static String restrictedAccess_constructor_library; >+ public static String restrictedAccess_field_project; >+ public static String restrictedAccess_field_library; >+ public static String restrictedAccess_method_project; >+ public static String restrictedAccess_method_library; > public static String convention_unit_nullName; > public static String convention_unit_notJavaName; > public static String convention_classFile_nullName; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v >retrieving revision 1.82 >diff -u -r1.82 BinaryTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 20 Oct 2005 13:26:45 -0000 1.82 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 3 Jan 2006 16:13:02 -0000 >@@ -272,6 +272,7 @@ > this.fields = new FieldBinding[size]; > boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5; > boolean isViewedAsDeprecated = isViewedAsDeprecated(); >+ boolean hasRestrictedAccess = hasRestrictedAccess(); > for (int i = 0; i < size; i++) { > IBinaryField binaryField = iFields[i]; > char[] fieldSignature = use15specifics ? binaryField.getGenericSignature() : null; >@@ -290,6 +291,9 @@ > field.tagBits |= binaryField.getTagBits(); > if (isViewedAsDeprecated && !field.isDeprecated()) > field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; >+ if (hasRestrictedAccess) { >+ field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; >+ } > if (fieldSignature != null) > field.modifiers |= ExtraCompilerModifiers.AccGenericSignature; > this.fields[i] = field; >@@ -444,12 +448,16 @@ > } > > boolean isViewedAsDeprecated = isViewedAsDeprecated(); >+ boolean hasRestrictedAccess = hasRestrictedAccess(); > this.methods = new MethodBinding[total]; > if (total == initialTotal) { > for (int i = 0; i < initialTotal; i++) { > MethodBinding method = createMethod(iMethods[i], sourceLevel); > if (isViewedAsDeprecated && !method.isDeprecated()) > method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; >+ if (hasRestrictedAccess) { >+ method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; >+ } > this.methods[i] = method; > } > } else { >@@ -458,6 +466,9 @@ > MethodBinding method = createMethod(iMethods[i], sourceLevel); > if (isViewedAsDeprecated && !method.isDeprecated()) > method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; >+ if (hasRestrictedAccess) { >+ method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; >+ } > this.methods[index++] = method; > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.116 >diff -u -r1.116 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 5 Dec 2005 19:35:42 -0000 1.116 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 3 Jan 2006 16:13:02 -0000 >@@ -644,6 +644,9 @@ > } finally { > typeDecl.staticInitializerScope.insideTypeAnnotation = old; > } >+ if ((this.tagBits & AnnotationDeprecated) != 0) { >+ this.modifiers |= ClassFileConstants.AccDeprecated; >+ } > } > return this.tagBits; > } >@@ -1085,6 +1088,9 @@ > } > if (isViewedAsDeprecated() && !field.isDeprecated()) > field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; >+ if (hasRestrictedAccess()) { >+ field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; >+ } > FieldDeclaration[] fieldDecls = scope.referenceContext.fields; > for (int f = 0, length = fieldDecls.length; f < length; f++) { > if (fieldDecls[f].binding != field) >@@ -1138,6 +1144,9 @@ > } > if (isViewedAsDeprecated() && !method.isDeprecated()) > method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; >+ if (hasRestrictedAccess()) { >+ method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; >+ } > > AbstractMethodDeclaration methodDecl = method.sourceMethod(); > if (methodDecl == null) return null; // method could not be resolved in previous iteration >Index: compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java,v >retrieving revision 1.11 >diff -u -r1.11 AccessRestriction.java >--- compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java 20 Apr 2005 16:47:02 -0000 1.11 >+++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java 3 Jan 2006 16:13:02 -0000 >@@ -13,10 +13,10 @@ > public class AccessRestriction { > > private AccessRule accessRule; >- private String messageTemplate; >- public AccessRestriction(AccessRule accessRule, String messageTemplate) { >+ private String[] messageTemplates; >+ public AccessRestriction(AccessRule accessRule, String [] messageTemplates) { > this.accessRule = accessRule; >- this.messageTemplate = messageTemplate; >+ this.messageTemplates = messageTemplates; > } > > /** >@@ -25,9 +25,21 @@ > * e.g. "{0} has restricted access" > */ > public String getMessageTemplate() { >- return this.messageTemplate; >+ return this.messageTemplates[0]; > } > >+ public String getConstructorAccessMessageTemplate() { >+ return this.messageTemplates[1]; >+ } >+ >+ public String getMethodAccessMessageTemplate() { >+ return this.messageTemplates[2]; >+ } >+ >+ public String getFieldAccessMessageTemplate() { >+ return this.messageTemplates[3]; >+ } >+ > public int getProblemId() { > return this.accessRule.problemId; > } >Index: compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java,v >retrieving revision 1.8 >diff -u -r1.8 AccessRuleSet.java >--- compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 6 Dec 2005 16:21:53 -0000 1.8 >+++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 3 Jan 2006 16:13:02 -0000 >@@ -19,16 +19,31 @@ > public class AccessRuleSet { > > private AccessRule[] accessRules; >- public String messageTemplate; >+ public String[] messageTemplates; >+ public static final int MESSAGE_TEMPLATES_LENGTH = 4; > > > public AccessRuleSet(AccessRule[] accessRules) { >- this.accessRules = accessRules; >+ this(accessRules, null); > } >- public AccessRuleSet(AccessRule[] accessRules, String messageTemplate) { >+ >+ /** >+ * Make a new set of access rules. >+ * @param accessRules the access rules to be contained by the new set >+ * @param messageTemplates a Sting[4] array specifying the messages for type, >+ * constructor, method and field access violation; each should contain as many >+ * placeholders as expected by the respective access violation message (that is, >+ * one for type and constructor, two for method and field). >+ */ >+ // TODO (maxime) move to better support >+ public AccessRuleSet(AccessRule[] accessRules, String[] messageTemplates) { > this.accessRules = accessRules; >- this.messageTemplate = messageTemplate; >+ if (messageTemplates != null && messageTemplates.length == MESSAGE_TEMPLATES_LENGTH) >+ this.messageTemplates = messageTemplates; >+ else >+ this.messageTemplates = new String[] {"{0}", "{0}", "{0} {1}", "{0} {1}"}; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ > } >+ > /** > * @see java.lang.Object#equals(java.lang.Object) > */ >@@ -38,8 +53,12 @@ > if (!(object instanceof AccessRuleSet)) > return false; > AccessRuleSet otherRuleSet = (AccessRuleSet) object; >- if (!this.messageTemplate.equals(otherRuleSet.messageTemplate)) >- return false; >+ if (this.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH || >+ otherRuleSet.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH) >+ return false; // guard >+ for (int i = 0; i < MESSAGE_TEMPLATES_LENGTH; i++) >+ if (!this.messageTemplates[i].equals(otherRuleSet.messageTemplates[i])) >+ return false; > int rulesLength = this.accessRules.length; > if (rulesLength != otherRuleSet.accessRules.length) return false; > for (int i = 0; i < rulesLength; i++) >@@ -67,7 +86,7 @@ > switch (accessRule.problemId) { > case IProblem.ForbiddenReference: > case IProblem.DiscouragedReference: >- return new AccessRestriction(accessRule, this.messageTemplate); >+ return new AccessRestriction(accessRule, this.messageTemplates); > default: > return null; > } >@@ -95,10 +114,10 @@ > else if (i < length-1) > buffer.append(", "); //$NON-NLS-1$ > } >- buffer >- .append("} [template:\"") //$NON-NLS-1$ >- .append(this.messageTemplate) >- .append("\"]"); //$NON-NLS-1$ >+ buffer.append("} [templates:\""); //$NON-NLS-1$ >+ for (int i = 0; i < messageTemplates.length; i++) >+ buffer.append(this.messageTemplates[i]); >+ buffer.append("\"]"); //$NON-NLS-1$ > return buffer.toString(); > } > } >Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v >retrieving revision 1.83 >diff -u -r1.83 ClasspathEntry.java >--- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 5 Sep 2005 11:39:01 -0000 1.83 >+++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 3 Jan 2006 16:13:04 -0000 >@@ -220,7 +220,7 @@ > AccessRuleSet ruleSet = createAccessRuleSet(accessRules); > if (ruleSet != null) { > // compute message template >- ruleSet.messageTemplate = getMessageTemplate(); >+ ruleSet.messageTemplates = getMessageTemplates(); > } > this.accessRuleSet = ruleSet; > >@@ -944,11 +944,21 @@ > return this.extraAttributes; > } > >- private String getMessageTemplate() { >+ private String[] getMessageTemplates() { >+ String [] result = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH]; > if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling >- return Messages.bind( >+ result[0] = Messages.bind( > org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_project, > new String[] {"{0}", getPath().segment(0)}); //$NON-NLS-1$ >+ result[1] = Messages.bind( >+ org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_project, >+ new String[] {"{0}", getPath().segment(0)}); //$NON-NLS-1$ >+ result[2] = Messages.bind( >+ org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_method_project, >+ new String[] {"{0}", "{1}", getPath().segment(0)}); //$NON-NLS-1$ //$NON-NLS-2$ >+ result[3] = Messages.bind( >+ org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_field_project, >+ new String[] {"{0}", "{1}", getPath().segment(0)}); //$NON-NLS-1$ //$NON-NLS-2$ > } else { > IPath libPath = getPath(); > Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), libPath, false); >@@ -957,10 +967,20 @@ > pathString = libPath.toOSString(); > else > pathString = libPath.makeRelative().toString(); >- return Messages.bind( >+ result[0] = Messages.bind( > org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_library, > new String[] {"{0}", pathString}); //$NON-NLS-1$ >+ result[1] = Messages.bind( >+ org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_library, >+ new String[] {"{0}", pathString}); //$NON-NLS-1$ >+ result[2] = Messages.bind( >+ org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_method_library, >+ new String[] {"{0}", "{1}", pathString}); //$NON-NLS-1$ //$NON-NLS-2$ >+ result[3] = Messages.bind( >+ org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_field_library, >+ new String[] {"{0}", "{1}", pathString}); //$NON-NLS-1$ //$NON-NLS-2$ > } >+ return result; > } > > /** >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java,v >retrieving revision 1.66 >diff -u -r1.66 AllJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java 17 Nov 2005 08:53:33 -0000 1.66 >+++ src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java 3 Jan 2006 16:13:08 -0000 >@@ -125,6 +125,9 @@ > // Inclusion patterns tests > InclusionPatternsTests.class, > >+ // Access restrictions tests >+ AccessRestrictionsTests.class, >+ > // Signature tests > SignatureTests.class, > >Index: src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java,v >retrieving revision 1.75 >diff -u -r1.75 ReconcilerTests.java >--- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 5 Dec 2005 15:52:04 -0000 1.75 >+++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 3 Jan 2006 16:13:09 -0000 >@@ -2083,15 +2083,10 @@ > "----------\n" + > "1. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + > " public class Y extends X {\n" + >- " ^\n" + >- "The constructor X() is deprecated\n" + >- "----------\n" + >- "2. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + >- " public class Y extends X {\n" + > " ^\n" + > "The type X is deprecated\n" + > "----------\n" + >- "3. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + >+ "2. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + > " Zork z;\n" + > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + >@@ -2219,15 +2214,10 @@ > "----------\n" + > "1. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + > " public class Y extends X {\n" + >- " ^\n" + >- "The constructor X() is deprecated\n" + >- "----------\n" + >- "2. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + >- " public class Y extends X {\n" + > " ^\n" + > "The type X is deprecated\n" + > "----------\n" + >- "3. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + >+ "2. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + > " Zork z;\n" + > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + >Index: src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java,v >retrieving revision 1.39 >diff -u -r1.39 ModifyingResourceTests.java >--- src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java 15 Apr 2005 08:27:55 -0000 1.39 >+++ src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java 3 Jan 2006 16:13:08 -0000 >@@ -295,12 +295,20 @@ > for (int j = 0; j < ruleCount; j++) { > String rule = tokenizer.nextToken(); > int kind; >- if (rule.charAt(0) == '+') { >- kind = IAccessRule.K_ACCESSIBLE; >- } else { >- kind = IAccessRule.K_NON_ACCESSIBLE; >- nonAccessibleRules++; >+ switch (rule.charAt(0)) { >+ case '+': >+ kind = IAccessRule.K_ACCESSIBLE; >+ break; >+ case '~': >+ kind = IAccessRule.K_DISCOURAGED; >+ break; >+ case '-': >+ default: // TODO (maxime) consider forbidding unspecified rule start; this one tolerates >+ // shortcuts that only specify a path matching pattern >+ kind = IAccessRule.K_NON_ACCESSIBLE; >+ break; > } >+ nonAccessibleRules++; > accessRules[j] = JavaCore.newAccessRule(new Path(rule.substring(1)), kind); > } > >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.154 >diff -u -r1.154 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 5 Dec 2005 15:52:04 -0000 1.154 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 3 Jan 2006 16:13:08 -0000 >@@ -56,7 +56,7 @@ > public static class ProblemRequestor implements IProblemRequestor { > public StringBuffer problems; > public int problemCount; >- private char[] unitSource; >+ protected char[] unitSource; > public ProblemRequestor() { > initialize(null); > } >Index: src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java >diff -N src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,483 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.model; >+ >+ >+import junit.framework.Test; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.*; >+import org.eclipse.jdt.core.compiler.IProblem; >+ >+public class AccessRestrictionsTests extends ModifyingResourceTests { >+ static class ProblemRequestor extends AbstractJavaModelTests.ProblemRequestor { >+ ProblemRequestor (String source) { >+ if (source != null) >+ unitSource = source.toCharArray(); >+ } >+ ProblemRequestor() { >+ } >+ public void acceptProblem(IProblem problem) { >+ super.acceptProblem(problem); >+ } >+ } >+ >+ protected ProblemRequestor problemRequestor; >+ >+ public AccessRestrictionsTests(String name) { >+ super(name); >+ } >+ >+ // Use this static initializer to specify subset for tests >+ // All specified tests which do not belong to the class are skipped... >+ static { >+ // Names of tests to run, like "testXXX" >+ //TESTS_NAMES = new String[] { "test004" }; >+ // Numbers of tests to run: "test<number>" will be run for each number of this array >+ //TESTS_NUMBERS = new int[] { 1 }; >+ // Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last } >+ //TESTS_RANGE = new int[] { 16, -1 }; >+ } >+ >+ public static Test suite() { >+ return buildTestSuite(AccessRestrictionsTests.class); >+ } >+ >+ protected void assertProblems(String message, String expected) { >+ assertProblems(message, expected, this.problemRequestor); >+ } >+ >+/* >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76266 >+ * Ensures that a problem is created for a reference to a member of a type that is not >+ * accessible in a prereq project, even though it is accessed through an intermediate >+ * accessible mother class. >+ * Checking methods. >+ */ >+public void test001() throws CoreException { >+ ICompilationUnit x1 = null, x2 = null, y = null, z = null; >+ try { >+ WorkingCopyOwner owner = new WorkingCopyOwner(){}; >+ createJavaProject( >+ "P1", >+ new String[] {"src"}, >+ new String[] {"JCL_LIB"}, >+ "bin"); >+ this.problemRequestor = new ProblemRequestor(); >+ x1 = getWorkingCopy( >+ "/P1/src/p/X1.java", >+ "package p;\n" + >+ "public class X1 {\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}", >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ this.problemRequestor = new ProblemRequestor(); >+ x2 = getWorkingCopy( >+ "/P1/src/p/X2.java", >+ "package p;\n" + >+ "public class X2 extends X1 {\n" + >+ " void bar() {\n" + >+ " }\n" + >+ "}", owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, >+ new String[] {"JCL_LIB"}, "bin"); >+ IClasspathEntry[] classpath = p2.getRawClasspath(); >+ int length = classpath.length; >+ System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length); >+ classpath[length] = createSourceEntry("P2", "/P1", "-p/X1"); >+ p2.setRawClasspath(classpath, null); >+ // check the most basic case >+ String src = >+ "package p;\n" + >+ "public class Z extends X1 {\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ z = getWorkingCopy( >+ "/P2/src/p/Z.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n----------\n----------\n" + >+ "1. ERROR in /P2/src/p/Z.java (at line 2)\n" + >+ " public class Z extends X1 {\n" + >+ " ^^\n" + >+ "Access restriction: The type X1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ // check the specifics of this test case >+ src = >+ "package p;\n" + >+ "public class Y extends X2 {\n" + >+ " void foobar() {\n" + >+ " foo(); // accesses X1.foo, should trigger an error\n" + >+ " bar(); // accesses X2.bar, OK\n" + >+ " }\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ y = getWorkingCopy( >+ "/P2/src/p/Y.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in /P2/src/p/Y.java (at line 4)\n" + >+ " foo(); // accesses X1.foo, should trigger an error\n" + >+ " ^^^^^\n" + >+ "Access restriction: The method foo() from the type X1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ } finally { >+ if (x1 != null) >+ x1.discardWorkingCopy(); >+ if (x2 != null) >+ x2.discardWorkingCopy(); >+ if (y != null) >+ y.discardWorkingCopy(); >+ if (z != null) >+ z.discardWorkingCopy(); >+ deleteProjects(new String[] {"P1", "P2"}); >+ } >+} >+ >+/* >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76266 >+ * Ensures that a problem is created for a reference to a member of a type that is not >+ * accessible in a prereq project, even though it is accessed through an intermediate >+ * accessible mother class. >+ * Checking members. >+ */ >+public void test002() throws CoreException { >+ ICompilationUnit x1 = null, x2 = null, y = null, z = null; >+ try { >+ WorkingCopyOwner owner = new WorkingCopyOwner(){}; >+ createJavaProject( >+ "P1", >+ new String[] {"src"}, >+ new String[] {"JCL_LIB"}, >+ "bin"); >+ this.problemRequestor = new ProblemRequestor(); >+ x1 = getWorkingCopy( >+ "/P1/src/p/X1.java", >+ "package p;\n" + >+ "public class X1 {\n" + >+ " int m1;\n" + >+ "}", >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ this.problemRequestor = new ProblemRequestor(); >+ x2 = getWorkingCopy( >+ "/P1/src/p/X2.java", >+ "package p;\n" + >+ "public class X2 extends X1 {\n" + >+ " char m2;\n" + >+ "}", >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, >+ new String[] {"JCL_LIB"}, "bin"); >+ IClasspathEntry[] classpath = p2.getRawClasspath(); >+ int length = classpath.length; >+ System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length); >+ classpath[length] = createSourceEntry("P2", "/P1", "-p/X1"); >+ p2.setRawClasspath(classpath, null); >+ // check the most basic case >+ String src = >+ "package p;\n" + >+ "public class Z extends X1 {\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ z = getWorkingCopy( >+ "/P2/src/p/Z.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n----------\n----------\n" + >+ "1. ERROR in /P2/src/p/Z.java (at line 2)\n" + >+ " public class Z extends X1 {\n" + >+ " ^^\n" + >+ "Access restriction: The type X1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ // check the specifics of this test case >+ src = >+ "package p;\n" + >+ "public class Y extends X2 {\n" + >+ " void foobar() {\n" + >+ " int l1 = m1; // accesses X1.m1, should trigger an error\n" + >+ " char l2 = m2; // accesses X2.m2, OK\n" + >+ " }\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ y = getWorkingCopy( >+ "/P2/src/p/Y.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in /P2/src/p/Y.java (at line 4)\n" + >+ " int l1 = m1; // accesses X1.m1, should trigger an error\n" + >+ " ^^\n" + >+ "Access restriction: The field m1 from the type X1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ } finally { >+ if (x1 != null) >+ x1.discardWorkingCopy(); >+ if (x2 != null) >+ x2.discardWorkingCopy(); >+ if (y != null) >+ y.discardWorkingCopy(); >+ if (z != null) >+ z.discardWorkingCopy(); >+ deleteProjects(new String[] {"P1", "P2"}); >+ } >+} >+ >+/* >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76266 >+ * Ensures that a problem is created for a reference to a member of a type that is not >+ * accessible in a prereq project, even though it is accessed through an intermediate >+ * accessible mother class. >+ * Checking member types. >+ */ >+public void test003() throws CoreException { >+ ICompilationUnit x1 = null, x2 = null, y = null, z = null; >+ try { >+ WorkingCopyOwner owner = new WorkingCopyOwner(){}; >+ createJavaProject( >+ "P1", >+ new String[] {"src"}, >+ new String[] {"JCL_LIB"}, >+ "bin"); >+ this.problemRequestor = new ProblemRequestor(); >+ x1 = getWorkingCopy( >+ "/P1/src/p/X1.java", >+ "package p;\n" + >+ "public class X1 {\n" + >+ " class C1 {\n" + >+ " protected C1 (int dummy) {}\n" + >+ " protected void foo() {}\n" + >+ " }\n" + >+ " interface I1 {}\n" + >+ "}", >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ this.problemRequestor = new ProblemRequestor(); >+ x2 = getWorkingCopy( >+ "/P1/src/p/X2.java", >+ "package p;\n" + >+ "public class X2 extends X1 {\n" + >+ " class C2 {}\n" + >+ " interface I2 {}\n" + >+ "}", >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, >+ new String[] {"JCL_LIB"}, "bin"); >+ IClasspathEntry[] classpath = p2.getRawClasspath(); >+ int length = classpath.length; >+ System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length); >+ classpath[length] = createSourceEntry("P2", "/P1", "-p/X1"); >+ p2.setRawClasspath(classpath, null); >+ // check the most basic case >+ String src = >+ "package p;\n" + >+ "public class Z extends X1 {\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ z = getWorkingCopy( >+ "/P2/src/p/Z.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n----------\n----------\n" + >+ "1. ERROR in /P2/src/p/Z.java (at line 2)\n" + >+ " public class Z extends X1 {\n" + >+ " ^^\n" + >+ "Access restriction: The type X1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ // check the specifics of this test case >+ src = >+ "package p;\n" + >+ "public class Y extends X2 {\n" + >+ " class C3a extends C1 { // error\n" + >+ " C3a() {\n" + >+ " super(0);\n" + >+ " foo(); // error\n" + >+ " }\n" + >+ " }\n" + >+ " class C3c extends C2 implements I2 {}\n" + >+ " void foobar() {\n" + >+ " C1 m1 = // error\n" + >+ " new C1(0); // error\n" + >+ " C2 m2 = new C2();\n" + >+ " }\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ y = getWorkingCopy( >+ "/P2/src/p/Y.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in /P2/src/p/Y.java (at line 3)\n" + >+ " class C3a extends C1 { // error\n" + >+ " ^^\n" + >+ "Access restriction: The type X1.C1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" + >+ "2. ERROR in /P2/src/p/Y.java (at line 5)\n" + >+ " super(0);\n" + >+ " ^^^^^^^^\n" + >+ "Access restriction: The constructor X1.C1(int) is not accessible due to restriction on required project P1\n" + >+ "----------\n" + >+ "3. ERROR in /P2/src/p/Y.java (at line 6)\n" + >+ " foo(); // error\n" + >+ " ^^^^^\n" + >+ "Access restriction: The method foo() from the type X1.C1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" + >+ "4. ERROR in /P2/src/p/Y.java (at line 11)\n" + >+ " C1 m1 = // error\n" + >+ " ^^\n" + >+ "Access restriction: The type X1.C1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" + >+ "5. ERROR in /P2/src/p/Y.java (at line 12)\n" + >+ " new C1(0); // error\n" + >+ " ^^^^^^^^^\n" + >+ "Access restriction: The constructor X1.C1(int) is not accessible due to restriction on required project P1\n" + >+ "----------\n" + >+ "6. ERROR in /P2/src/p/Y.java (at line 12)\n" + >+ " new C1(0); // error\n" + >+ " ^^\n" + >+ "Access restriction: The type X1.C1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ } finally { >+ if (x1 != null) >+ x1.discardWorkingCopy(); >+ if (x2 != null) >+ x2.discardWorkingCopy(); >+ if (y != null) >+ y.discardWorkingCopy(); >+ if (z != null) >+ z.discardWorkingCopy(); >+ deleteProjects(new String[] {"P1", "P2"}); >+ } >+} >+ >+/* >+ * Discouraged access message - type via discouraged rule. >+ */ >+public void test004() throws CoreException { >+ ICompilationUnit x1 = null, z = null; >+ try { >+ WorkingCopyOwner owner = new WorkingCopyOwner(){}; >+ createJavaProject( >+ "P1", >+ new String[] {"src"}, >+ new String[] {"JCL_LIB"}, >+ "bin"); >+ this.problemRequestor = new ProblemRequestor(); >+ x1 = getWorkingCopy( >+ "/P1/src/p/X1.java", >+ "package p;\n" + >+ "public class X1 {\n" + >+ " class C1 {}\n" + >+ " interface I1 {}\n" + >+ "}", >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems", >+ "----------\n----------\n----------\n----------\n" >+ ); >+ IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, >+ new String[] {"JCL_LIB"}, "bin"); >+ IClasspathEntry[] classpath = p2.getRawClasspath(); >+ int length = classpath.length; >+ System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length); >+ classpath[length] = createSourceEntry("P2", "/P1", "~p/X1"); >+ p2.setRawClasspath(classpath, null); >+ String src = >+ "package p;\n" + >+ "public class Z extends X1 {\n" + >+ "}"; >+ this.problemRequestor = new ProblemRequestor(src); >+ z = getWorkingCopy( >+ "/P2/src/p/Z.java", >+ src, >+ owner, >+ this.problemRequestor); >+ assertProblems( >+ "Unexpected problems value", >+ "----------\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. WARNING in /P2/src/p/Z.java (at line 2)\n" + >+ " public class Z extends X1 {\n" + >+ " ^^\n" + >+ "Discouraged access: The type X1 is not accessible due to restriction on required project P1\n" + >+ "----------\n" >+ ); >+ } finally { >+ if (x1 != null) >+ x1.discardWorkingCopy(); >+ if (z != null) >+ z.discardWorkingCopy(); >+ deleteProjects(new String[] {"P1", "P2"}); >+ } >+} >+} >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.126 >diff -u -r1.126 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 5 Dec 2005 19:35:55 -0000 1.126 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 3 Jan 2006 16:13:11 -0000 >@@ -12,6 +12,7 @@ > > import java.io.File; > import java.io.IOException; >+import java.util.HashMap; > import java.util.Hashtable; > import java.util.Map; > >@@ -3704,8 +3705,8 @@ > "----------\n" + > "1. WARNING in Y.java (at line 1)\n" + > " public class Y extends X {\n" + >- " ^\n" + >- "The constructor X() is deprecated\n" + >+ " ^\n" + >+ "The type X is deprecated\n" + > "----------\n" + > "2. WARNING in Y.java (at line 2)\n" + > " void foo(){ super.foo(); }\n" + >@@ -3741,8 +3742,8 @@ > "----------\n" + > "1. WARNING in Y.java (at line 1)\n" + > " public class Y extends X {\n" + >- " ^\n" + >- "The constructor X() is deprecated\n" + >+ " ^\n" + >+ "The type X is deprecated\n" + > "----------\n" + > "2. WARNING in Y.java (at line 2)\n" + > " void foo(){ super.foo(); }\n" + >@@ -3955,8 +3956,8 @@ > "----------\n" + > "1. WARNING in Y.java (at line 1)\n" + > " public class Y extends X {\n" + >- " ^\n" + >- "The constructor X() is deprecated\n" + >+ " ^\n" + >+ "The type X is deprecated\n" + > "----------\n" + > "2. ERROR in Y.java (at line 4)\n" + > " Zork z;\n" + >@@ -4510,8 +4511,94 @@ > " Zork z;\n" + > " ^^^^\n" + > "Zork cannot be resolved to a type\n" + >- "----------\n"); >+ "----------\n", >+ null, >+ true, >+ null); > } >+public void test142b() { >+ Map raiseInvalidJavadocSeverity = >+ new HashMap(2); >+ raiseInvalidJavadocSeverity.put( >+ CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR); >+ // admittingly, when these are errors, SuppressWarnings is not enough to >+ // filter them out *but* the deprecation level being WARNING, we get them >+ // out anyway >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "@SuppressWarnings(\"deprecation\")\n" + >+ "public class X extends p.OldStuff {\n" + >+ " /**\n" + >+ " * @see p.OldStuff#foo()\n" + >+ " */\n" + >+ " @Override\n" + >+ " public void foo() {\n" + >+ " super.foo();\n" + >+ " }\n" + >+ "}\n", >+ "p/OldStuff.java", >+ "package p;\n" + >+ "@Deprecated\n" + >+ "public class OldStuff {\n" + >+ " public void foo() {\n" + >+ " } \n" + >+ " Zork z;\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in p\\OldStuff.java (at line 6)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n", >+ null, >+ true, >+ raiseInvalidJavadocSeverity); >+} >+public void test142c() { >+ Map raiseDeprecationReduceInvalidJavadocSeverity = >+ new HashMap(2); >+ raiseDeprecationReduceInvalidJavadocSeverity.put( >+ CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); >+ raiseDeprecationReduceInvalidJavadocSeverity.put( >+ CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "@SuppressWarnings(\"deprecation\")\n" + >+ "public class X extends p.OldStuff {\n" + >+ " /**\n" + >+ " * @see p.OldStuff#foo()\n" + >+ " */\n" + >+ " @Override\n" + >+ " public void foo() {\n" + >+ " super.foo();\n" + >+ " }\n" + >+ "}\n", >+ "p/OldStuff.java", >+ "package p;\n" + >+ "@Deprecated\n" + >+ "public class OldStuff {\n" + >+ " public void foo() {\n" + >+ " } \n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " public class X extends p.OldStuff {\n" + >+ " ^^^^^^^^^^\n" + >+ "The type OldStuff is deprecated\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " super.foo();\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method foo() from the type OldStuff is deprecated\n" + >+ "----------\n", >+ null, >+ true, >+ raiseDeprecationReduceInvalidJavadocSeverity); >+} > public void _test143() { > this.runNegativeTest( > new String[] { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java,v >retrieving revision 1.17 >diff -u -r1.17 DeprecatedTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java 3 Jun 2005 01:00:16 -0000 1.17 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java 3 Jan 2006 16:13:11 -0000 >@@ -197,11 +197,6 @@ > "----------\n" + > "1. WARNING in A.java (at line 1)\n" + > " public class A extends X.Y {}\n" + >- " ^\n" + >- "The constructor X.Y() is deprecated\n" + >- "----------\n" + >- "2. WARNING in A.java (at line 1)\n" + >- " public class A extends X.Y {}\n" + > " ^^^\n" + > "The type X.Y is deprecated\n" + > "----------\n",// expected output
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 76266
:
22702
|
22703
|
22704
| 32416