Bug 320004 - 3.5.2+ fixes to AST instruction copmiler - follow to bug 277574
diff --git a/org.eclipse.jdt.debug/META-INF/MANIFEST.MF b/org.eclipse.jdt.debug/META-INF/MANIFEST.MF
index 22a2edb..e3c3773 100644
--- a/org.eclipse.jdt.debug/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.debug/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.debug; singleton:=true
-Bundle-Version: 3.5.0.qualifier
+Bundle-Version: 3.5.1.qualifier
Bundle-ClassPath: jdi.jar,
jdimodel.jar,
tools.jar
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java
index 119f903..93e25be 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -188,6 +188,8 @@
import org.eclipse.jdt.internal.debug.eval.ast.instructions.XorAssignmentOperator;
import org.eclipse.jdt.internal.debug.eval.ast.instructions.XorOperator;
+import com.ibm.icu.text.MessageFormat;
+
/**
* The AST instruction compiler generates a sequence
* of instructions (InstructionSequence) from a
@@ -441,12 +443,12 @@
if (expression instanceof MethodInvocation) {
IMethodBinding methodBinding= (IMethodBinding)((MethodInvocation)expression).getName().resolveBinding();
- if ("void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$
+ if (methodBinding != null && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$
pop= false;
}
} else if (expression instanceof SuperMethodInvocation) {
IMethodBinding methodBinding= (IMethodBinding)((SuperMethodInvocation)expression).getName().resolveBinding();
- if ("void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$
+ if (methodBinding != null && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$
pop= false;
}
} else if (expression instanceof VariableDeclarationExpression) {
@@ -593,6 +595,11 @@
public void endVisit(ArrayAccess node) {
if (!isActive() || hasErrors())
return;
+ ITypeBinding typeBinding = node.getIndex().resolveTypeBinding();
+ if (typeBinding != null && unBoxing(typeBinding)) {
+ // un-box the index, if required
+ storeInstruction();
+ }
storeInstruction();
}
@@ -1518,10 +1525,11 @@
ArrayType arrayType= node.getType();
- if (isALocalType(arrayType.resolveBinding().getElementType())) {
+ ITypeBinding binding = resolveTypeBinding(arrayType);
+ if (binding != null && isALocalType(binding.getElementType())) {
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Local_type_array_instance_creation_cannot_be_used_in_an_evaluation_expression_29);
setHasError(true);
- return true;
+ return false;
}
push(new ArrayAllocation(arrayType.getDimensions(), node.dimensions().size(), node.getInitializer() != null, fCounter));
@@ -1537,11 +1545,12 @@
return false;
}
- ITypeBinding typeBinding= node.resolveTypeBinding();
- int dimension= typeBinding.getDimensions();
- String signature= getTypeSignature(typeBinding.getElementType());
-
- push(new ArrayInitializerInstruction(signature, node.expressions().size(), dimension, fCounter));
+ ITypeBinding typeBinding = resolveTypeBinding(node);
+ if (typeBinding != null) {
+ int dimension= typeBinding.getDimensions();
+ String signature= getTypeSignature(typeBinding.getElementType());
+ push(new ArrayInitializerInstruction(signature, node.expressions().size(), dimension, fCounter));
+ }
return true;
}
@@ -1553,11 +1562,12 @@
if (!isActive()) {
return false;
}
- ITypeBinding arrayTypeBinding= node.resolveBinding();
- int dimension= arrayTypeBinding.getDimensions();
- String signature= getTypeSignature(arrayTypeBinding.getElementType());
-
- push(new PushArrayType(signature, dimension, fCounter));
+ ITypeBinding arrayTypeBinding= resolveTypeBinding(node);
+ if (arrayTypeBinding != null) {
+ int dimension= arrayTypeBinding.getDimensions();
+ String signature= getTypeSignature(arrayTypeBinding.getElementType());
+ push(new PushArrayType(signature, dimension, fCounter));
+ }
return false;
}
@@ -1571,7 +1581,7 @@
}
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Assert_statement_cannot_be_used_in_an_evaluation_expression_3);
- return true;
+ return false;
}
/**
@@ -1594,6 +1604,14 @@
char2 = opToken.charAt(2);
}
+ ITypeBinding rightBinding = resolveTypeBinding(rightHandSide);
+ if (rightBinding == null) {
+ return false;
+ }
+ ITypeBinding leftBinding = resolveTypeBinding(leftHandSide);
+ if (leftBinding == null) {
+ return false;
+ }
if (variableTypeId == Instruction.T_Object) {
// If the variable is an object, the value may need to be boxed for
// the simple assignment.
@@ -1612,8 +1630,8 @@
if (char0 == '=') {
boolean storeRequired= false;
- if (rightHandSide.resolveTypeBinding().isPrimitive()) {
- boxing(leftHandSide.resolveTypeBinding(), rightHandSide.resolveTypeBinding());
+ if (rightBinding.isPrimitive()) {
+ boxing(leftBinding, rightBinding);
storeRequired= true;
}
rightHandSide.accept(this);
@@ -1625,7 +1643,7 @@
boolean unrecognized = false;
- boxing(leftHandSide.resolveTypeBinding(), rightHandSide.resolveTypeBinding());
+ boxing(leftBinding, rightBinding);
switch (char0) {
case '=': // equal
@@ -1681,12 +1699,12 @@
return false;
}
- unBoxing(leftHandSide.resolveTypeBinding());
+ unBoxing(leftBinding);
push(new Dup());
storeInstruction(); // dupe
storeInstruction(); // un-boxing
- boolean storeRequired= unBoxing(rightHandSide.resolveTypeBinding());
+ boolean storeRequired= unBoxing(rightBinding);
rightHandSide.accept(this);
if (storeRequired) {
storeInstruction(); // un-boxing
@@ -1756,7 +1774,7 @@
}
leftHandSide.accept(this);
- boolean storeRequired= unBoxing(rightHandSide.resolveTypeBinding());
+ boolean storeRequired= unBoxing(rightBinding);
rightHandSide.accept(this);
if (storeRequired) {
storeInstruction();
@@ -1836,20 +1854,18 @@
Type type= node.getType();
int typeId= getTypeId(type);
- ITypeBinding typeBinding= type.resolveBinding();
-
- String baseTypeSignature;
- int dimension= typeBinding.getDimensions();
-
- if (typeBinding.isArray()) {
- typeBinding= typeBinding.getElementType();
- }
+ ITypeBinding typeBinding= resolveTypeBinding(type);
- baseTypeSignature= getTypeName(typeBinding);
-
- push(new Cast(typeId, baseTypeSignature, dimension, fCounter));
-
- node.getExpression().accept(this);
+ if (typeBinding != null) {
+ String baseTypeSignature;
+ int dimension= typeBinding.getDimensions();
+ if (typeBinding.isArray()) {
+ typeBinding= typeBinding.getElementType();
+ }
+ baseTypeSignature= getTypeName(typeBinding);
+ push(new Cast(typeId, baseTypeSignature, dimension, fCounter));
+ node.getExpression().accept(this);
+ }
return false;
}
@@ -1863,7 +1879,7 @@
}
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Catch_clause_cannot_be_used_in_an_evaluation_expression_6);
- return true;
+ return false;
}
/**
@@ -1894,8 +1910,12 @@
}
IMethodBinding methodBinding= node.resolveConstructorBinding();
+ if (methodBinding == null) {
+ setHasError(true);
+ addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_1, new String[]{node.toString()}));
+ return false;
+ }
ITypeBinding typeBinding= methodBinding.getDeclaringClass();
- ITypeBinding enclosingTypeBinding= typeBinding.getDeclaringClass();
boolean isInstanceMemberType= typeBinding.isMember() && ! Modifier.isStatic(typeBinding.getModifiers());
@@ -1911,13 +1931,20 @@
if (hasErrors()) {
- return true;
+ return false;
}
int paramCount= methodBinding.getParameterTypes().length;
String enclosingTypeSignature= null;
+ ITypeBinding enclosingTypeBinding= null;
if (isInstanceMemberType) {
+ enclosingTypeBinding= typeBinding.getDeclaringClass();
+ if (enclosingTypeBinding == null) {
+ setHasError(true);
+ addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_2, new String[]{typeBinding.getQualifiedName()}));
+ return false;
+ }
enclosingTypeSignature= getTypeSignature(enclosingTypeBinding);
paramCount++;
}
@@ -1942,7 +1969,7 @@
if (Modifier.isStatic(((MethodDeclaration)parent).getModifiers())) {
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Must_explicitly_qualify_the_allocation_with_an_instance_of_the_enclosing_type_33);
- return true;
+ return false;
}
push(new PushThis(getEnclosingLevel(node, enclosingTypeBinding)));
@@ -2044,9 +2071,15 @@
push(new NoOp(fCounter));
- ITypeBinding typeBinding= node.getExpression().resolveTypeBinding();
+ ITypeBinding typeBinding= resolveTypeBinding(node.getExpression());
+ if (typeBinding == null) {
+ return false;
+ }
Type paramType= node.getParameter().getType();
- ITypeBinding paramBinding = paramType.resolveBinding();
+ ITypeBinding paramBinding = resolveTypeBinding(paramType);
+ if (paramBinding == null) {
+ return false;
+ }
String typeSignature= getTypeSignature(paramBinding);
int paramTypeId= getTypeId(paramType);
boolean isParamPrimitiveType= paramTypeId != Instruction.T_Object && paramTypeId != Instruction.T_String;
@@ -2310,8 +2343,21 @@
Expression rightOperand= node.getRightOperand();
int leftTypeId;
int rightTypeId;
- // == case, do not un-box, if the two operands are objects
- boolean unbox= char0 != '=' || leftOperand.resolveTypeBinding().isPrimitive() || rightOperand.resolveTypeBinding().isPrimitive();
+ boolean unbox = false;
+ // for == and != un-box when at least operand is primitive (otherwise compare the objects)
+ ITypeBinding leftBinding = resolveTypeBinding(leftOperand);
+ if (leftBinding == null) {
+ return false;
+ }
+ ITypeBinding rightBinding = resolveTypeBinding(rightOperand);
+ if (rightBinding == null) {
+ return false;
+ }
+ if ((char0 == '=' || char0 == '!') && char1 == '=') {
+ unbox = leftBinding.isPrimitive() || rightBinding.isPrimitive();
+ } else {
+ unbox = true;
+ }
if (unbox) {
leftTypeId= getUnBoxedTypeId(leftOperand);
rightTypeId = getUnBoxedTypeId(rightOperand);
@@ -2476,7 +2522,7 @@
}
if (hasErrors()) {
- return true;
+ return false;
}
iterator = extendedOperands.iterator();
@@ -2488,7 +2534,7 @@
ConditionalJump[] conditionalJumps= new ConditionalJump[operatorNumber];
int[] conditionalJumpAddresses = new int[operatorNumber];
- boolean storeRequired= unBoxing(leftOperand.resolveTypeBinding());
+ boolean storeRequired= unBoxing(leftBinding);
leftOperand.accept(this);
if (storeRequired) {
storeInstruction();
@@ -2500,7 +2546,7 @@
push(conditionalJump);
storeInstruction();
- storeRequired= unBoxing(rightOperand.resolveTypeBinding());
+ storeRequired= unBoxing(rightBinding);
rightOperand.accept(this);
if (storeRequired) {
storeInstruction();
@@ -2513,7 +2559,11 @@
push(conditionalJump);
storeInstruction();
Expression operand= (Expression) iterator.next();
- storeRequired= unBoxing(operand.resolveTypeBinding());
+ ITypeBinding typeBinding = resolveTypeBinding(operand);
+ if (typeBinding == null) {
+ return false;
+ }
+ storeRequired= unBoxing(typeBinding);
operand.accept(this);
if (storeRequired) {
storeInstruction();
@@ -2539,14 +2589,14 @@
boolean storeRequired= false;
if (unbox) {
- storeRequired= unBoxing(leftOperand.resolveTypeBinding());
+ storeRequired= unBoxing(leftBinding);
}
leftOperand.accept(this);
if (storeRequired) {
storeInstruction();
}
if (unbox) {
- storeRequired= unBoxing(rightOperand.resolveTypeBinding());
+ storeRequired= unBoxing(rightBinding);
}
rightOperand.accept(this);
if (storeRequired) {
@@ -2557,7 +2607,11 @@
for (int i= 1; i < operatorNumber; i ++) {
Expression operand= (Expression) iterator.next();
if (unbox) {
- storeRequired= unBoxing(operand.resolveTypeBinding());
+ ITypeBinding typeBinding = resolveTypeBinding(operand);
+ if (typeBinding == null) {
+ return false;
+ }
+ storeRequired= unBoxing(typeBinding);
}
operand.accept(this);
if (storeRequired) {
@@ -2673,16 +2727,13 @@
}
if (hasErrors()) {
- return true;
+ return false;
}
if (containsALocalType(methodBinding)) {
setHasError(true);
- addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32);
- }
-
- if (hasErrors()) {
- return true;
+ addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32);
+ return false;
}
int paramCount = methodBinding.getParameterTypes().length;
@@ -2727,7 +2778,15 @@
int argCount = arguments.size();
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes();
int paramCount = parameterTypes.length;
- if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == ((Expression)arguments.get(argCount - 1)).resolveTypeBinding().getDimensions())) {
+ ITypeBinding lastArgBinding = null;
+ if (methodBinding.isVarargs()) {
+ Expression lastArg = (Expression)arguments.get(argCount - 1);
+ lastArgBinding = resolveTypeBinding(lastArg);
+ if (lastArgBinding == null) {
+ return;
+ }
+ }
+ if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == lastArgBinding.getDimensions())) {
// if this method is a varargs, and if the method is invoked using the varargs syntax
// (multiple arguments) and not an array
Iterator iterator= arguments.iterator();
@@ -2921,8 +2980,10 @@
if (!isActive()) {
return false;
}
- ITypeBinding typeBinding = node.resolveBinding();
- push(new PushType(getTypeName(typeBinding)));
+ ITypeBinding typeBinding = resolveTypeBinding(node);
+ if (typeBinding != null) {
+ push(new PushType(getTypeName(typeBinding)));
+ }
return false;
}
@@ -2967,7 +3028,7 @@
default:
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken);
- break;
+ return false;
}
push(new Value(fCounter));
push(new Dup());
@@ -2975,12 +3036,16 @@
storeInstruction(); // value
push(new DupX1());
storeInstruction(); // dup_x1
- unBoxing(operand.resolveTypeBinding());
+ ITypeBinding typeBinding = resolveTypeBinding(operand);
+ if (typeBinding == null) {
+ return false;
+ }
+ unBoxing(typeBinding);
storeInstruction(); // un-boxing
push(new PushInt(1));
storeInstruction(); // push 1
storeInstruction(); // operator
- boxing(operand.resolveTypeBinding(), null);
+ boxing(typeBinding, null);
storeInstruction(); // boxing
storeInstruction(); // assignment
push(new Pop(assignmentInstruction.getSize() + 1));
@@ -2999,7 +3064,7 @@
default:
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_postfix_operator____15 + opToken);
- break;
+ return false;
}
return true;
@@ -3030,6 +3095,10 @@
int expressionUnBoxedTypeId= getUnBoxedTypeId(operand);
+ ITypeBinding typeBinding = resolveTypeBinding(operand);
+ if (typeBinding == null) {
+ return false;
+ }
if (char1 == '\0') {
switch (char0) {
case '+': // unary plus
@@ -3047,10 +3116,10 @@
default:
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken);
- break;
+ return false;
}
- unBoxing(operand.resolveTypeBinding());
+ unBoxing(typeBinding);
operand.accept(this);
storeInstruction(); // un-boxing
@@ -3061,7 +3130,7 @@
operand.accept(this);
- boxing(operand.resolveTypeBinding(), null);
+ boxing(typeBinding, null);
switch (char1) {
case '+':
@@ -3073,10 +3142,10 @@
default:
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken);
- break;
+ return false;
}
- unBoxing(operand.resolveTypeBinding());
+ unBoxing(typeBinding);
push(new Dup());
storeInstruction(); // dupe
storeInstruction(); // un-boxing
@@ -3133,6 +3202,7 @@
if (unrecognized) {
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_unrecognized_prefix_operator____16 + opToken);
+ return false;
}
return true;
@@ -3145,8 +3215,10 @@
if (!isActive()) {
return false;
}
- ITypeBinding typeBinding = node.resolveBinding();
- push(new PushPrimitiveType(getTypeName(typeBinding)));
+ ITypeBinding typeBinding = resolveTypeBinding(node);
+ if (typeBinding != null) {
+ push(new PushPrimitiveType(getTypeName(typeBinding)));
+ }
return false;
}
@@ -3162,14 +3234,20 @@
return true;
}
- IBinding binding = node.resolveBinding();
+ IBinding binding = resolveBinding(node);
+ if (binding == null) {
+ return false;
+ }
switch (binding.getKind()) {
case IBinding.TYPE:
node.getName().accept(this);
break;
case IBinding.VARIABLE:
SimpleName fieldName= node.getName();
- IVariableBinding fieldBinding= (IVariableBinding) fieldName.resolveBinding();
+ IVariableBinding fieldBinding= (IVariableBinding) resolveBinding(fieldName);
+ if (fieldBinding == null) {
+ return false;
+ }
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass();
String fieldId = fieldName.getIdentifier();
@@ -3197,8 +3275,10 @@
if (!isActive()) {
return false;
}
- ITypeBinding typeBinding = node.resolveBinding();
- push(new PushType(getTypeName(typeBinding)));
+ ITypeBinding typeBinding = resolveTypeBinding(node);
+ if (typeBinding != null) {
+ push(new PushType(getTypeName(typeBinding)));
+ }
return false;
}
@@ -3225,14 +3305,11 @@
return true;
}
- IBinding binding = node.resolveBinding();
-
- String variableId = node.getIdentifier();
+ IBinding binding = resolveBinding(node);
if (binding == null) {
- setHasError(true);
- addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_binding_null_for__17 + variableId);
return true;
}
+ String variableId = node.getIdentifier();
switch (binding.getKind()) {
case IBinding.TYPE:
@@ -3273,9 +3350,10 @@
return false;
}
- ITypeBinding typeBinding = node.resolveBinding();
- push(new PushType(getTypeName(typeBinding)));
-
+ ITypeBinding typeBinding = resolveTypeBinding(node);
+ if (typeBinding != null) {
+ push(new PushType(getTypeName(typeBinding)));
+ }
return false;
}
@@ -3294,15 +3372,17 @@
if (!isActive()) {
return false;
}
- ITypeBinding typeBinding= node.getType().resolveBinding();
- int typeDimension= typeBinding.getDimensions();
- if (typeDimension != 0) {
- typeBinding= typeBinding.getElementType();
- }
- Expression initializer= node.getInitializer();
- push(new LocalVariableCreation(node.getName().getIdentifier(), getTypeSignature(typeBinding), typeDimension, typeBinding.isPrimitive(), initializer != null, fCounter));
- if (initializer != null) {
- initializer.accept(this);
+ ITypeBinding typeBinding= resolveTypeBinding(node.getType());
+ if (typeBinding != null) {
+ int typeDimension= typeBinding.getDimensions();
+ if (typeDimension != 0) {
+ typeBinding= typeBinding.getElementType();
+ }
+ Expression initializer= node.getInitializer();
+ push(new LocalVariableCreation(node.getName().getIdentifier(), getTypeSignature(typeBinding), typeDimension, typeBinding.isPrimitive(), initializer != null, fCounter));
+ if (initializer != null) {
+ initializer.accept(this);
+ }
}
return false;
}
@@ -3341,7 +3421,10 @@
}
SimpleName fieldName= node.getName();
- IVariableBinding fieldBinding= (IVariableBinding) fieldName.resolveBinding();
+ IVariableBinding fieldBinding= (IVariableBinding) resolveBinding(fieldName);
+ if (fieldBinding == null) {
+ return false;
+ }
ITypeBinding declaringTypeBinding= fieldBinding.getDeclaringClass();
String fieldId = fieldName.getIdentifier();
@@ -3352,8 +3435,16 @@
int superLevel= 1;
int enclosingLevel= 0;
if (qualifier != null) {
- superLevel= getSuperLevel(qualifier.resolveTypeBinding(), declaringTypeBinding);
- enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding());
+ ITypeBinding typeBinding = resolveTypeBinding(qualifier);
+ if (typeBinding == null) {
+ return false;
+ }
+ superLevel= getSuperLevel(typeBinding, declaringTypeBinding);
+ ITypeBinding binding = (ITypeBinding)resolveBinding(qualifier);
+ if (binding == null) {
+ return false;
+ }
+ enclosingLevel= getEnclosingLevel(node, binding);
}
push(new PushFieldVariable(fieldId, superLevel, fCounter));
push(new PushThis(enclosingLevel));
@@ -3373,15 +3464,15 @@
return false;
}
- IMethodBinding methodBinding = (IMethodBinding) node.getName().resolveBinding();
+ IMethodBinding methodBinding = (IMethodBinding) resolveBinding(node.getName());
+ if (methodBinding == null) {
+ return false;
+ }
if (containsALocalType(methodBinding)) {
setHasError(true);
- addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32);
- }
-
- if (hasErrors()) {
- return true;
+ addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32);
+ return false;
}
ITypeBinding[] parameterTypes = methodBinding.getParameterTypes();
@@ -3396,7 +3487,11 @@
push(new SendMessage(selector, signature, paramCount, getTypeSignature(methodBinding.getDeclaringClass()), fCounter));
int enclosingLevel= 0;
if (qualifier != null) {
- enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding());
+ ITypeBinding typeBinding = (ITypeBinding)resolveBinding(qualifier);
+ if (typeBinding == null) {
+ return false;
+ }
+ enclosingLevel= getEnclosingLevel(node, typeBinding);
}
push(new PushThis(enclosingLevel));
storeInstruction();
@@ -3404,7 +3499,14 @@
List arguments = node.arguments();
int argCount = arguments.size();
- if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == ((Expression)arguments.get(argCount - 1)).resolveTypeBinding().getDimensions())) {
+ ITypeBinding lastArgBinding = null;
+ if (methodBinding.isVarargs()) {
+ lastArgBinding = resolveTypeBinding((Expression)arguments.get(argCount - 1));
+ if (lastArgBinding == null) {
+ return false;
+ }
+ }
+ if (methodBinding.isVarargs() && !(paramCount == argCount && parameterTypes[paramCount - 1].getDimensions() == lastArgBinding.getDimensions())) {
// if this method is a varargs, and if the method is invoked using the varargs syntax
// (multiple arguments) and not an array
Iterator iterator= arguments.iterator();
@@ -3597,7 +3699,11 @@
Name qualifier= node.getQualifier();
int enclosingLevel= 0;
if (qualifier != null) {
- enclosingLevel= getEnclosingLevel(node, (ITypeBinding)qualifier.resolveBinding());
+ ITypeBinding binding = (ITypeBinding)resolveBinding(qualifier);
+ if (binding == null) {
+ return false;
+ }
+ enclosingLevel= getEnclosingLevel(node, binding);
}
push(new PushThis(enclosingLevel));
@@ -3624,7 +3730,7 @@
}
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Try_statement_cannot_be_used_in_an_evaluation_expression_23);
- return true;
+ return false;
}
/**
@@ -3706,16 +3812,19 @@
ASTNode parent= node.getParent();
switch (parent.getNodeType()) {
case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
- varTypeBinding= ((VariableDeclarationExpression)parent).getType().resolveBinding();
+ varTypeBinding= resolveTypeBinding(((VariableDeclarationExpression)parent).getType());
break;
case ASTNode.VARIABLE_DECLARATION_STATEMENT:
- varTypeBinding= ((VariableDeclarationStatement)parent).getType().resolveBinding();
+ varTypeBinding= resolveTypeBinding(((VariableDeclarationStatement)parent).getType());
break;
default:
setHasError(true);
addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Error_in_type_declaration_statement);
return false;
}
+ if (varTypeBinding == null) {
+ return false;
+ }
int typeDimension= varTypeBinding.getDimensions();
ITypeBinding elementBinding = varTypeBinding;
if (typeDimension != 0) {
@@ -3779,6 +3888,9 @@
private int getTypeId(Expression expression) {
ITypeBinding typeBinding = expression.resolveTypeBinding();
+ if (typeBinding == null) {
+ return Instruction.T_undefined;
+ }
String typeName = typeBinding.getQualifiedName();
if (typeBinding.isPrimitive()) {
return getPrimitiveTypeId(typeName);
@@ -3791,6 +3903,9 @@
private int getUnBoxedTypeId(Expression expression) {
ITypeBinding typeBinding = expression.resolveTypeBinding();
+ if (typeBinding == null) {
+ return Instruction.T_undefined;
+ }
String typeName = typeBinding.getQualifiedName();
if (typeBinding.isPrimitive()) {
return getPrimitiveTypeId(typeName);
@@ -3824,7 +3939,7 @@
return getPrimitiveTypeId(((PrimitiveType)type).getPrimitiveTypeCode().toString());
} else if (type.isSimpleType()) {
SimpleType simpleType = (SimpleType) type;
- if ("java.lang.String".equals(simpleType.getName())){ //$NON-NLS-1$
+ if ("java.lang.String".equals(simpleType.getName().getFullyQualifiedName())){ //$NON-NLS-1$
return Instruction.T_String;
}
return Instruction.T_Object;
@@ -3893,4 +4008,68 @@
}
return Instruction.T_undefined;
}
+
+ /**
+ * Resolves and returns the type binding from the given expression reporting an error
+ * if the binding is <code>null</code>.
+ *
+ * @param expression expression to resolve type binding for
+ * @return type binding or <code>null</code> if not available
+ */
+ private ITypeBinding resolveTypeBinding(Expression expression) {
+ ITypeBinding typeBinding = expression.resolveTypeBinding();
+ if (typeBinding == null) {
+ setHasError(true);
+ addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{expression.toString()}));
+ }
+ return typeBinding;
+ }
+
+ /**
+ * Resolves and returns the type binding for the give type reporting an error
+ * if the binding is <code>null</code>.
+ *
+ * @param type type to resolve binding for
+ * @return type binding or <code>null</code> if not available
+ */
+ private ITypeBinding resolveTypeBinding(Type type) {
+ ITypeBinding typeBinding = type.resolveBinding();
+ if (typeBinding == null) {
+ setHasError(true);
+ addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{type.toString()}));
+ }
+ return typeBinding;
+ }
+
+ /**
+ * Resolves and returns the binding for the given name reporting an error
+ * if the binding is <code>null</code>.
+ *
+ * @param name name to resolve binding for
+ * @return binding or <code>null</code> if not available
+ */
+ private IBinding resolveBinding(Name name) {
+ IBinding binding = name.resolveBinding();
+ if (binding == null) {
+ setHasError(true);
+ addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_5, new String[]{name.getFullyQualifiedName()}));
+ }
+ return binding;
+ }
+
+ /**
+ * Resolves and returns the type binding for the given name reporting an error
+ * if the binding is <code>null</code>.
+ *
+ * @param name name to resolve type binding for
+ * @return type binding or <code>null</code> if not available
+ */
+ private ITypeBinding resolveTypeBinding(Name name) {
+ ITypeBinding typeBinding = name.resolveTypeBinding();
+ if (typeBinding == null) {
+ setHasError(true);
+ addErrorMessage(MessageFormat.format(EvaluationEngineMessages.ASTInstructionCompiler_3, new String[]{name.getFullyQualifiedName()}));
+ }
+ return typeBinding;
+ }
}
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java
index 50ee1d8..ccfba0f 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 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
@@ -28,7 +28,6 @@
public static String ASTInstructionCompiler_unrecognized_postfix_operator____15;
public static String ASTInstructionCompiler_unrecognized_prefix_operator____16;
- public static String ASTInstructionCompiler_binding_null_for__17;
public static String ASTInstructionCompiler_super_constructor_invocation_cannot_be_used_in_an_evaluation_expression_19;
public static String ASTInstructionCompiler_Try_statement_cannot_be_used_in_an_evaluation_expression_23;
@@ -48,8 +47,12 @@
public static String ASTEvaluationEngine_AST_evaluation_engine_cannot_evaluate_expression;
public static String ASTEvaluationEngine_An_unknown_error_occurred_during_evaluation;
public static String ASTEvaluationEngine_Cannot_perform_nested_evaluations;
+ public static String ASTInstructionCompiler_3;
public static String ASTInstructionCompiler_36;
public static String ASTInstructionCompiler_0;
+ public static String ASTInstructionCompiler_1;
+ public static String ASTInstructionCompiler_2;
+ public static String ASTInstructionCompiler_5;
static {
// load message values from bundle file
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties
index e186512..648e82f 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 2010 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
@@ -22,7 +22,6 @@
ASTInstructionCompiler_unrecognized_postfix_operator____15=unrecognized postfix operator :
ASTInstructionCompiler_unrecognized_prefix_operator____16=unrecognized prefix operator :
-ASTInstructionCompiler_binding_null_for__17=binding == null for
ASTInstructionCompiler_super_constructor_invocation_cannot_be_used_in_an_evaluation_expression_19=super constructor invocation cannot be used in an evaluation expression
ASTInstructionCompiler_Try_statement_cannot_be_used_in_an_evaluation_expression_23=Try statement cannot be used in an evaluation expression
@@ -43,8 +42,12 @@
ASTEvaluationEngine_An_unknown_error_occurred_during_evaluation=An unknown error occurred during evaluation
ASTEvaluationEngine_Cannot_perform_nested_evaluations=Cannot perform nested evaluations.
+ASTInstructionCompiler_3=Unable to resolve type binding for: {0}
ASTInstructionCompiler_36=Local type field access cannot be used in an evaluation expression
ASTInstructionCompiler_0=Enum declaration cannot be used in an evaluation expression
+ASTInstructionCompiler_1=Unable to resolve type binding of constructor: {0}
+ASTInstructionCompiler_2=Unable to resolve type binding of declaring type of: {0}
+ASTInstructionCompiler_5=Unable to resolve binding for: {0}
ASTEvaluationEngine_0=Unable to evaluate expressions in the context of an interface
ASTEvaluationEngine_1=Unable to retrieve type for java.lang.Object
ArrayRuntimeContext_0=Unable to retrieve type for java.lang.Object