Skip to content
Commits on Source (5)
eclipse-jdt-debug (4.11-1) unstable; urgency=medium
* New upstream release
- Depend on libeclipse-debug-core-java (>= 3.13.200)
* Standards-Version updated to 4.4.0
-- Emmanuel Bourg <ebourg@apache.org> Thu, 11 Jul 2019 17:49:42 +0200
eclipse-jdt-debug (4.10-2) unstable; urgency=medium
* Fixed the dependencies of libeclipse-jdt-debug-ui-java (Closes: #917975)
......
......@@ -15,7 +15,7 @@ Build-Depends:
libeclipse-core-resources-java,
libeclipse-core-runtime-java,
libeclipse-core-variables-java,
libeclipse-debug-core-java (>= 3.13),
libeclipse-debug-core-java (>= 3.13.200),
libeclipse-debug-ui-java (>= 3.13.100),
libeclipse-jdt-core-java (>= 3.15),
libeclipse-jdt-core-manipulation-java,
......@@ -36,7 +36,7 @@ Build-Depends:
libequinox-registry-java,
libicu4j-java,
libswt-gtk-4-java
Standards-Version: 4.3.0
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/eclipse-jdt-debug.git
Vcs-Browser: https://salsa.debian.org/java-team/eclipse-jdt-debug
Homepage: https://projects.eclipse.org/projects/eclipse.jdt.debug
......@@ -111,7 +111,7 @@ Depends:
libeclipse-core-resources-java,
libeclipse-core-runtime-java,
libeclipse-core-variables-java,
libeclipse-debug-core-java (>= 3.13),
libeclipse-debug-core-java (>= 3.13.200),
libeclipse-jdt-core-java (>= 3.15),
libequinox-common-java,
libequinox-preferences-java,
......
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.debug.tests; singleton:=true
Bundle-Version: 3.11.300.qualifier
Bundle-Version: 3.11.400.qualifier
Bundle-ClassPath: javadebugtests.jar
Bundle-Activator: org.eclipse.jdt.debug.testplugin.JavaTestPlugin
Bundle-Vendor: %providerName
......
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
import java.util.function.Consumer;
public class Bug404097BreakpointInAnonymousLocalClass {
public static void breakpointMethod(final String methodParameter) {
// StringBuilder to make sure the compiler doesn't optimize "methodVariable" out of the compiled code.
final StringBuilder methodVariable = new StringBuilder("methodVariable");
Consumer<String> r = new Consumer<String>() {
public void accept(String lambdaParameter) {
String lambdaVariable = "lambdaVariable";
System.out.println("method parameter: " + methodParameter);
System.out.println("method variable: " + methodVariable);
System.out.println("lambda parameter: " + lambdaParameter);
System.out.println("lambda variable: " + lambdaVariable);
}
};
r.accept("lambdaParameter");
}
public static void main(String[] args) {
breakpointMethod("methodParameter");
}
}
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
import java.util.function.Consumer;
public class Bug404097BreakpointInLambda {
public static void breakpointMethod(final String methodParameter) {
// StringBuilder to make sure the compiler doesn't optimize "methodVariable" out of the compiled code.
final StringBuilder methodVariable = new StringBuilder("methodVariable");
Consumer<String> r = lambdaParameter -> {
String lambdaVariable = "lambdaVariable";
System.out.println("method parameter: " + methodParameter);
System.out.println("method variable: " + methodVariable);
System.out.println("lambda parameter: " + lambdaParameter);
System.out.println("lambda variable: " + lambdaVariable);
};
r.accept("lambdaParameter");
}
public static void main(String[] args) {
breakpointMethod("methodParameter");
}
}
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
import java.util.function.Consumer;
public class Bug404097BreakpointInLocalClass {
public static void breakpointMethod(final String methodParameter) {
// StringBuilder to make sure the compiler doesn't optimize "methodVariable" out of the compiled code.
final StringBuilder methodVariable = new StringBuilder("methodVariable");
class SomeConsumer implements Consumer<String> {
public void accept(String lambdaParameter) {
String lambdaVariable = "lambdaVariable";
System.out.println("method parameter: " + methodParameter);
System.out.println("method variable: " + methodVariable);
System.out.println("lambda parameter: " + lambdaParameter);
System.out.println("lambda variable: " + lambdaVariable);
}
};
Consumer<String> r = new SomeConsumer();
r.accept("lambdaParameter");
}
public static void main(String[] args) {
breakpointMethod("methodParameter");
}
}
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
public class Bug404097BreakpointUsingInnerClass {
static class InnerClass {
int i;
}
public static void breakpointMethod() {
InnerClass object = new InnerClass();
object.i = 0;
System.out.println(object.i);
}
public static void main(String[] args) {
breakpointMethod();
}
}
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
public class Bug404097BreakpointUsingLocalClass {
public static void breakpointMethod() {
class LocalClass {
int i;
}
LocalClass object = new LocalClass();
object.i = 0;
System.out.println(object.i);
}
public static void main(String[] args) {
breakpointMethod();
}
}
/*******************************************************************************
* Copyright (c) 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Paul Pazderski - initial API and implementation
*******************************************************************************/
public class ClosureVariableTest_Bug542989 {
public static void main(String[] args) {
java.io.PrintStream out = System.out;
java.util.function.Consumer<String> printer = (msg) -> {
out.println(msg); //set breakpoint here
};
printer.accept("Hallo World!");
}
}
......@@ -14,11 +14,11 @@
<parent>
<artifactId>eclipse.jdt.debug</artifactId>
<groupId>eclipse.jdt.debug</groupId>
<version>4.10.0-SNAPSHOT</version>
<version>4.11.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.debug.tests</artifactId>
<version>3.11.300-SNAPSHOT</version>
<version>3.11.400-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<code.ignoredWarnings>${tests.ignoredWarnings}</code.ignoredWarnings>
......
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
public class Bug540243 {
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(new Runnable() {
// method must be synchronized, so that the thread owns a monitor
public synchronized void run() {
breakpointMethod();
}
});
t.start();
t.join();
}
public static void breakpointMethod() {
System.out.println("set a breakpoint here");
}
}
......@@ -36,7 +36,6 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
......@@ -207,7 +206,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
"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", "TestContributedStepFilterClass", "TerminateAll_01", "TerminateAll_02", "StepResult1",
"StepResult2", "StepResult3", "StepUncaught", "TriggerPoint_01", "BulkThreadCreationTest", "MethodExitAndException",
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303" };
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303", "Bug540243" };
/**
* the default timeout
......@@ -470,6 +469,12 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
cfgs.add(createLaunchConfiguration(jp, "EvalIntfSuperDefault"));
cfgs.add(createLaunchConfiguration(jp, "DebugHoverTest18"));
cfgs.add(createLaunchConfiguration(jp, "Bug541110"));
cfgs.add(createLaunchConfiguration(jp, "ClosureVariableTest_Bug542989"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointInLocalClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointInAnonymousLocalClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointInLambda"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointUsingInnerClass"));
cfgs.add(createLaunchConfiguration(jp, "Bug404097BreakpointUsingLocalClass"));
loaded18 = true;
waitForBuild();
}
......@@ -2828,8 +2833,15 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
}
protected void assertNoErrorMarkersExist() throws Exception {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
IJavaProject javaProject = getProjectContext();
assertNotNull("Java test project cannot be null", javaProject);
IProject project = javaProject.getProject();
assertNotNull("test project cannot be null", project);
IProject[] projects = { project };
assertNoErrorMarkersExist(projects);
}
protected void assertNoErrorMarkersExist(IProject[] projects) throws Exception {
for (IProject project : projects) {
assertNoErrorMarkersExist(project);
}
......
......@@ -23,6 +23,7 @@ import org.eclipse.jdt.debug.testplugin.JavaProjectHelper;
import org.eclipse.jdt.debug.tests.breakpoints.BreakpointListenerTests;
import org.eclipse.jdt.debug.tests.breakpoints.BreakpointLocationVerificationTests;
import org.eclipse.jdt.debug.tests.breakpoints.BreakpointWorkingSetTests;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsInJava8Tests;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsTests;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithGenerics;
import org.eclipse.jdt.debug.tests.breakpoints.DeferredBreakpointTests;
......@@ -31,6 +32,7 @@ import org.eclipse.jdt.debug.tests.breakpoints.HitCountBreakpointsTests;
import org.eclipse.jdt.debug.tests.breakpoints.ImportBreakpointsTest;
import org.eclipse.jdt.debug.tests.breakpoints.JavaBreakpointListenerTests;
import org.eclipse.jdt.debug.tests.breakpoints.JavaThreadEventHandlerTests;
import org.eclipse.jdt.debug.tests.breakpoints.LambdaBreakpointsInJava8Tests;
import org.eclipse.jdt.debug.tests.breakpoints.MethodBreakpointTests;
import org.eclipse.jdt.debug.tests.breakpoints.MethodBreakpointTests15;
import org.eclipse.jdt.debug.tests.breakpoints.MiscBreakpointsTests;
......@@ -131,6 +133,7 @@ import org.eclipse.jdt.debug.tests.ui.DetailPaneManagerTests;
import org.eclipse.jdt.debug.tests.ui.OpenFromClipboardTests;
import org.eclipse.jdt.debug.tests.ui.ViewManagementTests;
import org.eclipse.jdt.debug.tests.ui.presentation.ModelPresentationTests;
import org.eclipse.jdt.debug.tests.ui.presentation.ModelPresentationTests18;
import org.eclipse.jdt.debug.tests.variables.DetailFormatterTests;
import org.eclipse.jdt.debug.tests.variables.TestAnonymousInspect;
import org.eclipse.jdt.debug.tests.variables.TestInstanceRetrieval;
......@@ -347,6 +350,9 @@ public class AutomatedSuite extends DebugSuite {
if (JavaProjectHelper.isJava8Compatible()) {
addTest(new TestSuite(TestToggleBreakpointsTarget8.class));
addTest(new TestSuite(ModelPresentationTests18.class));
addTest(new TestSuite(ConditionalBreakpointsInJava8Tests.class));
addTest(new TestSuite(LambdaBreakpointsInJava8Tests.class));
}
if (JavaProjectHelper.isJava5Compatible()) {
addTest(new TestSuite(MethodBreakpointTests15.class));
......
/*******************************************************************************
* Copyright (c) 2000, 2015 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
......@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Paul Pazderski - Bug 544133: signal end of test runner in any case
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
......@@ -31,7 +32,6 @@ public abstract class DebugSuite extends TestSuite {
*/
protected boolean fTesting = true;
/**
* Construct the test suite.
*/
......@@ -52,6 +52,7 @@ public abstract class DebugSuite extends TestSuite {
Runnable r = new Runnable() {
@Override
public void run() {
try {
for (Enumeration<Test> e= tests(); e.hasMoreElements(); ) {
if (result.shouldStop()) {
break;
......@@ -59,11 +60,13 @@ public abstract class DebugSuite extends TestSuite {
Test test= e.nextElement();
runTest(test, result);
}
} finally {
fTesting = false;
display.wake();
}
}
};
thread = new Thread(r);
thread = new Thread(r, "Test Runner");
thread.start();
} catch (Exception e) {
e.printStackTrace();
......@@ -79,6 +82,4 @@ public abstract class DebugSuite extends TestSuite {
}
}
}
}
......@@ -13,25 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
import java.util.Enumeration;
import org.eclipse.jdt.debug.tests.core.RemoteJavaApplicationTests;
import org.eclipse.swt.widgets.Display;
import junit.framework.Test;
import junit.framework.TestResult;
import junit.framework.TestSuite;
/**
* Tests that are to be run manually by the debug team, in addition to
* automated tests.
*/
public class ManualSuite extends TestSuite {
/**
* Flag that indicates test are in progress
*/
protected boolean fTesting = true;
public class ManualSuite extends DebugSuite {
/**
* Returns the suite. This is required to
......@@ -55,48 +46,5 @@ public class ManualSuite extends TestSuite {
addTest(new TestSuite(RemoteJavaApplicationTests.class));
}
/**
* Runs the tests and collects their result in a TestResult.
* The debug tests cannot be run in the UI thread or the event
* waiter blocks the UI when a resource changes.
* @see junit.framework.TestSuite#run(junit.framework.TestResult)
*/
@Override
public void run(final TestResult result) {
final Display display = Display.getCurrent();
Thread thread = null;
try {
Runnable r = new Runnable() {
@Override
public void run() {
for (Enumeration<Test> e= tests(); e.hasMoreElements(); ) {
if (result.shouldStop() ) {
break;
}
Test test= e.nextElement();
runTest(test, result);
}
fTesting = false;
display.wake();
}
};
thread = new Thread(r);
thread.start();
} catch (Exception e) {
e.printStackTrace();
}
while (fTesting) {
try {
if (!display.readAndDispatch()) {
display.sleep();
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.debug.tests.breakpoints;
import java.util.Arrays;
import java.util.List;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.testplugin.DebugEventWaiter;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
import org.eclipse.jdt.debug.tests.TestUtil;
/**
* Tests conditional breakpoints.
*/
public class ConditionalBreakpointsInJava8Tests extends AbstractDebugTest {
public ConditionalBreakpointsInJava8Tests(String name) {
super(name);
}
@Override
protected IJavaProject getProjectContext() {
return get18Project();
}
@Override
protected void setUp() throws Exception {
super.setUp();
assertNoErrorMarkersExist();
}
@Override
protected void tearDown() throws Exception {
terminateAndRemoveJavaLaunches();
removeAllBreakpoints();
super.tearDown();
}
/**
* Test for Bug 541110 - ClassCastException in Instruction.popValue and a zombie EventDispatcher$1 job afterwards
*
* We check that a specific conditional breakpoint on a line with a lambda expression does not cause a {@link ClassCastException}.
*/
public void testBug541110() throws Exception {
String typeName = "Bug541110";
String breakpointCondition = "map.get(key) != null";
int breakpointLineNumber = 22;
// The class cast exception causes a job which runs forever. So we will timeout when waiting for debug events, if the exception occurs.
assertNoBreakpointHit(typeName, breakpointLineNumber, breakpointCondition);
}
/**
* Test for Bug 541110 - Cannot display or set conditional breakpoint using local class reference or field
*
* We check that a conditional breakpoint inside a locally defined anonymous class can access visbile variables.
*/
public void testBug404097BreakpointInAnonymousLocalClass() throws Exception {
String typeName = "Bug404097BreakpointInAnonymousLocalClass";
int breakpointLineNumber = 25;
doTestVariableVisibility(typeName, breakpointLineNumber);
}
/**
* Test for Bug 541110 - Cannot display or set conditional breakpoint using local class reference or field
*
* We check that a conditional breakpoint inside a lambda can access visible variables.
*/
public void testBug404097BreakpointInLambda() throws Exception {
String typeName = "Bug404097BreakpointInLambda";
int breakpointLineNumber = 24;
doTestVariableVisibility(typeName, breakpointLineNumber);
}
/**
* Test for Bug 541110 - Cannot display or set conditional breakpoint using local class reference or field
*
* We check that a conditional breakpoint inside a locally defined class can access visible variables.
*/
public void testBug404097BreakpointInLocalClass() throws Exception {
String typeName = "Bug404097BreakpointInLocalClass";
int breakpointLineNumber = 25;
doTestVariableVisibility(typeName, breakpointLineNumber);
}
/**
* Test for Bug 541110 - Cannot display or set conditional breakpoint using local class reference or field
*
* We check that a conditional breakpoint can access members of a static inner class.
*/
public void testBug404097BreakpointUsingInnerClass() throws Exception {
String typeName = "Bug404097BreakpointUsingInnerClass";
int breakpointLineNumber = 24;
doTestClassMemberVisibility(typeName, breakpointLineNumber);
}
/**
* Test for Bug 541110 - Cannot display or set conditional breakpoint using local class reference or field
*
* We check that a conditional breakpoint can access members of a class which is defined locally.
*
* TODO: disabled until a fix is available
*/
public void disabled_testBug404097BreakpointUsingLocalClass() throws Exception {
String typeName = "Bug404097BreakpointUsingLocalClass";
int breakpointLineNumber = 23;
doTestClassMemberVisibility(typeName, breakpointLineNumber);
}
private void doTestVariableVisibility(String typeName, int breakpointLineNumber) throws Exception {
/*
* We create a condition which does not evaluate to true and expect to not hit the breakpoint.
* If condition evaluation runs into a compile error, either the breakpoint becomes unconditional and is therefore always hit.
*/
String breakpointCondition = String.join(" || ", Arrays.asList(
"!\"methodParameter\".equals(methodParameter)",
"methodVariable == null", "!\"methodVariable\".equals(methodVariable.toString())",
"!\"lambdaParameter\".equals(lambdaParameter)",
"!\"lambdaVariable\".equals(lambdaVariable)"));
assertNoBreakpointHit(typeName, breakpointLineNumber, breakpointCondition);
}
private void doTestClassMemberVisibility(String typeName, int breakpointLineNumber) throws Exception {
/*
* We create a condition which does not evaluate to true and expect to not hit the breakpoint. If condition evaluation runs into a compile
* error, the breakpoint becomes unconditional and is therefore always hit.
*/
String breakpointCondition = "object.i != 0";
assertNoBreakpointHit(typeName, breakpointLineNumber, breakpointCondition);
}
private void assertNoBreakpointHit(String typeName, int breakpointLineNumber, String breakpointCondition) throws Exception {
boolean suspendOnTrue = true;
createConditionalLineBreakpoint(breakpointLineNumber, typeName, breakpointCondition, suspendOnTrue);
ILaunchConfiguration config = getLaunchConfiguration(typeName);
DebugEventWaiter waiter = new DebugTargetTerminateWaiter();
launchAndWait(config, waiter);
TestUtil.waitForJobs(getName(), 1_000, 30_000, ProcessConsole.class);
}
private void terminateAndRemoveJavaLaunches() {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
List<ILaunch> launches = Arrays.asList(launchManager.getLaunches());
for (ILaunch launch : launches) {
IDebugTarget debugTarget = launch.getDebugTarget();
if (debugTarget instanceof IJavaDebugTarget) {
terminateAndRemove((IJavaDebugTarget) debugTarget);
}
}
}
private static class DebugTargetTerminateWaiter extends DebugEventWaiter {
public DebugTargetTerminateWaiter() {
super(DebugEvent.TERMINATE);
}
@Override
public boolean accept(DebugEvent event) {
if (super.accept(event)) {
Object source = event.getSource();
return source instanceof IDebugTarget;
}
return false;
}
}
}
/*******************************************************************************
* Copyright (c) 2018 Simeon Andreev and others.
* Copyright (c) 2019 Andrey Loskutov and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
......@@ -9,36 +9,31 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
* Andrey Loskutov - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.debug.tests.breakpoints;
import java.util.Arrays;
import java.util.List;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.testplugin.DebugEventWaiter;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
import org.eclipse.jdt.debug.tests.TestUtil;
/**
* Tests conditional breakpoints.
* Tests lambda breakpoints.
*/
public class LambdaBreakpointsTests extends AbstractDebugTest {
public class LambdaBreakpointsInJava8Tests extends AbstractDebugTest {
/**
* Constructor
* @param name
*/
public LambdaBreakpointsTests(String name) {
public LambdaBreakpointsInJava8Tests(String name) {
super(name);
}
......@@ -47,27 +42,62 @@ public class LambdaBreakpointsTests extends AbstractDebugTest {
return get18Project();
}
@Override
protected void setUp() throws Exception {
super.setUp();
assertNoErrorMarkersExist();
}
@Override
protected void tearDown() throws Exception {
terminateAndRemoveJavaLaunches();
removeAllBreakpoints();
super.tearDown();
}
/**
* Test for Bug 541110 - ClassCastException in Instruction.popValue and a zombie EventDispatcher$1 job afterwards
*
* We check that a specific conditional breakpoint on a line with a lambda expression does not cause a {@link ClassCastException}.
* Test for bug 543385 - we should stop multiple times on same line with many lambdas
*/
public void testBug541110() throws Exception {
assertNoErrorMarkersExist();
public void testBug541110_unconditional() throws Exception {
String typeName = "Bug541110";
int breakpointLineNumber = 22;
IJavaLineBreakpoint bp = createLineBreakpoint(breakpointLineNumber, typeName);
IJavaThread thread = null;
try {
thread = launchToLineBreakpoint(typeName, bp);
thread.resume();
// now we should stop again in the lambda
TestUtil.waitForJobs(getName(), 1000, DEFAULT_TIMEOUT, ProcessConsole.class);
assertTrue("Thread should be suspended", thread.isSuspended());
} finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
/**
* Test for bug 543385/541110 - we should stop only once if there is a condition.
*
* Note: if we implement proper lambda debugging support some time later, this test will probably fail.
*/
public void testBug541110_conditional() throws Exception {
String typeName = "Bug541110";
createConditionalLineBreakpoint(22, typeName, "map.get(key) != null", true);
String breakpointCondition = "true";
int breakpointLineNumber = 22;
IJavaLineBreakpoint bp = createConditionalLineBreakpoint(breakpointLineNumber, typeName, breakpointCondition, true);
IJavaThread thread = null;
try {
// The class cast exception causes a job which runs forever. So we will timeout when waiting for debug events, if the exception occurs.
ILaunchConfiguration config = getLaunchConfiguration(typeName);
DebugEventWaiter waiter = new DebugEventWaiter(DebugEvent.TERMINATE);
launchAndWait(config, waiter);
// Join running jobs in case the launch did go through, but we have the endless job.
TestUtil.waitForJobs(getName(), 1_000, 30_000, ProcessConsole.class);
thread = launchToLineBreakpoint(typeName, bp);
thread.resume();
// now we should NOT stop again in the lambda (a more complex condition would most likely fail)
TestUtil.waitForJobs(getName(), 1000, DEFAULT_TIMEOUT, ProcessConsole.class);
assertTrue("Thread should be suspended", thread.isTerminated());
} finally {
terminateAndRemoveJavaLaunches();
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
......@@ -82,4 +112,5 @@ public class LambdaBreakpointsTests extends AbstractDebugTest {
}
}
}
}
......@@ -21,16 +21,20 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.debug.ui.console.IConsoleLineTrackerExtension;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
import org.eclipse.jdt.debug.core.JDIDebugModel;
import org.eclipse.jdt.debug.testplugin.ConsoleLineTracker;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.internal.debug.ui.console.JavaExceptionHyperLink;
import org.eclipse.jdt.internal.debug.ui.console.JavaStackTraceHyperlink;
import org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
......@@ -182,6 +186,77 @@ public class LineTrackerTests extends AbstractDebugTest implements IConsoleLineT
}
}
public void testJavaExceptionHyperLink() throws Exception {
ConsoleLineTracker.setDelegate(this);
fTarget = null;
IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
boolean suspendOnException = jdiUIPreferences.getBoolean(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS);
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS, false);
try {
fTarget = launchAndTerminate("ThrowsNPE");
synchronized (fLock) {
if (!fStopped) {
fLock.wait(30000);
}
}
assertTrue("Never received 'start' notification", fStarted);
assertTrue("Never received 'stopped' notification", fStopped);
assertTrue("Console should be an IOCosnole", fConsole instanceof IOConsole);
IOConsole console = (IOConsole) fConsole;
IHyperlink[] hyperlinks = console.getHyperlinks();
// should be 1 exception hyperlink
int total = 0;
for (int i = 0; i < hyperlinks.length; i++) {
IHyperlink hyperlink = hyperlinks[i];
if (hyperlink instanceof JavaExceptionHyperLink) {
total++;
// should be followed by a stack trace hyperlink
assertTrue("Stack trace hyperlink missing", hyperlinks[i + 1] instanceof JavaStackTraceHyperlink);
}
}
assertEquals("Wrong number of exception hyperlinks", 1, total);
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(JDIDebugModel.getPluginIdentifier());
IJavaExceptionBreakpoint foundBreakpoint = null;
for (int i = 0; i < breakpoints.length; i++) {
IBreakpoint breakpoint = breakpoints[i];
if (breakpoint instanceof IJavaExceptionBreakpoint) {
IJavaExceptionBreakpoint exceptionBreakpoint = (IJavaExceptionBreakpoint) breakpoint;
if ("java.lang.NullPointerException".equals(exceptionBreakpoint.getTypeName())) {
foundBreakpoint = exceptionBreakpoint;
break;
}
}
}
assertTrue("NPE breakpoint should not exist yet", foundBreakpoint == null);
IJavaExceptionBreakpoint ex = createExceptionBreakpoint("java.lang.NullPointerException", true, false);
ex.setEnabled(false);
JavaExceptionHyperLink exLink = (JavaExceptionHyperLink) hyperlinks[0];
exLink.linkActivated();
breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(JDIDebugModel.getPluginIdentifier());
foundBreakpoint = null;
for (int i = 0; i < breakpoints.length; i++) {
IBreakpoint breakpoint = breakpoints[i];
if (breakpoint instanceof IJavaExceptionBreakpoint) {
IJavaExceptionBreakpoint exceptionBreakpoint = (IJavaExceptionBreakpoint) breakpoint;
if ("java.lang.NullPointerException".equals(exceptionBreakpoint.getTypeName())) {
foundBreakpoint = exceptionBreakpoint;
break;
}
}
}
assertTrue("NPE breakpoint not found", foundBreakpoint != null);
assertTrue("NPE breakpoint not enabled", foundBreakpoint.isEnabled());
assertTrue("NPE breakpoint cancel enablement value not false", foundBreakpoint.getMarker().getAttribute(JavaBreakpointPage.ATTR_ENABLED_SETTING_ON_CANCEL, "").equals("false"));
} finally {
ConsoleLineTracker.setDelegate(null);
jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS, suspendOnException);
terminateAndRemove(fTarget);
}
}
/**
* @see org.eclipse.debug.ui.console.IConsoleLineTracker#dispose()
*/
......
......@@ -55,13 +55,15 @@ public abstract class AbstractDebugViewTests extends AbstractDebugUiTests {
}
private LaunchView debugView;
private boolean showMonitorsOriginal;
private Boolean showMonitorsOriginal;
private Boolean showSystemThreadsOriginal;
@Override
protected void setUp() throws Exception {
super.setUp();
IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
showMonitorsOriginal = jdiUIPreferences.getBoolean(IJavaDebugUIConstants.PREF_SHOW_MONITOR_THREAD_INFO);
showSystemThreadsOriginal = jdiUIPreferences.getBoolean(IJavaDebugUIConstants.PREF_SHOW_SYSTEM_THREADS);
jdiUIPreferences.setValue(IJavaDebugUIConstants.PREF_SHOW_MONITOR_THREAD_INFO, true);
resetPerspective(DebugViewPerspectiveFactory.ID);
debugView = sync(() -> (LaunchView) getActivePage().showView(IDebugUIConstants.ID_DEBUG_VIEW));
......@@ -72,6 +74,7 @@ public abstract class AbstractDebugViewTests extends AbstractDebugUiTests {
protected void tearDown() throws Exception {
IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
jdiUIPreferences.setValue(IJavaDebugUIConstants.PREF_SHOW_MONITOR_THREAD_INFO, showMonitorsOriginal);
jdiUIPreferences.setValue(IJavaDebugUIConstants.PREF_SHOW_SYSTEM_THREADS, showSystemThreadsOriginal);
sync(() -> getActivePage().closeAllEditors(false));
processUiEvents(100);
super.tearDown();
......@@ -118,6 +121,7 @@ public abstract class AbstractDebugViewTests extends AbstractDebugUiTests {
try {
thread = launchToBreakpoint(typeName, breakpointMethodName, expectedBreakpointHitsCount);
assertDebugViewIsOpen();
assertStackFrameIsSelected(breakpointMethodName);
} catch (AssertionError assertionError) {
failedAssertions.add(assertionError);
......@@ -272,8 +276,13 @@ public abstract class AbstractDebugViewTests extends AbstractDebugUiTests {
sync(() -> getActivePage().activate(debugView));
}
protected void assertDebugViewIsOpen() throws Exception {
debugView = sync(() -> (LaunchView) getActivePage().findView(IDebugUIConstants.ID_DEBUG_VIEW));
assertNotNull("expected Debug View to be open", debugView);
}
protected void assertDebugViewIsActive() throws Exception {
assertEquals("expected Debug View to activate after resuming thread", debugView, sync(() -> getActivePage().getActivePart()));
assertEquals("expected Debug View to be activate", debugView, sync(() -> getActivePage().getActivePart()));
}
protected static class BreakpointWaiter extends DebugElementKindEventDetailWaiter {
......
......@@ -17,9 +17,13 @@ import java.util.Arrays;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jdt.debug.core.IJavaStackFrame;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.tests.TestAgainException;
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.test.OrderedTestSuite;
import org.eclipse.ui.IViewPart;
......@@ -193,6 +197,36 @@ public class DebugViewTests extends AbstractDebugViewTests {
}
}
/**
* Test for Bug 540243 - Wrong selection when first opening view due to breakpoint
*
* When hitting a breakpoint, if the Debug View is open at all, and we show Java thread owned monitors, its possible to see a wrong selection in
* the Debug View. To ensure this doesn't occur, this test does the following:
*
* <ol>
* <li>ensures the Debug View is showing owned monitors for threads</li>
* <li>close the Debug View</li>
* <li>create a Java snippet which starts a thread</li>
* <li>set a break point in the code executed by the thread</li>
* <li>debug the snippet until the break point is reached</li>
* <li>validate that the selection in the Debug View contains is exactly the method with a break point</li>
* </ol>
*/
public void testWrongSelectionBug540243() throws Exception {
IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
Boolean isShowingMonitorThreadInfo = jdiUIPreferences.getBoolean(IJavaDebugUIConstants.PREF_SHOW_MONITOR_THREAD_INFO);
assertNotNull("Preference to show thread owned monitors must be set but is not", isShowingMonitorThreadInfo);
assertTrue("Preference to show thread owned monitors must be enabled but is not", isShowingMonitorThreadInfo);
sync(() -> getActivePage().hideView(getActivePage().findView(IDebugUIConstants.ID_DEBUG_VIEW)));
int iterations = 1;
String typeName = "Bug540243";
String breakpointMethodName = "breakpointMethod";
int expectedBreakpointHitsCount = 1;
doTestWrongSelection(iterations, typeName, breakpointMethodName, expectedBreakpointHitsCount);
}
/**
* Test for Bug 534319 - Debug View shows wrong information due to threads with short lifetime
*
......