Bug 513635 - Revert unnecessary loss of type safety in
Instruction#popValue()
Change-Id: Id06b8a26881a07065ec2993129b3485c0932d293
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java
index 7e78e6b..b27cb48 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -62,13 +62,7 @@
* if not available
*/
protected IJavaArray popArray() throws CoreException {
- Object popValue = popValue();
- if (! (popValue instanceof IJavaValue)) {
- throw new CoreException(new Status(IStatus.ERROR,
- JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK,
- "Internal error: attempt to access non-java object", null)); //$NON-NLS-1$
- }
- IJavaValue value = (IJavaValue) popValue;
+ IJavaValue value = popValue();
if (value instanceof IJavaArray) {
return (IJavaArray) value;
} else if (value.isNull()) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java
index e812e51..95aff73 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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,7 +13,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.debug.core.IJavaArray;
import org.eclipse.jdt.debug.core.IJavaArrayType;
-import org.eclipse.jdt.debug.core.IJavaValue;
public class ArrayInitializerInstruction extends ArrayInstruction {
@@ -47,10 +46,7 @@
IJavaArray array = arrayType.newInstance(fLength);
for (int i = fLength - 1; i >= 0; i--) {
- Object popValue = popValue();
- if (popValue instanceof IJavaValue) {
- array.setValue(i, (IJavaValue) popValue);
- }
+ array.setValue(i, popValue());
}
push(array);
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java
index 9b7f06e..1a31a57 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -31,10 +31,7 @@
*/
@Override
public void execute() throws CoreException {
- Object popValue = popValue();
- if (!(popValue instanceof IJavaValue))
- return;
- IJavaValue value = (IJavaValue) popValue;
+ IJavaValue value = popValue();
IJavaVariable variable = (IJavaVariable) pop();
if (value instanceof IJavaPrimitiveValue) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java
index 70151a6..1e70cee 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -42,10 +42,7 @@
}
private void executeAssignment() throws CoreException {
- Object popValue = popValue();
- if (!(popValue instanceof IJavaValue))
- return;
- IJavaValue value = (IJavaValue) popValue;
+ IJavaValue value = popValue();
IJavaVariable variable = (IJavaVariable) pop();
IJavaValue variableValue = (IJavaValue) variable.getValue();
@@ -83,11 +80,8 @@
}
private void executeBinary() throws CoreException {
- Object popValue = popValue();
- if (!(popValue instanceof IJavaValue))
- return;
- IJavaValue right = (IJavaValue) popValue;
- IJavaValue left = (IJavaValue) popValue();
+ IJavaValue right = popValue();
+ IJavaValue left = popValue();
switch (fResultTypeId) {
case T_String:
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java
index 3007ad7..c3193df 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -56,10 +56,7 @@
*/
@Override
public void execute() throws CoreException {
- Object popValue = popValue();
- if (!(popValue instanceof IJavaValue))
- return;
- IJavaValue value = (IJavaValue) popValue;
+ IJavaValue value = popValue();
if (value instanceof IJavaPrimitiveValue) {
IJavaPrimitiveValue primitiveValue = (IJavaPrimitiveValue) value;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java
index c28b839..5bca4ff 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 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,10 +28,7 @@
*/
@Override
public void execute() throws CoreException {
- Object popValue = popValue();
- if (!(popValue instanceof IJavaValue))
- return;
- IJavaValue conditionValue = (IJavaValue) popValue;
+ IJavaValue conditionValue = popValue();
IJavaPrimitiveValue condition = null;
if (conditionValue instanceof IJavaPrimitiveValue) {
condition = (IJavaPrimitiveValue) conditionValue;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java
index 72f4911..92a07d3 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -34,10 +34,7 @@
IJavaValue[] args = new IJavaValue[fArgCount];
// args are in reverse order
for (int i = fArgCount - 1; i >= 0; i--) {
- Object popValue = popValue();
- if (popValue instanceof IJavaValue) {
- args[i] = (IJavaValue) popValue;
- }
+ args[i] = popValue();
}
IJavaClassType clazz = (IJavaClassType) pop();
IJavaValue result = clazz.newInstance(fSignature, args, getContext()
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java
index f4f04b4..4697334 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -34,10 +34,7 @@
@Override
public void execute() throws CoreException {
IJavaType type = (IJavaType) pop();
- Object popValue = popValue();
- if (!(popValue instanceof IJavaValue))
- return;
- IJavaValue value = (IJavaValue) popValue;
+ IJavaValue value = popValue();
if (value instanceof JDINullValue) {
pushNewValue(false);
return;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java
index 9a9011c..3b48d11 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -105,12 +105,12 @@
return fInterpreter.pop();
}
- protected Object popValue() throws CoreException {
+ protected IJavaValue popValue() throws CoreException {
Object element = fInterpreter.pop();
if (element instanceof IJavaVariable) {
- return ((IJavaVariable) element).getValue();
+ return (IJavaValue) ((IJavaVariable) element).getValue();
}
- return element;
+ return (IJavaValue) element;
}
protected void pushNewValue(boolean value) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java
index e12c865..04249e1 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -11,7 +11,6 @@
package org.eclipse.jdt.internal.debug.eval.ast.instructions;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.jdi.internal.PrimitiveTypeImpl;
import org.eclipse.jdi.internal.VirtualMachineImpl;
@@ -104,9 +103,7 @@
}
IVariable var = createInternalVariable(fName, type);
if (fHasInitializer) {
- Object value = popValue();
- if (value instanceof IValue)
- var.setValue((IValue) value);
+ var.setValue(popValue());
}
}
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java
index ea7764f..2053618 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -17,7 +17,6 @@
import org.eclipse.jdt.debug.core.IJavaObject;
import org.eclipse.jdt.debug.core.IJavaVariable;
import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
-import org.eclipse.jdt.internal.debug.core.model.JDIClassType;
import org.eclipse.jdt.internal.debug.core.model.JDINullValue;
import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
import org.eclipse.jdt.internal.debug.eval.ast.engine.IRuntimeContext;
@@ -56,17 +55,15 @@
JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK,
InstructionsEvaluationMessages.PushFieldVariable_0, null));
}
+ IJavaObject receiver = (IJavaObject) value;
+
IJavaVariable field = null;
- if (value instanceof JDIClassType ) {
- field = ((JDIClassType) value).getField(fName);
- } else if (value instanceof IJavaObject){
- IJavaObject receiver = (IJavaObject) value;
- if (fDeclaringTypeSignature == null) {
- field = ((JDIObjectValue) receiver).getField(fName,
- fSuperClassLevel);
- } else {
- field = receiver.getField(fName, fDeclaringTypeSignature);
- }
+
+ if (fDeclaringTypeSignature == null) {
+ field = ((JDIObjectValue) receiver).getField(fName,
+ fSuperClassLevel);
+ } else {
+ field = receiver.getField(fName, fDeclaringTypeSignature);
}
if (field == null) {
@@ -91,7 +88,7 @@
IStatus.OK,
NLS.bind(InstructionsEvaluationMessages.PushFieldVariable_Cannot_find_the_field__0__for_the_object__1__1,
new String[] { fName,
- value.toString() }),
+ receiver.toString() }),
null)); //
}
push(field);
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java
index cbcd065..02811f9 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -44,9 +44,7 @@
IJavaValue[] args = new IJavaValue[fArgCount];
// args are in reverse order
for (int i = fArgCount - 1; i >= 0; i--) {
- Object popValue = popValue();
- if ((popValue instanceof IJavaValue))
- args[i] = (IJavaValue) popValue;
+ args[i] = popValue();
}
Object receiver = pop();
IJavaValue result = null;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java
index a26c735..75925f7 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -46,9 +46,7 @@
IJavaValue[] args = new IJavaValue[fArgCount];
// args are in reverse order
for (int i = fArgCount - 1; i >= 0; i--) {
- Object popValue = popValue();
- if ((popValue instanceof IJavaValue))
- args[i] = (IJavaValue) popValue;
+ args[i] = popValue();
}
IJavaType receiver = getType(fTypeName);