Bug 428887 - EmptyStackException while inspecting the code
Change-Id: Id3824261ef4bbb74d0c1d5f64f09f6a0cd6946b4
Signed-off-by: Sarika Sinha <sarika.sinha@in.ibm.com>
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 50d4d1a..0efc008 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
@@ -4521,7 +4521,7 @@
return signature;
}
- private int getPrimitiveTypeId(String typeName) {
+ public static int getPrimitiveTypeId(String typeName) {
switch (typeName.charAt(0)) {
case 'b': // byte or boolean
switch (typeName.charAt(1)) {
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 2b677b1..990c22b 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, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -22,6 +22,7 @@
import org.eclipse.jdt.debug.core.IJavaValue;
import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
import org.eclipse.jdt.internal.debug.core.model.JDINullValue;
+import org.eclipse.jdt.internal.debug.eval.ast.engine.ASTInstructionCompiler;
import org.eclipse.osgi.util.NLS;
public class Cast extends CompoundInstruction {
@@ -63,7 +64,11 @@
if (value instanceof IJavaPrimitiveValue) {
IJavaPrimitiveValue primitiveValue = (IJavaPrimitiveValue) value;
- switch (fTypeTypeId) {
+ int newTypeId = fTypeTypeId;
+ if (fTypeTypeId == T_Object) {
+ newTypeId = ASTInstructionCompiler.getPrimitiveTypeId(value.getJavaType().getName());
+ }
+ switch (newTypeId) {
case T_double:
push(newValue(primitiveValue.getDoubleValue()));
break;