aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Moller2014-01-29 10:19:05 (EST)
committerMike Rennie2014-03-07 12:14:12 (EST)
commit0e7ea755f49c065f8670dc57215dd03760f62180 (patch)
treee8016c9321244c67fd926ffa03286f4e7c7acdc2
parenteee984121ca5ddb2885b61196c0cb99e9f4bfbdd (diff)
downloadeclipse.jdt.debug-0e7ea755f49c065f8670dc57215dd03760f62180.zip
eclipse.jdt.debug-0e7ea755f49c065f8670dc57215dd03760f62180.tar.gz
eclipse.jdt.debug-0e7ea755f49c065f8670dc57215dd03760f62180.tar.bz2
Bug 422029 - [1.8] Enable debug evaluation support for default methods
Change-Id: If2aa61dc5ceca87b1aa820de490344b304433fbf Signed-off-by: Jesper Moller <jesper@selskabet.org>
-rw-r--r--org.eclipse.jdt.debug.tests/java8/EvalTest18.java24
-rw-r--r--org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java13
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java63
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/EvalTestSuite.java9
-rw-r--r--org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java64
-rw-r--r--org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIObjectValue.java18
6 files changed, 182 insertions, 9 deletions
diff --git a/org.eclipse.jdt.debug.tests/java8/EvalTest18.java b/org.eclipse.jdt.debug.tests/java8/EvalTest18.java
new file mode 100644
index 0000000..e7f148e
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/java8/EvalTest18.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Jesper Steen Møller 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
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * Jesper Steen Møller - initial API and implementation
+ *******************************************************************************/
+
+import java.util.Arrays;
+import java.util.List;
+
+public class EvalTest18 {
+ public static void main(String[] args) {
+ List<String> strings = Arrays.asList("One", "Two", "Three");
+ System.out.println("Count of strings in stream from array =" + strings.stream().count());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java b/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java
index 947f314..e47d0b8 100644
--- a/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java
+++ b/org.eclipse.jdt.debug.tests/test plugin/org/eclipse/jdt/debug/testplugin/JavaProjectHelper.java
@@ -1,12 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 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
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S. Møller - bug 422029: [1.8] Enable debug evaluation support for default methods
*******************************************************************************/
package org.eclipse.jdt.debug.testplugin;
@@ -71,6 +76,10 @@ public class JavaProjectHelper {
* path to the 1.7 test source
*/
public static final IPath TEST_1_7_SRC_DIR= new Path("java7");
+ /**
+ * path to the 1.8 test source
+ */
+ public static final IPath TEST_1_8_SRC_DIR= new Path("java8");
/**
* path to the compiler error java file
@@ -109,7 +118,7 @@ public class JavaProjectHelper {
/**
* Returns if the current running system is compatible with the given Java minor version
*
- * @param ver the version to test - either 4, 5, 6 or 7
+ * @param ver the version to test - either 4, 5, 6, 7 or 8
* @return <code>true</code> if compatible <code>false</code> otherwise
*/
static boolean isCompatible(int ver) {
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java
index a6a1231..0007d10 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java
@@ -1,13 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 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
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
- * Jesper Steen Moller - bug 341232
+ * Jesper Steen Møller - bug 422029: [1.8] Enable debug evaluation support for default methods
+ * Jesper Steen Møller - bug 341232
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
@@ -173,6 +178,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
public static final String ONE_FOUR_PROJECT_CLOSED_NAME = "ClosedDebugTests";
public static final String ONE_FIVE_PROJECT_NAME = "OneFive";
public static final String ONE_SEVEN_PROJECT_NAME = "OneSeven";
+ public static final String ONE_EIGHT_PROJECT_NAME = "OneEight";
public static final String BOUND_JRE_PROJECT_NAME = "BoundJRE";
final String[] LAUNCH_CONFIG_NAMES_1_4 = {"LargeSourceFile", "LotsOfFields", "Breakpoints", "InstanceVariablesTests", "LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
@@ -187,7 +193,9 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
"bug329294", "bug401270", "org.eclipse.debug.tests.targets.HcrClass2", "org.eclipse.debug.tests.targets.HcrClass3", "org.eclipse.debug.tests.targets.HcrClass4",
"org.eclipse.debug.tests.targets.HcrClass5", "org.eclipse.debug.tests.targets.HcrClass6", "org.eclipse.debug.tests.targets.HcrClass7", "org.eclipse.debug.tests.targets.HcrClass8",
"org.eclipse.debug.tests.targets.HcrClass9"};
-
+
+ final String[] LAUNCH_CONFIG_NAMES_1_8 = {"LargeSourceFile"};
+
/**
* the default timeout
*/
@@ -217,6 +225,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
private static boolean loaded14 = false;
private static boolean loaded15 = false;
private static boolean loaded17 = false;
+ private static boolean loaded18 = false;
private static boolean loadedEE = false;
private static boolean loadedJRE = false;
private static boolean loadedMulti = false;
@@ -247,6 +256,8 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
loaded15 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONE_SEVEN_PROJECT_NAME);
loaded17 = pro.exists();
+ pro = ResourcesPlugin.getWorkspace().getRoot().getProject(ONE_EIGHT_PROJECT_NAME);
+ loaded18 = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(BOUND_JRE_PROJECT_NAME);
loadedJRE = pro.exists();
pro = ResourcesPlugin.getWorkspace().getRoot().getProject(BOUND_EE_PROJECT_NAME);
@@ -432,6 +443,36 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
}
/**
+ * Creates the Java 1.8 compliant project
+ */
+ synchronized void assert18Project() {
+ IJavaProject jp = null;
+ ArrayList<ILaunchConfiguration> cfgs = new ArrayList<ILaunchConfiguration>(1);
+ try {
+ if (!loaded18) {
+ jp = createProject(ONE_EIGHT_PROJECT_NAME, JavaProjectHelper.TEST_1_8_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
+ cfgs.add(createLaunchConfiguration(jp, "EvalTest18"));
+ loaded18 = true;
+ waitForBuild();
+ }
+ }
+ catch(Exception e) {
+ try {
+ if(jp != null) {
+ jp.getProject().delete(true, true, null);
+ for (int i = 0; i < cfgs.size(); i++) {
+ cfgs.get(i).delete();
+ }
+ }
+ }
+ catch (CoreException ce) {
+ //ignore
+ }
+ handleProjectCreationException(e, ONE_SEVEN_PROJECT_NAME, jp);
+ }
+ }
+
+ /**
* Creates the 'BoundJRE' project used for the JRE testing
*/
synchronized void assertBoundJreProject() {
@@ -678,6 +719,16 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
assert17Project();
return getJavaProject(ONE_SEVEN_PROJECT_NAME);
}
+
+ /**
+ * Returns the 'OneSeven' project.
+ *
+ * @return the test project
+ */
+ protected IJavaProject get18Project() {
+ assert18Project();
+ return getJavaProject(ONE_EIGHT_PROJECT_NAME);
+ }
/**
* Returns the 'BoundJRE' project
@@ -2619,7 +2670,11 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
while(listener.getResult() == null && System.currentTimeMillis() < timeout) {
Thread.sleep(100);
}
- assertFalse("The evaluation should not have errors", listener.getResult().hasErrors());
+ IEvaluationResult result = listener.getResult();
+ assertNull("The evaluation should not have exception : " + result.getException(), result.getException());
+
+ String firstError = result.hasErrors() ? result.getErrorMessages()[0] : "";
+ assertFalse("The evaluation should not have errors : " + firstError, result.hasErrors());
return listener.getResult().getValue();
}
finally {
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/EvalTestSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/EvalTestSuite.java
index 33b3958..75423af 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/EvalTestSuite.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/EvalTestSuite.java
@@ -1,12 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S. Møller - bug 422029: [1.8] Enable debug evaluation support for default methods
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
@@ -32,6 +37,7 @@ import org.eclipse.jdt.debug.tests.eval.FloatAssignmentOperatorsTests;
import org.eclipse.jdt.debug.tests.eval.FloatOperatorsTests;
import org.eclipse.jdt.debug.tests.eval.IntAssignmentOperatorsTests;
import org.eclipse.jdt.debug.tests.eval.IntOperatorsTests;
+import org.eclipse.jdt.debug.tests.eval.Java8Tests;
import org.eclipse.jdt.debug.tests.eval.LabelTests;
import org.eclipse.jdt.debug.tests.eval.LocalVarAssignmentTests;
import org.eclipse.jdt.debug.tests.eval.LocalVarValueTests;
@@ -125,6 +131,7 @@ public class EvalTestSuite extends TestSuite {
public EvalTestSuite() {
addTest(new TestSuite(ProjectCreationDecorator.class));
// Tests included in the automated suite
+ addTest(new TestSuite(Java8Tests.class));
addTest(new TestSuite(TestsOperators1.class));
addTest(new TestSuite(TestsOperators2.class));
addTest(new TestSuite(TestsArrays.class));
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java
new file mode 100644
index 0000000..3fd1042
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Jesper S. Møller 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
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * Jesper S. Møller - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.debug.tests.eval;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.tests.AbstractDebugTest;
+
+/**
+ * Group of tests that evaluate operations involving generics
+ *
+ * @since 3.8
+ */
+public class Java8Tests extends AbstractDebugTest {
+
+ /**
+ * @param name
+ */
+ public Java8Tests(String name) {
+ super(name);
+ }
+
+ @Override
+ protected IJavaProject getProjectContext() {
+ return get18Project();
+ }
+
+ /**
+ * Evaluates a generified snippet with a simple single
+ * generic statement
+ *
+ * @throws Exception
+ */
+ public void testEvalDefaultMethod() throws Exception {
+ IJavaThread thread = null;
+ try {
+ String type = "EvalTest18";
+ createLineBreakpoint(22, type);
+ thread = launchToBreakpoint(type);
+ assertNotNull("The program did not suspend", thread);
+ String snippet = "strings.stream()";
+ doEval(thread, snippet);
+ }
+ finally {
+ removeAllBreakpoints();
+ terminateAndRemove(thread);
+ }
+ }
+
+
+}
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIObjectValue.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIObjectValue.java
index 4bd90d5..45808de 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIObjectValue.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIObjectValue.java
@@ -1,12 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jesper S. Møller - bug 422029: [1.8] Enable debug evaluation support for default methods
*******************************************************************************/
package org.eclipse.jdt.internal.debug.core.model;
@@ -26,6 +31,7 @@ import com.sun.jdi.ArrayType;
import com.sun.jdi.ClassType;
import com.sun.jdi.Field;
import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.InterfaceType;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
@@ -150,8 +156,16 @@ public class JDIObjectValue extends JDIValue implements IJavaObject {
private Method concreteMethodByName(ReferenceType refType, String selector,
String signature) throws DebugException {
if (refType instanceof ClassType) {
- return ((ClassType) refType).concreteMethodByName(selector,
+ Method m = ((ClassType) refType).concreteMethodByName(selector,
signature);
+ if (m != null) return m;
+
+ for (InterfaceType iface : ((ClassType) refType).allInterfaces()) {
+ List<Method> matches = iface.methodsByName(selector, signature);
+ for (Method ifaceMethod : matches) {
+ if (! ifaceMethod.isAbstract()) return ifaceMethod;
+ }
+ }
}
if (refType instanceof ArrayType) {
// the jdi spec specifies that all methods on methods return an