Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2005-04-03 04:28:20 -0400
committerPhilipe Mulet2005-04-03 04:28:20 -0400
commit46120337654a09db60dbf563fdeee34bd3985a0d (patch)
treea06e818d14a5f4f25a81ef2df168625ebaf7be78
parent1f456d708b37ea99866e1891a042f96a047120d9 (diff)
downloadeclipse.jdt.core-46120337654a09db60dbf563fdeee34bd3985a0d.tar.gz
eclipse.jdt.core-46120337654a09db60dbf563fdeee34bd3985a0d.tar.xz
eclipse.jdt.core-46120337654a09db60dbf563fdeee34bd3985a0d.zip
36397
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java30
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java21
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java140
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java72
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java13
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java2
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java4
15 files changed, 216 insertions, 153 deletions
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 394395f93d..1cd25e729b 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -35,6 +35,26 @@
</tr>
</table>
+<a name="v_455_R30x"></a>
+<p><hr><h1>
+Eclipse Platform Build Notes&nbsp;<br>
+Java Development Tooling Core</h1>
+Eclipse SDK 3.0.3 Build - 3rd April 2005 - 3.0.3 RELEASE (R3_0_3)
+<br>Project org.eclipse.jdt.core v_454_R30x
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_455_R30x">cvs</a>).
+<h2>
+What's new in this drop</h2>
+<ul>
+<!--
+<li> Plugin version ID got incremented to 3.0.2.</li>
+-->
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=36397">36397</a>
+Compiling source which indirectly references unavailable classes
+
+
<a name="v_454_R30x"></a>
<p><hr><h1>
Eclipse Platform Build Notes&nbsp;<br>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
index b7170475ad..a4d0898798 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
@@ -150,6 +150,8 @@ public class ArrayInitializer extends Expression {
return null;
// Compile-time conversion required?
+ if (expectedElementsTb != expressionTb) // must call before computeConversion() and typeMismatchError()
+ scope.compilationUnitScope().recordTypeConversion(expectedElementsTb, expressionTb);
if (expression.isConstantValueOfTypeAssignableToType(expressionTb, expectedElementsTb)) {
expression.implicitWidening(expectedElementsTb, expressionTb);
} else if (BaseTypeBinding.isWidening(expectedElementsTb.id, expressionTb.id)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
index 5b86adec80..c39cb0801c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
@@ -122,7 +122,7 @@ public class Assignment extends Expression {
scope.problemReporter().expressionShouldBeAVariable(this.lhs);
return null;
}
- this.resolvedType = lhs.resolveType(scope); // expressionType contains the assignment type (lhs Type)
+ TypeBinding lhsType = this.resolvedType = lhs.resolveType(scope); // expressionType contains the assignment type (lhs Type)
TypeBinding rhsType = expression.resolveType(scope);
if (this.resolvedType == null || rhsType == null) {
return null;
@@ -130,18 +130,20 @@ public class Assignment extends Expression {
checkAssignmentEffect(scope);
// Compile-time conversion of base-types : implicit narrowing integer into byte/short/character
- // may require to widen the rhs expression at runtime
- if ((expression.isConstantValueOfTypeAssignableToType(rhsType, this.resolvedType)
- || (this.resolvedType.isBaseType() && BaseTypeBinding.isWidening(this.resolvedType.id, rhsType.id)))
- || rhsType.isCompatibleWith(this.resolvedType)) {
- expression.implicitWidening(this.resolvedType, rhsType);
+ // may require to widen the rhs expression at runtime
+ if (lhsType != rhsType) // must call before computeConversion() and typeMismatchError()
+ scope.compilationUnitScope().recordTypeConversion(lhsType, rhsType);
+ if ((expression.isConstantValueOfTypeAssignableToType(rhsType, lhsType)
+ || (lhsType.isBaseType() && BaseTypeBinding.isWidening(lhsType.id, rhsType.id)))
+ || rhsType.isCompatibleWith(lhsType)) {
+ expression.implicitWidening(lhsType, rhsType);
return this.resolvedType;
}
scope.problemReporter().typeMismatchErrorActualTypeExpectedType(
expression,
rhsType,
- this.resolvedType);
- return this.resolvedType;
+ lhsType);
+ return lhsType;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveTypeExpecting(org.eclipse.jdt.internal.compiler.lookup.BlockScope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
index 7f001c35a2..95c54a6a14 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
@@ -190,27 +190,29 @@ public class FieldDeclaration extends AbstractVariableDeclaration {
// break dead-lock cycles by forcing constant to NotAConstant
this.binding.constant = Constant.NotAConstant;
- TypeBinding typeBinding = this.binding.type;
- TypeBinding initializationTypeBinding;
+ TypeBinding fieldType = this.binding.type;
+ TypeBinding initializationType;
if (this.initialization instanceof ArrayInitializer) {
- if ((initializationTypeBinding = this.initialization.resolveTypeExpecting(initializationScope, typeBinding)) != null) {
- ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationTypeBinding;
- this.initialization.implicitWidening(typeBinding, initializationTypeBinding);
+ if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) {
+ ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType;
+ this.initialization.implicitWidening(fieldType, initializationType);
}
- } else if ((initializationTypeBinding = this.initialization.resolveType(initializationScope)) != null) {
+ } else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) {
- if (this.initialization.isConstantValueOfTypeAssignableToType(initializationTypeBinding, typeBinding)
- || (typeBinding.isBaseType() && BaseTypeBinding.isWidening(typeBinding.id, initializationTypeBinding.id))) {
+ if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError()
+ initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType);
+ if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType)
+ || (fieldType.isBaseType() && BaseTypeBinding.isWidening(fieldType.id, initializationType.id))) {
- this.initialization.implicitWidening(typeBinding, initializationTypeBinding);
+ this.initialization.implicitWidening(fieldType, initializationType);
- } else if (initializationTypeBinding.isCompatibleWith(typeBinding)) {
- this.initialization.implicitWidening(typeBinding, initializationTypeBinding);
+ } else if (initializationType.isCompatibleWith(fieldType)) {
+ this.initialization.implicitWidening(fieldType, initializationType);
} else {
- initializationScope.problemReporter().typeMismatchError(initializationTypeBinding, typeBinding, this);
+ initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this);
}
if (this.binding.isFinal()){ // cast from constant actual type to variable type
this.binding.constant =
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index 353fc00acb..1c1f3e2255 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -134,16 +134,16 @@ public class LocalDeclaration extends AbstractVariableDeclaration {
public void resolve(BlockScope scope) {
// create a binding and add it to the scope
- TypeBinding typeBinding = type.resolveType(scope);
+ TypeBinding variableType = type.resolveType(scope);
checkModifiers();
- if (typeBinding != null) {
- if (typeBinding == VoidBinding) {
+ if (variableType != null) {
+ if (variableType == VoidBinding) {
scope.problemReporter().variableTypeCannotBeVoid(this);
return;
}
- if (typeBinding.isArrayType() && ((ArrayBinding) typeBinding).leafComponentType == VoidBinding) {
+ if (variableType.isArrayType() && ((ArrayBinding) variableType).leafComponentType == VoidBinding) {
scope.problemReporter().variableTypeCannotBeVoidArray(this);
return;
}
@@ -164,14 +164,14 @@ public class LocalDeclaration extends AbstractVariableDeclaration {
if ((modifiers & AccFinal)!= 0 && this.initialization == null) {
modifiers |= AccBlankFinal;
}
- binding = new LocalVariableBinding(this, typeBinding, modifiers, false);
+ binding = new LocalVariableBinding(this, variableType, modifiers, false);
scope.addLocalVariable(binding);
binding.constant = NotAConstant;
// allow to recursivelly target the binding....
// the correct constant is harmed if correctly computed at the end of this method
}
- if (typeBinding == null) {
+ if (variableType == null) {
if (initialization != null)
initialization.resolveType(scope); // want to report all possible errors
return;
@@ -180,20 +180,22 @@ public class LocalDeclaration extends AbstractVariableDeclaration {
// store the constant for final locals
if (initialization != null) {
if (initialization instanceof ArrayInitializer) {
- TypeBinding initializationType = initialization.resolveTypeExpecting(scope, typeBinding);
+ TypeBinding initializationType = initialization.resolveTypeExpecting(scope, variableType);
if (initializationType != null) {
((ArrayInitializer) initialization).binding = (ArrayBinding) initializationType;
- initialization.implicitWidening(typeBinding, initializationType);
+ initialization.implicitWidening(variableType, initializationType);
}
} else {
TypeBinding initializationType = initialization.resolveType(scope);
if (initializationType != null) {
- if (initialization.isConstantValueOfTypeAssignableToType(initializationType, typeBinding)
- || (typeBinding.isBaseType() && BaseTypeBinding.isWidening(typeBinding.id, initializationType.id))
- || initializationType.isCompatibleWith(typeBinding))
- initialization.implicitWidening(typeBinding, initializationType);
+ if (variableType != initializationType) // must call before computeConversion() and typeMismatchError()
+ scope.compilationUnitScope().recordTypeConversion(variableType, initializationType);
+ if (initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType)
+ || (variableType.isBaseType() && BaseTypeBinding.isWidening(variableType.id, initializationType.id))
+ || initializationType.isCompatibleWith(variableType))
+ initialization.implicitWidening(variableType, initializationType);
else
- scope.problemReporter().typeMismatchError(initializationType, typeBinding, this);
+ scope.problemReporter().typeMismatchError(initializationType, variableType, this);
}
}
@@ -203,7 +205,7 @@ public class LocalDeclaration extends AbstractVariableDeclaration {
if (binding != null) {
binding.constant =
binding.isFinal()
- ? initialization.constant.castTo((typeBinding.id << 4) + initialization.constant.typeID())
+ ? initialization.constant.castTo((variableType.id << 4) + initialization.constant.typeID())
: NotAConstant;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index af7dd02d3a..4f80f5641f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -276,6 +276,8 @@ public class QualifiedAllocationExpression extends AllocationExpression {
// The enclosing instance must be compatible with the innermost enclosing type
ReferenceBinding expectedType = this.binding.declaringClass.enclosingType();
+ if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError()
+ scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType);
if (enclosingInstanceType.isCompatibleWith(expectedType)) {
return receiverType;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
index ca74dae364..1dc21ebd40 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
@@ -210,23 +210,24 @@ public class ReturnStatement extends Statement {
}
if ((expressionType = expression.resolveType(scope)) == null)
return;
-
- if (methodType != null && expression.isConstantValueOfTypeAssignableToType(expressionType, methodType)) {
+ if (expressionType == VoidBinding) {
+ scope.problemReporter().attemptToReturnVoidValue(this);
+ return;
+ }
+ if (methodType == null)
+ return;
+ if (methodType != expressionType) // must call before computeConversion() and typeMismatchError()
+ scope.compilationUnitScope().recordTypeConversion(methodType, expressionType);
+ if (expression.isConstantValueOfTypeAssignableToType(expressionType, methodType)) {
// dealing with constant
expression.implicitWidening(methodType, expressionType);
return;
}
- if (expressionType == VoidBinding) {
- scope.problemReporter().attemptToReturnVoidValue(this);
- return;
- }
- if (methodType != null && expressionType.isCompatibleWith(methodType)) {
+ if (expressionType.isCompatibleWith(methodType)) {
expression.implicitWidening(methodType, expressionType);
return;
}
- if (methodType != null){
- scope.problemReporter().typeMismatchErrorActualTypeExpectedType(expression, expressionType, methodType);
- }
+ scope.problemReporter().typeMismatchErrorActualTypeExpectedType(expression, expressionType, methodType);
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index 6ada2f8d4c..3cffe58d72 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -317,7 +317,7 @@ public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
// NOTE: the return type, arg & exception types of each method of a binary type are resolved when needed
// searches up the hierarchy as long as no potential (but not exact) match was found.
-public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes) {
+public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes, CompilationUnitScope refScope) {
int argCount = argumentTypes.length;
int selectorLength = selector.length;
boolean foundNothing = true;
@@ -338,10 +338,15 @@ public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes
if (foundNothing) {
if (isInterface()) {
- if (superInterfaces.length == 1)
- return superInterfaces[0].getExactMethod(selector, argumentTypes);
+ if (superInterfaces.length == 1) {
+ if (refScope != null)
+ refScope.recordTypeReference(superInterfaces[0]);
+ return superInterfaces[0].getExactMethod(selector, argumentTypes, refScope);
+ }
} else if (superclass != null) {
- return superclass.getExactMethod(selector, argumentTypes);
+ if (refScope != null)
+ refScope.recordTypeReference(superclass);
+ return superclass.getExactMethod(selector, argumentTypes, refScope);
}
}
return null;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 12057f396e..166e3f76de 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -760,7 +760,7 @@ public class ClassScope extends Scope {
sourceType.tagBits |= HierarchyHasProblems;
return true;
}
-
+ compilationUnitScope().recordSuperTypeReference(superType); // to record supertypes
if (superType.isBinaryBinding()) {
// force its superclass & superinterfaces to be found... 2 possibilities exist - the source type is included in the hierarchy of:
// - a binary type... this case MUST be caught & reported here
@@ -853,7 +853,7 @@ public class ClassScope extends Scope {
if (typeOrPackage instanceof PackageBinding) // error, the compoundName is a packageName
return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, n), NotFound);
superType = (ReferenceBinding) typeOrPackage;
- compilationUnitScope().recordTypeReference(superType); // to record supertypes
+// compilationUnitScope().recordTypeReference(superType); // to record supertypes
if (checkVisibility
&& n == size) { // if we're finished and know the final supertype then check visibility
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index d4a8d4f480..d2c6c247e5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -36,7 +36,8 @@ public class CompilationUnitScope extends Scope {
private CompoundNameVector qualifiedReferences;
private SimpleNameVector simpleNameReferences;
private ObjectVector referencedTypes;
-
+ private ObjectVector referencedSuperTypes;
+
HashtableOfType constantPoolNameUsage;
public CompilationUnitScope(CompilationUnitDeclaration unit, LookupEnvironment environment) {
@@ -50,11 +51,13 @@ public CompilationUnitScope(CompilationUnitDeclaration unit, LookupEnvironment e
this.qualifiedReferences = new CompoundNameVector();
this.simpleNameReferences = new SimpleNameVector();
this.referencedTypes = new ObjectVector();
+ this.referencedSuperTypes = new ObjectVector();
} else {
this.qualifiedReferences = null; // used to test if dependencies should be recorded
this.simpleNameReferences = null;
this.referencedTypes = null;
- }
+ this.referencedSuperTypes = null;
+ }
}
void buildFieldsAndMethods() {
for (int i = 0, length = topLevelTypes.length; i < length; i++)
@@ -511,36 +514,34 @@ void recordSimpleReference(char[] simpleName) {
if (!simpleNameReferences.contains(simpleName))
simpleNameReferences.add(simpleName);
}
-void recordTypeReference(TypeBinding type) {
- if (referencedTypes == null) return; // not recording dependencies
-
- if (type.isArrayType())
- type = ((ArrayBinding) type).leafComponentType;
+void recordSuperTypeReference(TypeBinding type) {
+ if (referencedSuperTypes == null) return; // not recording dependencies
- if (type.isBaseType()) return;
- if (referencedTypes.containsIdentical(type)) return;
- if (((ReferenceBinding) type).isLocalType()) return;
+ ReferenceBinding actualType = typeToRecord(type);
+ if (actualType != null && !referencedSuperTypes.containsIdentical(actualType))
+ referencedSuperTypes.add(actualType);
+}
+public void recordTypeConversion(TypeBinding superType, TypeBinding subType) {
+ recordSuperTypeReference(subType); // must record the hierarchy of the subType that is converted to the superType
+}
+void recordTypeReference(TypeBinding type) {
+ if (referencedTypes == null) return; // not recording dependencies
- referencedTypes.add(type);
+ ReferenceBinding actualType = typeToRecord(type);
+ if (actualType != null && !referencedTypes.containsIdentical(actualType))
+ referencedTypes.add(actualType);
}
void recordTypeReferences(TypeBinding[] types) {
- if (qualifiedReferences == null) return; // not recording dependencies
- if (types == null || types.length == 0) return;
-
- for (int i = 0, max = types.length; i < max; i++) {
- // No need to record supertypes of method arguments & thrown exceptions, just the compoundName
- // If a field/method is retrieved from such a type then a separate call does the job
- TypeBinding type = types[i];
- if (type.isArrayType())
- type = ((ArrayBinding) type).leafComponentType;
- if (!type.isBaseType()) {
- ReferenceBinding actualType = (ReferenceBinding) type;
- if (!actualType.isLocalType())
- recordQualifiedReference(actualType.isMemberType()
- ? CharOperation.splitOn('.', actualType.readableName())
- : actualType.compoundName);
- }
- }
+ if (referencedTypes == null) return; // not recording dependencies
+ if (types == null || types.length == 0) return;
+
+ for (int i = 0, max = types.length; i < max; i++) {
+ // No need to record supertypes of method arguments & thrown exceptions, just the compoundName
+ // If a field/method is retrieved from such a type then a separate call does the job
+ ReferenceBinding actualType = typeToRecord(types[i]);
+ if (actualType != null && !referencedTypes.containsIdentical(actualType))
+ referencedTypes.add(actualType);
+ }
}
Binding resolveSingleTypeImport(ImportBinding importBinding) {
if (importBinding.resolvedImport == null) {
@@ -560,43 +561,60 @@ Binding resolveSingleTypeImport(ImportBinding importBinding) {
return importBinding.resolvedImport;
}
public void storeDependencyInfo() {
- // add the type hierarchy of each referenced type
- // cannot do early since the hierarchy may not be fully resolved
- for (int i = 0; i < referencedTypes.size; i++) { // grows as more types are added
- ReferenceBinding type = (ReferenceBinding) referencedTypes.elementAt(i);
- if (!type.isLocalType()) {
- recordQualifiedReference(type.isMemberType()
- ? CharOperation.splitOn('.', type.readableName())
- : type.compoundName);
- ReferenceBinding enclosing = type.enclosingType();
- if (enclosing != null && !referencedTypes.containsIdentical(enclosing))
- referencedTypes.add(enclosing); // to record its supertypes
- }
- ReferenceBinding superclass = type.superclass();
- if (superclass != null && !referencedTypes.containsIdentical(superclass))
- referencedTypes.add(superclass); // to record its supertypes
- ReferenceBinding[] interfaces = type.superInterfaces();
- if (interfaces != null && interfaces.length > 0)
- for (int j = 0, length = interfaces.length; j < length; j++)
- if (!referencedTypes.containsIdentical(interfaces[j]))
- referencedTypes.add(interfaces[j]); // to record its supertypes
- }
-
- int size = qualifiedReferences.size;
- char[][][] qualifiedRefs = new char[size][][];
- for (int i = 0; i < size; i++)
- qualifiedRefs[i] = qualifiedReferences.elementAt(i);
- referenceContext.compilationResult.qualifiedReferences = qualifiedRefs;
-
- size = simpleNameReferences.size;
- char[][] simpleRefs = new char[size][];
- for (int i = 0; i < size; i++)
- simpleRefs[i] = simpleNameReferences.elementAt(i);
- referenceContext.compilationResult.simpleNameReferences = simpleRefs;
+ // add the type hierarchy of each referenced supertype
+ // cannot do early since the hierarchy may not be fully resolved
+ for (int i = 0; i < referencedSuperTypes.size; i++) { // grows as more types are added
+ ReferenceBinding type = (ReferenceBinding) referencedSuperTypes.elementAt(i);
+ if (!referencedTypes.containsIdentical(type))
+ referencedTypes.add(type);
+
+ if (!type.isLocalType()) {
+ ReferenceBinding enclosing = type.enclosingType();
+ if (enclosing != null)
+ recordSuperTypeReference(enclosing);
+ }
+ ReferenceBinding superclass = type.superclass();
+ if (superclass != null)
+ recordSuperTypeReference(superclass);
+ ReferenceBinding[] interfaces = type.superInterfaces();
+ if (interfaces != null)
+ for (int j = 0, length = interfaces.length; j < length; j++)
+ recordSuperTypeReference(interfaces[j]);
+ }
+
+ for (int i = 0, l = referencedTypes.size; i < l; i++) {
+ ReferenceBinding type = (ReferenceBinding) referencedTypes.elementAt(i);
+ if (!type.isLocalType())
+ recordQualifiedReference(type.isMemberType()
+ ? CharOperation.splitOn('.', type.readableName())
+ : type.compoundName);
+ }
+
+ int size = qualifiedReferences.size;
+ char[][][] qualifiedRefs = new char[size][][];
+ for (int i = 0; i < size; i++)
+ qualifiedRefs[i] = qualifiedReferences.elementAt(i);
+ referenceContext.compilationResult.qualifiedReferences = qualifiedRefs;
+
+ size = simpleNameReferences.size;
+ char[][] simpleRefs = new char[size][];
+ for (int i = 0; i < size; i++)
+ simpleRefs[i] = simpleNameReferences.elementAt(i);
+ referenceContext.compilationResult.simpleNameReferences = simpleRefs;
}
public String toString() {
return "--- CompilationUnit Scope : " + new String(referenceContext.getFileName()); //$NON-NLS-1$
}
+private ReferenceBinding typeToRecord(TypeBinding type) {
+ if (type.isArrayType())
+ type = ((ArrayBinding) type).leafComponentType;
+
+ if (type instanceof ReferenceBinding) {
+ ReferenceBinding refType = (ReferenceBinding) type;
+ if (!refType.isLocalType()) return refType;
+ }
+ return null;
+}
public void verifyMethods(MethodVerifier verifier) {
for (int i = 0, length = topLevelTypes.length; i < length; i++)
topLevelTypes[i].verifyMethods(verifier);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index 6cda282e33..6cbeacc197 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -316,7 +316,7 @@ public final int getAccessFlags() {
public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
return null;
}
-public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes) {
+public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes, CompilationUnitScope refScope) {
return null;
}
public FieldBinding getField(char[] fieldName, boolean needResolve) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index bfbb0b55c8..89a7f10cfa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -137,27 +137,27 @@ public abstract class Scope
return ((CompilationUnitScope) unitScope).environment;
}
- protected void faultInReceiverType(TypeBinding type) {
- if (type.isArrayType())
- type = ((ArrayBinding) type).leafComponentType;
-
- // check on Begin bit, so as to be resilient with potential illformed binaries containing cycles (67769)
- if (type instanceof BinaryTypeBinding && (type.tagBits & BeginHierarchyCheck) == 0) {
- type.tagBits |= BeginHierarchyCheck;
- // fault in the hierarchy of the type now so we can detect missing types instead of in storeDependencyInfo
- BinaryTypeBinding binaryType = (BinaryTypeBinding) type;
- ReferenceBinding enclosingType = binaryType.enclosingType();
- if (enclosingType != null)
- faultInReceiverType(enclosingType);
- ReferenceBinding superclass = binaryType.superclass();
- if (superclass != null)
- faultInReceiverType(superclass);
- ReferenceBinding[] interfaces = binaryType.superInterfaces();
- for (int i = 0, l = interfaces.length; i < l; i++)
- faultInReceiverType(interfaces[i]);
- type.tagBits |= EndHierarchyCheck;
- }
- }
+// protected void faultInReceiverType(TypeBinding type) {
+// if (type.isArrayType())
+// type = ((ArrayBinding) type).leafComponentType;
+//
+// // check on Begin bit, so as to be resilient with potential illformed binaries containing cycles (67769)
+// if (type instanceof BinaryTypeBinding && (type.tagBits & BeginHierarchyCheck) == 0) {
+// type.tagBits |= BeginHierarchyCheck;
+// // fault in the hierarchy of the type now so we can detect missing types instead of in storeDependencyInfo
+// BinaryTypeBinding binaryType = (BinaryTypeBinding) type;
+// ReferenceBinding enclosingType = binaryType.enclosingType();
+// if (enclosingType != null)
+// faultInReceiverType(enclosingType);
+// ReferenceBinding superclass = binaryType.superclass();
+// if (superclass != null)
+// faultInReceiverType(superclass);
+// ReferenceBinding[] interfaces = binaryType.superInterfaces();
+// for (int i = 0, l = interfaces.length; i < l; i++)
+// faultInReceiverType(interfaces[i]);
+// type.tagBits |= EndHierarchyCheck;
+// }
+// }
// abstract method lookup lookup (since maybe missing default abstract methods)
public MethodBinding findDefaultAbstractMethod(
@@ -239,12 +239,11 @@ public abstract class Scope
TypeBinding[] argumentTypes,
InvocationSite invocationSite) {
- faultInReceiverType(receiverType);
- compilationUnitScope().recordTypeReference(receiverType);
- compilationUnitScope().recordTypeReferences(argumentTypes);
- MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes);
+ CompilationUnitScope unitScope = compilationUnitScope();
+ unitScope.recordTypeReferences(argumentTypes);
+ MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, unitScope);
if (exactMethod != null) {
- compilationUnitScope().recordTypeReferences(exactMethod.thrownExceptions);
+ unitScope.recordTypeReferences(exactMethod.thrownExceptions);
if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this))
return exactMethod;
}
@@ -274,8 +273,8 @@ public abstract class Scope
return null;
}
- faultInReceiverType(receiverType);
- compilationUnitScope().recordTypeReference(receiverType);
+ CompilationUnitScope unitScope = compilationUnitScope();
+ unitScope.recordTypeReference(receiverType);
ReferenceBinding currentType = (ReferenceBinding) receiverType;
if (!currentType.canBeSeenBy(this))
@@ -311,6 +310,7 @@ public abstract class Scope
if ((currentType = currentType.superclass()) == null)
break;
+ unitScope.recordTypeReference(currentType);
if ((field = currentType.getField(fieldName, needResolve)) != null) {
keepLooking = false;
if (field.canBeSeenBy(receiverType, invocationSite, this)) {
@@ -334,6 +334,7 @@ public abstract class Scope
if ((anInterface.tagBits & InterfaceVisited) == 0) {
// if interface as not already been visited
anInterface.tagBits |= InterfaceVisited;
+ unitScope.recordTypeReference(anInterface);
if ((field = anInterface.getField(fieldName, true /*resolve*/)) != null) {
if (visibleField == null) {
visibleField = field;
@@ -497,7 +498,6 @@ public abstract class Scope
MethodBinding matchingMethod = null;
ObjectVector found = new ObjectVector(); //TODO should rewrite to remove #matchingMethod since found is allocated anyway
- faultInReceiverType(receiverType);
compilationUnitScope().recordTypeReference(receiverType);
compilationUnitScope().recordTypeReferences(argumentTypes);
@@ -516,7 +516,9 @@ public abstract class Scope
boolean isCompliant14 = compilationUnitScope().environment.options.complianceLevel >= ClassFileConstants.JDK1_4;
// superclass lookup
ReferenceBinding classHierarchyStart = currentType;
+ CompilationUnitScope unitScope = compilationUnitScope();
while (currentType != null) {
+ unitScope.recordTypeReference(currentType);
MethodBinding[] currentMethods = currentType.getMethods(selector);
int currentLength = currentMethods.length;
@@ -677,7 +679,7 @@ public abstract class Scope
}
ReferenceBinding object = getJavaLangObject();
- MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes);
+ MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
if (methodBinding != null) {
// handle the method clone() specially... cannot be protected or throw exceptions
if (argumentTypes == NoParameters && CharOperation.equals(selector, CLONE))
@@ -737,7 +739,8 @@ public abstract class Scope
if ((currentType.tagBits & InterfaceVisited) == 0) {
// if interface as not already been visited
currentType.tagBits |= InterfaceVisited;
-
+
+ compilationUnitScope().recordTypeReference(currentType);
MethodBinding[] currentMethods = currentType.getMethods(selector);
int currentLength = currentMethods.length;
if (currentLength == 1 && matchingMethod == null && found.size == 0) {
@@ -1041,7 +1044,6 @@ public abstract class Scope
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
try {
- faultInReceiverType(receiverType);
compilationUnitScope().recordTypeReference(receiverType);
compilationUnitScope().recordTypeReferences(argumentTypes);
MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
@@ -1418,10 +1420,12 @@ public abstract class Scope
public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
try {
+ if (receiverType.isBaseType())
+ return new ProblemMethodBinding(selector, argumentTypes, NotFound);
+
+ compilationUnitScope().recordTypeReference(receiverType);
if (receiverType.isArrayType())
return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
- if (receiverType.isBaseType())
- return new ProblemMethodBinding(selector, argumentTypes, NotFound);
ReferenceBinding currentType = (ReferenceBinding) receiverType;
if (!currentType.canBeSeenBy(this))
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index e791f1e03e..c89be68748 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -439,7 +439,7 @@ public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
// NOTE: the return type, arg & exception types of each method of a source type are resolved when needed
// searches up the hierarchy as long as no potential (but not exact) match was found.
-public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes) {
+public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes, CompilationUnitScope refScope) {
int argCount = argumentTypes.length;
int selectorLength = selector.length;
boolean foundNothing = true;
@@ -475,10 +475,15 @@ public MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes
if (foundNothing) {
if (isInterface()) {
- if (superInterfaces.length == 1)
- return superInterfaces[0].getExactMethod(selector, argumentTypes);
+ if (superInterfaces.length == 1) {
+ if (refScope != null)
+ refScope.recordTypeReference(superInterfaces[0]);
+ return superInterfaces[0].getExactMethod(selector, argumentTypes, refScope);
+ }
} else if (superclass != null) {
- return superclass.getExactMethod(selector, argumentTypes);
+ if (refScope != null)
+ refScope.recordTypeReference(superclass);
+ return superclass.getExactMethod(selector, argumentTypes, refScope);
}
}
return null;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
index d1fe48e296..5a112a53b5 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
@@ -941,7 +941,7 @@ class DefaultBindingResolver extends BindingResolver {
case ProblemReasons.NonStaticReferenceInConstructorInvocation :
ReferenceBinding declaringClass = methodBinding.declaringClass;
if (declaringClass != null) {
- org.eclipse.jdt.internal.compiler.lookup.MethodBinding exactBinding = declaringClass.getExactMethod(methodBinding.selector, methodBinding.parameters);
+ org.eclipse.jdt.internal.compiler.lookup.MethodBinding exactBinding = declaringClass.getExactMethod(methodBinding.selector, methodBinding.parameters, null);
if (exactBinding != null) {
IMethodBinding binding = (IMethodBinding) this.compilerBindingsToASTBindings.get(exactBinding);
if (binding != null) {
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java
index 10c42cb805..b361131b69 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java
@@ -243,7 +243,7 @@ public final boolean canBeSeenByForCodeSnippet(ReferenceBinding referenceBinding
}
// Internal use only
public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
- MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes);
+ MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, null);
if (exactMethod != null){
if (receiverType.isInterface() || canBeSeenByForCodeSnippet(exactMethod, receiverType, invocationSite, this))
return exactMethod;
@@ -484,7 +484,7 @@ public MethodBinding findMethod(
// Internal use only
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
ReferenceBinding object = getJavaLangObject();
- MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes);
+ MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
if (methodBinding != null) {
// handle the method clone() specially... cannot be protected or throw exceptions
if (argumentTypes == NoParameters && CharOperation.equals(selector, CLONE))

Back to the top