Bug 304757 - "Display" during debug: JDIObjectValue cannot be cast to IJavaPrimitiveValue
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
index 42bc2c5..cbd26ef 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
@@ -102,6 +102,7 @@
import org.eclipse.jdt.debug.tests.ui.DetailPaneManagerTests;
import org.eclipse.jdt.debug.tests.ui.ViewMangementTests;
import org.eclipse.jdt.debug.tests.variables.TestInstanceRetrieval;
+import org.eclipse.jdt.debug.tests.variables.TestIntegerAccessUnboxing15;
import org.eclipse.jdt.debug.tests.variables.TestLogicalStructures;
/**
@@ -159,6 +160,7 @@
addTest(new TestSuite(RunToLineTests.class));
if (isJ2SE15Compatible()) {
addTest(new TestSuite(MethodBreakpointTests15.class));
+ addTest(new TestSuite(TestIntegerAccessUnboxing15.class));
}
//Sourcelookup tests
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java
index b3a4bcf..40d4e17 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ProjectCreationDecorator.java
@@ -276,6 +276,7 @@
folder.create(true, true, null);
createLaunchConfiguration(jp, "a.b.c.MethodBreakpoints");
+ createLaunchConfiguration(jp, "a.b.c.IntegerAccess");
}
}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/variables/TestIntegerAccessUnboxing15.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/variables/TestIntegerAccessUnboxing15.java
new file mode 100644
index 0000000..a72f33a
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/variables/TestIntegerAccessUnboxing15.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests.variables;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.eval.EvaluationManager;
+import org.eclipse.jdt.debug.eval.IAstEvaluationEngine;
+import org.eclipse.jdt.debug.eval.IEvaluationListener;
+import org.eclipse.jdt.debug.eval.IEvaluationResult;
+import org.eclipse.jdt.debug.tests.AbstractDebugTest;
+
+/**
+ * Tests that arrays can be accessed with *big* Integers
+ */
+public class TestIntegerAccessUnboxing15 extends AbstractDebugTest {
+
+ public TestIntegerAccessUnboxing15(String name) {
+ super(name);
+ }
+
+ class Listener implements IEvaluationListener {
+
+ private Object lock = new Object();
+ private IEvaluationResult result;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.debug.eval.IEvaluationListener#evaluationComplete(org.eclipse.jdt.debug.eval.IEvaluationResult)
+ */
+ public void evaluationComplete(IEvaluationResult result) {
+ synchronized (lock) {
+ this.result = result;
+ lock.notifyAll();
+ }
+ }
+
+ IEvaluationResult getResult() throws Exception {
+ synchronized (lock) {
+ if (result == null) {
+ lock.wait(DEFAULT_TIMEOUT);
+ }
+ }
+ assertNotNull("Evaluation did not complete", result);
+ return result;
+ }
+
+ }
+
+ public void doAccessTest(String snippet, int expected) throws Exception {
+ IJavaThread thread= null;
+ IAstEvaluationEngine engine = null;
+ String typeName = "a.b.c.IntegerAccess";
+ createLineBreakpoint(get15Project().findType(typeName), 24);
+ try {
+ thread= launchToBreakpoint(get15Project(), typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+
+ IBreakpoint hit = getBreakpoint(thread);
+ assertNotNull("suspended, but not by breakpoint", hit);
+ IJavaDebugTarget target = (IJavaDebugTarget) thread.getDebugTarget();
+
+ IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
+ engine = EvaluationManager.newAstEvaluationEngine(get15Project(), target);
+ Listener listener = new Listener();
+ engine.evaluate(snippet, frame, listener, DebugEvent.EVALUATION, false);
+ IEvaluationResult result = listener.getResult();
+ assertFalse("Should be no errors in evaluation", result.hasErrors());
+ assertEquals(target.newValue(expected), result.getValue());
+ } finally {
+ if (engine != null) {
+ engine.dispose();
+ }
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ /**
+ * Test a row can be accessed
+ *
+ * @throws Exception
+ */
+ public void testRowAccess() throws Exception {
+ doAccessTest("matrix[new Integer(0)][0]", 1);
+ }
+
+ /**
+ * Test a column can be accessed.
+ *
+ * @throws Exception
+ */
+ public void testColumnAccess() throws Exception {
+ doAccessTest("matrix[2][new Integer(2)]", 9);
+ }
+
+ public void testRowColumnAccess() throws Exception {
+ doAccessTest("matrix[1][new Integer(1)]", 5);
+ }
+}
diff --git a/org.eclipse.jdt.debug.tests/testsource-j2se-1.5/a/b/c/IntegerAccess.java b/org.eclipse.jdt.debug.tests/testsource-j2se-1.5/a/b/c/IntegerAccess.java
new file mode 100644
index 0000000..a286eb4
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/testsource-j2se-1.5/a/b/c/IntegerAccess.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package a.b.c;
+
+public class IntegerAccess {
+
+ public static void main(String[] args) {
+ int[][] matrix = new int[3][];
+ for (int i = 0; i < matrix.length; i++) {
+ int[] row = new int[3]; // [1,2,3] [4,5,6] [7,8,9]
+ matrix[i] = row;
+ for (int j = 0; j < row.length; j++) {
+ row[j] = (i * row.length) + j + 1;
+ }
+ }
+ System.out.println(matrix);
+ }
+}
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 b834e1c..a87e4b6 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
@@ -593,6 +593,10 @@
public void endVisit(ArrayAccess node) {
if (!isActive() || hasErrors())
return;
+ if (unBoxing(node.getIndex().resolveTypeBinding())) {
+ // un-box the index, if required
+ storeInstruction();
+ }
storeInstruction();
}