### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v
retrieving revision 1.221
diff -u -r1.221 messages.properties
--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 11 Jul 2007 13:40:49 -0000 1.221
+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 26 Jul 2007 12:06:29 -0000
@@ -587,3 +587,18 @@
857 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}>
858 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
859 = The constructor {0}({1}) of raw type {2} is no longer generic; it cannot be parameterized with arguments <{3}>
+
+### ELABORATIONS
+## Access restrictions
+78592 = The type {1} is not accessible due to restriction on classpath entry {0}
+78593 = The type {1} is not accessible due to restriction on required project {0}
+78594 = The type {1} is not accessible due to restriction on required library {0}
+78596 = The field {1} from the type {2} is not accessible due to restriction on classpath entry {0}
+78597 = The field {1} from the type {2} is not accessible due to restriction on required project {0}
+78598 = The field {1} from the type {2} is not accessible due to restriction on required library {0}
+78600 = The constructor {1} is not accessible due to restriction on classpath entry {0}
+78601 = The constructor {1} is not accessible due to restriction on required project {0}
+78602 = The constructor {1} is not accessible due to restriction on required library {0}
+78604 = The method {1} from the type {2} is not accessible due to restriction on classpath entry {0}
+78606 = The method {1} from the type {2} is not accessible due to restriction on required library {0}
+78605 = The method {1} from the type {2} is not accessible due to restriction on required project {0}
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.351
diff -u -r1.351 ProblemReporter.java
--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Jul 2007 14:07:25 -0000 1.351
+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 26 Jul 2007 12:06:29 -0000
@@ -13,7 +13,6 @@
import java.io.CharConversionException;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.text.MessageFormat;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
@@ -33,7 +32,16 @@
public ReferenceContext referenceContext;
private Scanner positionScanner;
-
+ private final static byte
+ // TYPE_ACCESS = 0x0,
+ FIELD_ACCESS = 0x4,
+ CONSTRUCTOR_ACCESS = 0x8,
+ METHOD_ACCESS = 0xC;
+
+private static int getElaborationId (int leadProblemId, byte elaborationVariant) {
+ return leadProblemId << 8 | elaborationVariant; // leadProblemId comes into the higher order bytes
+}
+
public static long getIrritant(int problemID) {
switch(problemID){
@@ -1641,50 +1649,61 @@
typeRef.sourceEnd);
}
public void forbiddenReference(FieldBinding field, ASTNode location,
- String messageTemplate, int problemId) {
+ byte classpathEntryType, String classpathEntryName, int problemId) {
+ int severity = computeSeverity(problemId);
+ if (severity == ProblemSeverities.Ignore) return;
this.handle(
problemId,
new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose
+ getElaborationId(IProblem.ForbiddenReference, (byte) (FIELD_ACCESS | classpathEntryType)),
new String[] {
- MessageFormat.format(messageTemplate,
- new String[]{
- new String(field.shortReadableName()),
- new String(field.declaringClass.shortReadableName())})},
+ classpathEntryName,
+ new String(field.shortReadableName()),
+ new String(field.declaringClass.shortReadableName())},
+ severity,
nodeSourceStart(field, location),
nodeSourceEnd(field, location));
}
public void forbiddenReference(MethodBinding method, ASTNode location,
- String messageTemplate, int problemId) {
+ byte classpathEntryType, String classpathEntryName, int problemId) {
+ int severity = computeSeverity(problemId);
+ if (severity == ProblemSeverities.Ignore) return;
if (method.isConstructor())
this.handle(
problemId,
new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
+ getElaborationId(IProblem.ForbiddenReference, (byte) (CONSTRUCTOR_ACCESS | classpathEntryType)),
new String[] {
- MessageFormat.format(messageTemplate,
- new String[]{new String(method.shortReadableName())})},
+ classpathEntryName,
+ new String(method.shortReadableName())},
+ severity,
location.sourceStart,
location.sourceEnd);
else
this.handle(
problemId,
new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
+ getElaborationId(IProblem.ForbiddenReference, (byte) (METHOD_ACCESS | classpathEntryType)),
new String[] {
- MessageFormat.format(messageTemplate,
- new String[]{
- new String(method.shortReadableName()),
- new String(method.declaringClass.shortReadableName())})},
+ classpathEntryName,
+ new String(method.shortReadableName()),
+ new String(method.declaringClass.shortReadableName())},
+ severity,
location.sourceStart,
location.sourceEnd);
}
-public void forbiddenReference(TypeBinding type, ASTNode location, String messageTemplate, int problemId) {
+public void forbiddenReference(TypeBinding type, ASTNode location,
+ byte classpathEntryType, String classpathEntryName, int problemId) {
if (location == null) return;
int severity = computeSeverity(problemId);
if (severity == ProblemSeverities.Ignore) return;
- // this problem has a message template extracted from the access restriction rule
this.handle(
problemId,
new String[] { new String(type.readableName()) }, // distinct from msg arg for quickfix purpose
- new String[] { MessageFormat.format(messageTemplate, new String[]{ new String(type.shortReadableName())})},
+ getElaborationId(IProblem.ForbiddenReference, /* TYPE_ACCESS | */ classpathEntryType), // TYPE_ACCESS values to 0
+ new String[] {
+ classpathEntryName,
+ new String(type.shortReadableName())},
severity,
location.sourceStart,
location.sourceEnd);
@@ -1768,6 +1787,27 @@
this.handle(
problemId,
problemArguments,
+ 0, // no elaboration
+ messageArguments,
+ severity,
+ problemStartPosition,
+ problemEndPosition);
+}
+// use this private API when the compilation unit result can be found through the
+// reference context. Otherwise, use the other API taking a problem and a compilation result
+// as arguments
+private void handle(
+ int problemId,
+ String[] problemArguments,
+ int elaborationId,
+ String[] messageArguments,
+ int severity,
+ int problemStartPosition,
+ int problemEndPosition){
+ this.handle(
+ problemId,
+ problemArguments,
+ elaborationId,
messageArguments,
severity,
problemStartPosition,
Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java,v
retrieving revision 1.30
diff -u -r1.30 ProblemHandler.java
--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java 27 Apr 2007 15:51:39 -0000 1.30
+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java 26 Jul 2007 12:06:28 -0000
@@ -77,9 +77,33 @@
lineNumber,
columnNumber);
}
+public CategorizedProblem createProblem(
+ char[] fileName,
+ int problemId,
+ String[] problemArguments,
+ int elaborationId,
+ String[] messageArguments,
+ int severity,
+ int problemStartPosition,
+ int problemEndPosition,
+ int lineNumber,
+ int columnNumber) {
+ return this.problemFactory.createProblem(
+ fileName,
+ problemId,
+ problemArguments,
+ elaborationId,
+ messageArguments,
+ severity,
+ problemStartPosition,
+ problemEndPosition,
+ lineNumber,
+ columnNumber);
+}
public void handle(
int problemId,
- String[] problemArguments,
+ String[] problemArguments,
+ int elaborationId,
String[] messageArguments,
int severity,
int problemStartPosition,
@@ -93,7 +117,7 @@
// if no reference context, we need to abort from the current compilation process
if (referenceContext == null) {
if ((severity & ProblemSeverities.Error) != 0) { // non reportable error is fatal
- CategorizedProblem problem = this.createProblem(null, problemId, problemArguments, messageArguments, severity, 0, 0, 0, 0);
+ CategorizedProblem problem = this.createProblem(null, problemId, problemArguments, elaborationId, messageArguments, severity, 0, 0, 0, 0);
throw new AbortCompilation(null, problem);
} else {
return; // ignore non reportable warning
@@ -112,6 +136,7 @@
unitResult.getFileName(),
problemId,
problemArguments,
+ elaborationId,
messageArguments,
severity,
problemStartPosition,
@@ -144,7 +169,7 @@
*/
public void handle(
int problemId,
- String[] problemArguments,
+ String[] problemArguments,
String[] messageArguments,
int problemStartPosition,
int problemEndPosition,
@@ -154,6 +179,7 @@
this.handle(
problemId,
problemArguments,
+ 0, // no message elaboration
messageArguments,
this.computeSeverity(problemId), // severity inferred using the ID
problemStartPosition,
Index: compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java,v
retrieving revision 1.44
diff -u -r1.44 DefaultProblemFactory.java
--- compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java 6 Mar 2007 02:38:51 -0000 1.44
+++ compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java 26 Jul 2007 12:06:27 -0000
@@ -82,6 +82,28 @@
lineNumber,
columnNumber);
}
+public CategorizedProblem createProblem(
+ char[] originatingFileName,
+ int problemId,
+ String[] problemArguments,
+ int elaborationId,
+ String[] messageArguments,
+ int severity,
+ int startPosition,
+ int endPosition,
+ int lineNumber,
+ int columnNumber) {
+ return new DefaultProblem(
+ originatingFileName,
+ this.getLocalizedMessage(problemId, elaborationId, messageArguments),
+ problemId,
+ problemArguments,
+ severity,
+ startPosition,
+ endPosition,
+ lineNumber,
+ columnNumber);
+}
private final static int keyFromID(int id) {
return id + 1; // keys are offsetted by one in table, since it cannot handle 0 key
}
@@ -104,15 +126,24 @@
this.messageTemplates = loadMessageTemplates(locale);
}
}
-
public final String getLocalizedMessage(int id, String[] problemArguments) {
- String message = (String) this.messageTemplates.get(keyFromID(id & IProblem.IgnoreCategoriesMask));
+ return getLocalizedMessage(id, 0, problemArguments);
+}
+public final String getLocalizedMessage(int id, int elaborationId, String[] problemArguments) {
+ String message = (String) this.messageTemplates.get(keyFromID(id & IProblem.IgnoreCategoriesMask));
if (message == null) {
return "Unable to retrieve the error message for problem id: " //$NON-NLS-1$
- + (id & IProblem.IgnoreCategoriesMask)
- + ". Check compiler resources."; //$NON-NLS-1$
+ + (id & IProblem.IgnoreCategoriesMask) + ". Check compiler resources."; //$NON-NLS-1$
}
-
+ if (elaborationId != 0) {
+ String elaboration = (String) this.messageTemplates.get(keyFromID(elaborationId));
+ if (elaboration == null) {
+ return "Unable to retrieve the error message elaboration for elaboration id: " //$NON-NLS-1$
+ + elaborationId + ". Check compiler resources."; //$NON-NLS-1$
+ }
+ message = message.replaceAll("\\{0\\}", elaboration); //$NON-NLS-1$
+ }
+
// for compatibility with MessageFormat which eliminates double quotes in original message
char[] messageWithNoDoubleQuotes =
CharOperation.replace(message.toCharArray(), DOUBLE_QUOTES, SINGLE_QUOTE);
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.61
diff -u -r1.61 State.java
--- model/org/eclipse/jdt/internal/core/builder/State.java 22 May 2007 18:25:46 -0000 1.61
+++ model/org/eclipse/jdt/internal/core/builder/State.java 26 Jul 2007 12:06:29 -0000
@@ -44,7 +44,7 @@
private StringSet structurallyChangedTypes;
public static int MaxStructurallyChangedTypes = 100; // keep track of ? structurally changed types, otherwise consider all to be changed
-public static final byte VERSION = 0x0015; // changed access rule presentation
+public static final byte VERSION = 0x0016; // changed access rules sets storage
static final byte SOURCE_FOLDER = 1;
static final byte BINARY_FOLDER = 2;
@@ -342,12 +342,7 @@
accessRules[i] = new ClasspathAccessRule(pattern, problemId);
}
JavaModelManager manager = JavaModelManager.getJavaModelManager();
- String[] messageTemplates = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
- for (int i = 0; i < AccessRuleSet.MESSAGE_TEMPLATES_LENGTH; i++) {
- messageTemplates[i] = manager.intern(in.readUTF());
- }
- AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules, messageTemplates);
- return accessRuleSet;
+ return new AccessRuleSet(accessRules, in.readByte(), manager.intern(in.readUTF()));
}
void tagAsNoopBuild() {
@@ -639,8 +634,8 @@
writeName(accessRule.pattern, out);
out.writeInt(accessRule.problemId);
}
- for (int i = 0; i < AccessRuleSet.MESSAGE_TEMPLATES_LENGTH; i++)
- out.writeUTF(accessRuleSet.messageTemplates[i]);
+ out.writeByte(accessRuleSet.classpathEntryType);
+ out.writeUTF(accessRuleSet.classpathEntryName);
}
}
}
Index: search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java,v
retrieving revision 1.58
diff -u -r1.58 JavaSearchScope.java
--- search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java 12 Jul 2007 10:33:09 -0000 1.58
+++ search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java 26 Jul 2007 12:06:29 -0000
@@ -58,7 +58,7 @@
private int threshold;
private IPath[] enclosingProjectsAndJars;
- public final static AccessRuleSet NOT_ENCLOSED = new AccessRuleSet(null, null);
+ public final static AccessRuleSet NOT_ENCLOSED = new AccessRuleSet(null, (byte) 0, null);
public JavaSearchScope() {
this(5);
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.305
diff -u -r1.305 Main.java
--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 5 Jul 2007 14:43:22 -0000 1.305
+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 26 Jul 2007 12:06:26 -0000
@@ -54,6 +54,7 @@
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.AccessRule;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
@@ -1404,63 +1405,50 @@
AccessRuleSet accessRuleSet = null;
if (rulesSpecsSize != 0) {
AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
- boolean rulesOK = true;
- Iterator i = currentRuleSpecs.iterator();
- int j = 0;
- while (i.hasNext()) {
- String ruleSpec = (String) i.next();
- char key = ruleSpec.charAt(0);
- String pattern = ruleSpec.substring(1);
- if (pattern.length() > 0) {
- switch (key) {
- case '+':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(), 0);
- break;
- case '~':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(),
- IProblem.DiscouragedReference);
- break;
- case '-':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(),
- IProblem.ForbiddenReference);
- break;
- case '?':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(),
- IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
- break;
- default:
- rulesOK = false;
- }
- } else {
- rulesOK = false;
- }
- }
- if (rulesOK) {
- String templates[] = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
- templates[0] = this.bind(
- "template.restrictedAccess.type", //$NON-NLS-1$
- new String[] {"{0}", currentClasspathName}); //$NON-NLS-1$
- templates[1] = this.bind(
- "template.restrictedAccess.constructor", //$NON-NLS-1$
- new String[] {"{0}", currentClasspathName}); //$NON-NLS-1$
- templates[2] = this.bind(
- "template.restrictedAccess.method", //$NON-NLS-1$
- new String[] {"{0}", "{1}", currentClasspathName}); //$NON-NLS-1$ //$NON-NLS-2$
- templates[3] = this.bind(
- "template.restrictedAccess.field", //$NON-NLS-1$
- new String[] {"{0}", "{1}", currentClasspathName}); //$NON-NLS-1$ //$NON-NLS-2$
- accessRuleSet = new AccessRuleSet(accessRules, templates);
- } else {
- if (currentClasspathName.length() != 0) {
- // we go on anyway
- this.logger.logIncorrectClasspath(currentClasspathName);
- }
- return;
- }
+ boolean rulesOK = true;
+ Iterator i = currentRuleSpecs.iterator();
+ int j = 0;
+ while (i.hasNext()) {
+ String ruleSpec = (String) i.next();
+ char key = ruleSpec.charAt(0);
+ String pattern = ruleSpec.substring(1);
+ if (pattern.length() > 0) {
+ switch (key) {
+ case '+':
+ accessRules[j++] = new AccessRule(pattern
+ .toCharArray(), 0);
+ break;
+ case '~':
+ accessRules[j++] = new AccessRule(pattern
+ .toCharArray(),
+ IProblem.DiscouragedReference);
+ break;
+ case '-':
+ accessRules[j++] = new AccessRule(pattern
+ .toCharArray(),
+ IProblem.ForbiddenReference);
+ break;
+ case '?':
+ accessRules[j++] = new AccessRule(pattern
+ .toCharArray(),
+ IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
+ break;
+ default:
+ rulesOK = false;
+ }
+ } else {
+ rulesOK = false;
+ }
+ }
+ if (rulesOK) {
+ accessRuleSet = new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
+ } else {
+ if (currentClasspathName.length() != 0) {
+ // we go on anyway
+ this.logger.logIncorrectClasspath(currentClasspathName);
+ }
+ return;
+ }
}
if (NONE.equals(destPath)) {
destPath = NONE; // keep == comparison valid
Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v
retrieving revision 1.650
diff -u -r1.650 messages.properties
--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 24 Jul 2007 14:32:11 -0000 1.650
+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 26 Jul 2007 12:06:26 -0000
@@ -286,10 +286,3 @@
\ \n\
\ Advanced options:\n\
\ -? -help print the help message\n\
-
-# templates
-### access restrictions
-template.restrictedAccess.type = The type {0} is not accessible due to restriction on classpath entry {1}
-template.restrictedAccess.constructor = The constructor {0} is not accessible due to restriction on classpath entry {1}
-template.restrictedAccess.field = The field {0} from the type {1} is not accessible due to restriction on classpath entry {2}
-template.restrictedAccess.method = The method {0} from the type {1} is not accessible due to restriction on classpath entry {2}
Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v
retrieving revision 1.340
diff -u -r1.340 CompletionEngine.java
--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 11 Jul 2007 08:54:44 -0000 1.340
+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 26 Jul 2007 12:06:27 -0000
@@ -83,27 +83,8 @@
super(loc);
}
- public CategorizedProblem createProblem(
- char[] originatingFileName,
- int problemId,
- String[] problemArguments,
- String[] messageArguments,
- int severity,
- int start,
- int end,
- int lineNumber,
- int columnNumber) {
-
- CategorizedProblem pb = super.createProblem(
- originatingFileName,
- problemId,
- problemArguments,
- messageArguments,
- severity,
- start,
- end,
- lineNumber,
- columnNumber);
+ private CategorizedProblem checkProblem(CategorizedProblem pb,
+ char[] originatingFileName, int severity, int start) {
int id = pb.getID();
if (CompletionEngine.this.actualCompletionPosition > start
&& this.lastErrorStart < start
@@ -146,6 +127,54 @@
return pb;
}
+ public CategorizedProblem createProblem(
+ char[] originatingFileName,
+ int problemId,
+ String[] problemArguments,
+ String[] messageArguments,
+ int severity,
+ int start,
+ int end,
+ int lineNumber,
+ int columnNumber) {
+ return checkProblem(
+ super.createProblem(
+ originatingFileName,
+ problemId,
+ problemArguments,
+ messageArguments,
+ severity,
+ start,
+ end,
+ lineNumber,
+ columnNumber), originatingFileName, severity, start);
+ }
+
+ public CategorizedProblem createProblem(
+ char[] originatingFileName,
+ int problemId,
+ String[] problemArguments,
+ int elaborationId,
+ String[] messageArguments,
+ int severity,
+ int start,
+ int end,
+ int lineNumber,
+ int columnNumber) {
+ return checkProblem(
+ super.createProblem(
+ originatingFileName,
+ problemId,
+ problemArguments,
+ elaborationId,
+ messageArguments,
+ severity,
+ start,
+ end,
+ lineNumber,
+ columnNumber), originatingFileName, severity, start);
+ }
+
public void startCheckingProblems() {
this.checkProblems = true;
this.hasForbiddenProblems = false;
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.65
diff -u -r1.65 messages.properties
--- model/org/eclipse/jdt/internal/core/util/messages.properties 7 Mar 2007 16:09:14 -0000 1.65
+++ model/org/eclipse/jdt/internal/core/util/messages.properties 26 Jul 2007 12:06:29 -0000
@@ -186,16 +186,6 @@
javamodel_building_after_upgrade=Triggering build after upgrade
javamodel_refreshing_external_jars=Refreshing external archives
-### 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
convention_unit_notJavaName = Compilation unit name must end with .java, or one of the registered Java-like extensions
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.14
diff -u -r1.14 AccessRestriction.java
--- compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java 28 Mar 2006 20:31:59 -0000 1.14
+++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java 26 Jul 2007 12:06:27 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -13,33 +13,19 @@
public class AccessRestriction {
private AccessRule accessRule;
- private String[] messageTemplates;
- public AccessRestriction(AccessRule accessRule, String [] messageTemplates) {
- this.accessRule = accessRule;
- this.messageTemplates = messageTemplates;
- }
+ public byte classpathEntryType;
+ public static final byte
+ COMMAND_LINE = 0,
+ PROJECT = 1,
+ LIBRARY = 2;
+ public String classpathEntryName;
- /**
- * Returns readable description for problem reporting,
- * message is expected to contain room for restricted type name
- * e.g. "{0} has restricted access"
- */
- public String getMessageTemplate() {
- return this.messageTemplates[0];
+ public AccessRestriction(AccessRule accessRule, byte classpathEntryType, String classpathEntryName) {
+ this.accessRule = accessRule;
+ this.classpathEntryName = classpathEntryName;
+ this.classpathEntryType = classpathEntryType;
}
- 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.getProblemId();
}
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.12
diff -u -r1.12 AccessRuleSet.java
--- compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 28 Mar 2006 20:31:59 -0000 1.12
+++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 26 Jul 2007 12:06:27 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -19,26 +19,23 @@
public class AccessRuleSet {
private AccessRule[] accessRules;
- public String[] messageTemplates;
- public static final int MESSAGE_TEMPLATES_LENGTH = 4;
-
- /**
- * 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); replaced by a
- * default value if null.
- */
- public AccessRuleSet(AccessRule[] accessRules, String[] messageTemplates) {
- this.accessRules = accessRules;
- 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$
- }
+ public byte classpathEntryType; // one of AccessRestriction#COMMAND_LINE, LIBRARY, PROJECT
+ public String classpathEntryName;
+/**
+ * Make a new set of access rules.
+ * @param accessRules the access rules to be contained by the new set
+ * @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
+ * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT}
+ * that tells the access restrictions how to render the classpath entry
+ * @param classpathEntryName a user-readable name for the classpath entry
+ */
+public AccessRuleSet(AccessRule[] accessRules, byte classpathEntryType, String classpathEntryName) {
+ this.accessRules = accessRules;
+ this.classpathEntryType = classpathEntryType;
+ this.classpathEntryName = classpathEntryName;
+}
+
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@@ -48,12 +45,11 @@
if (!(object instanceof AccessRuleSet))
return false;
AccessRuleSet otherRuleSet = (AccessRuleSet) object;
- 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;
+ if (this.classpathEntryType != otherRuleSet.classpathEntryType ||
+ this.classpathEntryName == null && otherRuleSet.classpathEntryName != null ||
+ ! this.classpathEntryName.equals(otherRuleSet.classpathEntryName)) {
+ return false;
+ }
int rulesLength = this.accessRules.length;
if (rulesLength != otherRuleSet.accessRules.length) return false;
for (int i = 0; i < rulesLength; i++)
@@ -81,7 +77,7 @@
switch (accessRule.getProblemId()) {
case IProblem.ForbiddenReference:
case IProblem.DiscouragedReference:
- return new AccessRestriction(accessRule, this.messageTemplates);
+ return new AccessRestriction(accessRule, this.classpathEntryType, this.classpathEntryName);
default:
return null;
}
@@ -109,10 +105,9 @@
else if (i < length-1)
buffer.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$
+ buffer.append("} [classpath entry: "); //$NON-NLS-1$
+ buffer.append(this.classpathEntryName);
+ buffer.append("]"); //$NON-NLS-1$
return buffer.toString();
}
}
Index: compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java,v
retrieving revision 1.15
diff -u -r1.15 IProblemFactory.java
--- compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java 28 Sep 2006 14:14:29 -0000 1.15
+++ compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java 26 Jul 2007 12:06:27 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -24,11 +24,35 @@
*/
public interface IProblemFactory {
+ CategorizedProblem createProblem(
+ char[] originatingFileName,
+ int problemId,
+ String[] problemArguments,
+ String[] messageArguments, // shorter versions of the problemArguments
+ int severity,
+ int startPosition,
+ int endPosition,
+ int lineNumber,
+ int columnNumber);
+ /**
+ * Answer a new IProblem created according to the parameters values.
+ * @param originatingFileName the name of the file from which the problem is originated
+ * @param problemId the problem id
+ * @param problemArguments the fully qualified arguments recorded inside the problem
+ * @param elaborationId the message elaboration id (0 for problems that have no message elaboration)
+ * @param messageArguments the arguments needed to set the error message (shorter names than problemArguments ones)
+ * @param severity the severity of the problem
+ * @param startPosition the start position of the problem
+ * @param endPosition the end position of the problem
+ * @param lineNumber the line on which the problem occurred
+ * @return a new IProblem created according to the parameters values.
+ */
CategorizedProblem createProblem(
char[] originatingFileName,
int problemId,
String[] problemArguments,
+ int elaborationId,
String[] messageArguments, // shorter versions of the problemArguments
int severity,
int startPosition,
@@ -39,4 +63,22 @@
Locale getLocale();
String getLocalizedMessage(int problemId, String[] messageArguments);
+
+ /**
+ * Inject the supplied message arguments into a localized template
+ * elaborated from the supplied problem id and an optional elaboration id
+ * and return the resulting message. The arguments number should match the
+ * highest placeholder index in the template. When an elaboration id is
+ * used, the template matching that elaboration id replaces '{0}' into the
+ * template matching the problem id before the message arguments are
+ * injected.
+ * @param problemId the problem id taken from
+ * {@link org.eclipse.jdt.core.compiler.IProblem} constants
+ * @param elaborationId 0 if the considered problem has no elaboration, a
+ * valid elaboration id else
+ * @param messageArguments the arguments to inject into the template
+ * @return a localized message elaborated from the supplied problem id,
+ * elaboration id and message parameters
+ */
+ String getLocalizedMessage(int problemId, int elaborationId, String[] messageArguments);
}
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.84
diff -u -r1.84 ASTNode.java
--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 22 Jun 2007 15:50:14 -0000 1.84
+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 26 Jul 2007 12:06:27 -0000
@@ -348,7 +348,8 @@
scope.environment().getAccessRestriction(field.declaringClass.erasure());
if (restriction != null) {
scope.problemReporter().forbiddenReference(field, this,
- restriction.getFieldAccessMessageTemplate(), restriction.getProblemId());
+ restriction.classpathEntryType, restriction.classpathEntryName,
+ restriction.getProblemId());
}
}
@@ -385,16 +386,9 @@
AccessRestriction restriction =
scope.environment().getAccessRestriction(method.declaringClass.erasure());
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());
- }
+ scope.problemReporter().forbiddenReference(method, this,
+ restriction.classpathEntryType, restriction.classpathEntryName,
+ restriction.getProblemId());
}
}
@@ -444,7 +438,8 @@
if (refType.hasRestrictedAccess()) {
AccessRestriction restriction = scope.environment().getAccessRestriction(type.erasure());
if (restriction != null) {
- scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId());
+ scope.problemReporter().forbiddenReference(type, this, restriction.classpathEntryType,
+ restriction.classpathEntryName, restriction.getProblemId());
}
}
Index: model/org/eclipse/jdt/internal/core/CancelableProblemFactory.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CancelableProblemFactory.java,v
retrieving revision 1.5
diff -u -r1.5 CancelableProblemFactory.java
--- model/org/eclipse/jdt/internal/core/CancelableProblemFactory.java 28 Sep 2006 14:14:30 -0000 1.5
+++ model/org/eclipse/jdt/internal/core/CancelableProblemFactory.java 26 Jul 2007 12:06:29 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 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
@@ -30,4 +30,10 @@
throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
return super.createProblem(originatingFileName, problemId, problemArguments, messageArguments, severity, startPosition, endPosition, lineNumber, columnNumber);
}
+
+ public CategorizedProblem createProblem(char[] originatingFileName, int problemId, String[] problemArguments, int elaborationId, String[] messageArguments, int severity, int startPosition, int endPosition, int lineNumber, int columnNumber) {
+ if (this.monitor != null && this.monitor.isCanceled())
+ throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
+ return super.createProblem(originatingFileName, problemId, problemArguments, elaborationId, messageArguments, severity, startPosition, endPosition, lineNumber, columnNumber);
+ }
}
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.97
diff -u -r1.97 ClasspathEntry.java
--- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 12 Mar 2007 16:14:15 -0000 1.97
+++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 26 Jul 2007 12:06:29 -0000
@@ -40,6 +40,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.env.AccessRule;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -224,7 +225,22 @@
if (accessRules != null && (length = accessRules.length) > 0) {
AccessRule[] rules = new AccessRule[length];
System.arraycopy(accessRules, 0, rules, 0, length);
- this.accessRuleSet = new AccessRuleSet(rules, getMessageTemplates());
+ byte classpathEntryType;
+ String classpathEntryName;
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling
+ classpathEntryType = AccessRestriction.PROJECT;
+ classpathEntryName = manager.intern(getPath().segment(0));
+ } else {
+ classpathEntryType = AccessRestriction.LIBRARY;
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, false);
+ if (target instanceof java.io.File) {
+ classpathEntryName = manager.intern(path.toOSString());
+ } else {
+ classpathEntryName = manager.intern(path.makeRelative().toString());
+ }
+ }
+ this.accessRuleSet = new AccessRuleSet(rules, classpathEntryType, classpathEntryName);
}
// else { -- implicit!
// this.accessRuleSet = null;
@@ -951,46 +967,6 @@
return this.extraAttributes;
}
- private String[] getMessageTemplates() {
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
- String [] result = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
- if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling
- result[0] = manager.intern(Messages.bind(
- org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_project,
- new String[] {"{0}", getPath().segment(0)})); //$NON-NLS-1$
- result[1] = manager.intern(Messages.bind(
- org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_project,
- new String[] {"{0}", getPath().segment(0)})); //$NON-NLS-1$
- result[2] = manager.intern(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] = manager.intern(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);
- String pathString;
- if (target instanceof java.io.File)
- pathString = libPath.toOSString();
- else
- pathString = libPath.makeRelative().toString();
- result[0] = manager.intern(Messages.bind(
- org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_library,
- new String[] {"{0}", pathString})); //$NON-NLS-1$
- result[1] = manager.intern(Messages.bind(
- org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_library,
- new String[] {"{0}", pathString})); //$NON-NLS-1$
- result[2] = manager.intern(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] = manager.intern(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;
- }
-
/**
* @see IClasspathEntry#getExclusionPatterns()
*/
#P org.eclipse.jdt.core.tests.compiler
Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v
retrieving revision 1.116
diff -u -r1.116 BatchCompilerTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 9 Jul 2007 15:28:31 -0000 1.116
+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 26 Jul 2007 12:06:36 -0000
@@ -5297,6 +5297,69 @@
checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
}
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122885
+// coverage test
+public void test145_access_restrictions(){
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "/** */\n" +
+ "public class X {\n" +
+ " KO ko;\n" +
+ " void foo() {\n" +
+ " ko = new KO();\n" +
+ " ko.bar();\n" +
+ " if (ko.m) {}\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}",
+ "KO.java",
+ "/** */\n" +
+ "public class KO {\n" +
+ " void bar() {};\n" +
+ " boolean m;\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals"
+ + " -cp \"" + OUTPUT_DIR + "[-KO]\""
+ + " -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal"
+ + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
+ " KO ko;\n" +
+ " ^^\n" +
+ "Access restriction: The type KO is not accessible due to restriction on classpath entry ---OUTPUT_DIR_PLACEHOLDER---\n" +
+ "----------\n" +
+ "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " ko = new KO();\n" +
+ " ^^^^^^^^\n" +
+ "Access restriction: The constructor KO() is not accessible due to restriction on classpath entry ---OUTPUT_DIR_PLACEHOLDER---\n" +
+ "----------\n" +
+ "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
+ " ko = new KO();\n" +
+ " ^^\n" +
+ "Access restriction: The type KO is not accessible due to restriction on classpath entry ---OUTPUT_DIR_PLACEHOLDER---\n" +
+ "----------\n" +
+ "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
+ " ko.bar();\n" +
+ " ^^^^^^^^\n" +
+ "Access restriction: The method bar() from the type KO is not accessible due to restriction on classpath entry ---OUTPUT_DIR_PLACEHOLDER---\n" +
+ "----------\n" +
+ "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" +
+ " if (ko.m) {}\n" +
+ " ^\n" +
+ "Access restriction: The field m from the type KO is not accessible due to restriction on classpath entry ---OUTPUT_DIR_PLACEHOLDER---\n" +
+ "----------\n" +
+ "6. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 9)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n" +
+ "6 problems (1 error, 5 warnings)",
+ true);
+}
public static Class testClass() {
return BatchCompilerTest.class;
}
#P org.eclipse.jdt.core.tests.model
Index: src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java,v
retrieving revision 1.10
diff -u -r1.10 AccessRestrictionsTests.java
--- src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java 14 Mar 2007 08:18:40 -0000 1.10
+++ src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java 26 Jul 2007 12:06:39 -0000
@@ -50,7 +50,17 @@
public static Test suite() {
return buildModelTestSuite(AccessRestrictionsTests.class);
}
+
+public void setUpSuite() throws Exception {
+ super.setUpSuite();
+ setUpJavaProject("AccessRestrictions");
+}
+public void tearDownSuite() throws Exception {
+ deleteProject("AccessRestrictions");
+ super.tearDownSuite();
+}
+
protected void assertProblems(String message, String expected) {
assertProblems(message, expected, this.problemRequestor);
}
@@ -1009,4 +1019,73 @@
}
}
+/*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=122885
+ * Checking library messages.
+ */
+public void test011() throws CoreException {
+ ICompilationUnit y = null;
+ try {
+ createJavaProject(
+ "P1",
+ new String[] {"src"},
+ new String[] {"JCL_LIB", "/AccessRestrictions/lib.jar"},
+ new String[][]{{}, {}},
+ new String[][]{{}, {"**/*"}},
+ null/*no project*/,
+ null/*no inclusion pattern*/,
+ null/*no exclusion pattern*/,
+ null/*no exported project*/,
+ "bin",
+ null/*no source outputs*/,
+ null/*no inclusion pattern*/,
+ null/*no exclusion pattern*/,
+ "1.4");
+ this.problemRequestor = new ProblemRequestor();
+ y = getWorkingCopy(
+ "/P1/src/q/Y.java",
+ "package q;\n" +
+ "public class Y {\n" +
+ " void foo() {\n" +
+ " p.X x = new p.X();\n" +
+ " x.foo();\n" +
+ " if (x.m > 0) {}\n" +
+ " }\n" +
+ "}"
+ );
+ assertProblems(
+ "Unexpected problems",
+ "----------\n" +
+ "1. ERROR in /P1/src/q/Y.java (at line 4)\n" +
+ " p.X x = new p.X();\n" +
+ " ^^^\n" +
+ "Access restriction: The type X is not accessible due to restriction on required library AccessRestrictions/lib.jar\n" +
+ "----------\n" +
+ "2. ERROR in /P1/src/q/Y.java (at line 4)\n" +
+ " p.X x = new p.X();\n" +
+ " ^^^^^^^^^\n" +
+ "Access restriction: The constructor X() is not accessible due to restriction on required library AccessRestrictions/lib.jar\n" +
+ "----------\n" +
+ "3. ERROR in /P1/src/q/Y.java (at line 4)\n" +
+ " p.X x = new p.X();\n" +
+ " ^^^\n" +
+ "Access restriction: The type X is not accessible due to restriction on required library AccessRestrictions/lib.jar\n" +
+ "----------\n" +
+ "4. ERROR in /P1/src/q/Y.java (at line 5)\n" +
+ " x.foo();\n" +
+ " ^^^^^^^\n" +
+ "Access restriction: The method foo() from the type X is not accessible due to restriction on required library AccessRestrictions/lib.jar\n" +
+ "----------\n" +
+ "5. ERROR in /P1/src/q/Y.java (at line 6)\n" +
+ " if (x.m > 0) {}\n" +
+ " ^\n" +
+ "Access restriction: The field m from the type X is not accessible due to restriction on required library AccessRestrictions/lib.jar\n" +
+ "----------\n"
+ );
+ } finally {
+ if (y != null)
+ y.discardWorkingCopy();
+ deleteProject("P1");
+ }
+}
}
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.185
diff -u -r1.185 AbstractJavaModelTests.java
--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 27 Mar 2007 14:28:56 -0000 1.185
+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 26 Jul 2007 12:06:38 -0000
@@ -1130,7 +1130,10 @@
entries[sourceLength+i] = JavaCore.newVariableEntry(
new Path(new String(vars[0])),
vars.length > 1 ? new Path(new String(vars[1])) : null,
- vars.length > 2 ? new Path(new String(vars[2])) : null);
+ vars.length > 2 ? new Path(new String(vars[2])) : null,
+ ClasspathEntry.getAccessRules(accessibleFiles, nonAccessibleFiles), // ClasspathEntry.NO_ACCESS_RULES,
+ ClasspathEntry.NO_EXTRA_ATTRIBUTES,
+ false);
} else if (lib.startsWith("org.eclipse.jdt.core.tests.model.")) { // container
entries[sourceLength+i] = JavaCore.newContainerEntry(
new Path(lib),
Index: workspace/AccessRestrictions/.classpath
===================================================================
RCS file: workspace/AccessRestrictions/.classpath
diff -N workspace/AccessRestrictions/.classpath
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/AccessRestrictions/.classpath 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,6 @@
+
+
+
+
+
+
Index: workspace/AccessRestrictions/.settings/org.eclipse.jdt.core.prefs
===================================================================
RCS file: workspace/AccessRestrictions/.settings/org.eclipse.jdt.core.prefs
diff -N workspace/AccessRestrictions/.settings/org.eclipse.jdt.core.prefs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/AccessRestrictions/.settings/org.eclipse.jdt.core.prefs 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,12 @@
+#Tue Apr 24 16:48:41 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
Index: workspace/AccessRestrictions/.project
===================================================================
RCS file: workspace/AccessRestrictions/.project
diff -N workspace/AccessRestrictions/.project
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/AccessRestrictions/.project 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,17 @@
+
+
+ AccessRestrictions
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+