Skip to content

Commit 7394536

Browse files
authored
Fix conditional breakpoint not working in File class #273
Handles all the exception caused while evaluating conditional breakpoint java.io.File class #273
1 parent 2b23ef9 commit 7394536

File tree

6 files changed

+215
-204
lines changed

6 files changed

+215
-204
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
import java.io.File;
15+
16+
public class FileConditionSnippet2 {
17+
public static void main(String[] ecs) {
18+
int i = 0;
19+
File parent = new File("parent");
20+
File file = new File(parent,"test");
21+
System.out.println("COMPLETED");
22+
}
23+
}

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
184184
public static final String BOUND_JRE_PROJECT_NAME = "BoundJRE";
185185
public static final String CLONE_SUFFIX = "Clone";
186186

187-
final String[] LAUNCH_CONFIG_NAMES_1_4 = {"LargeSourceFile", "LotsOfFields", "Breakpoints", "InstanceVariablesTests", "LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
187+
final String[] LAUNCH_CONFIG_NAMES_1_4 = { "LargeSourceFile", "LotsOfFields",
188+
"Breakpoints",
189+
"InstanceVariablesTests",
190+
"LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
188191
"DropTests", "ThrowsNPE", "ThrowsException", "org.eclipse.debug.tests.targets.Watchpoint",
189192
"org.eclipse.debug.tests.targets.BreakpointsLocationBug344984", "org.eclipse.debug.tests.targets.CallLoop", "A",
190193
"HitCountLooper", "CompileError", "MultiThreadedLoop", "HitCountException", "MultiThreadedException", "MultiThreadedList", "MethodLoop", "StepFilterOne",
@@ -201,7 +204,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
201204
"StepResult2", "StepResult3", "StepUncaught", "TriggerPoint_01", "BulkThreadCreationTest", "MethodExitAndException",
202205
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303", "Bug540243",
203206
"OutSync", "OutSync2", "ConsoleOutputUmlaut", "ErrorRecurrence", "ModelPresentationTests", "Bug565982",
204-
"SuspendVMConditionalBreakpointsTestSnippet" };
207+
"SuspendVMConditionalBreakpointsTestSnippet", "FileConditionSnippet2" };
205208

206209
/**
207210
* the default timeout
@@ -1553,7 +1556,6 @@ protected IJavaThread launchToLineBreakpoint(ILaunchConfiguration config, ILineB
15531556
int lineNumber = breakpoint.getLineNumber();
15541557
int stackLine = thread.getTopStackFrame().getLineNumber();
15551558
assertEquals("line numbers of breakpoint and stack frame do not match", lineNumber, stackLine); //$NON-NLS-1$
1556-
15571559
return thread;
15581560
}
15591561

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.jdt.debug.tests.breakpoints.BreakpointWorkingSetTests;
2727
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsInJava8Tests;
2828
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsTests;
29+
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithFileClass;
2930
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithGenerics;
3031
import org.eclipse.jdt.debug.tests.breakpoints.DeferredBreakpointTests;
3132
import org.eclipse.jdt.debug.tests.breakpoints.ExceptionBreakpointTests;
@@ -394,6 +395,7 @@ public AutomatedSuite() {
394395
addTest(new TestSuite(TestToggleBreakpointsTarget.class));
395396
addTest(new TestSuite(TriggerPointBreakpointsTests.class));
396397
addTest(new TestSuite(JavaThreadEventHandlerTests.class));
398+
addTest(new TestSuite(ConditionalBreakpointsWithFileClass.class));
397399

398400
if (JavaProjectHelper.isJava8Compatible()) {
399401
addTest(new TestSuite(TestToggleBreakpointsTarget8.class));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation -- initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.jdt.debug.tests.breakpoints;
15+
16+
import org.eclipse.jdt.core.IJavaProject;
17+
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
18+
import org.eclipse.jdt.debug.core.IJavaThread;
19+
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
20+
21+
public class ConditionalBreakpointsWithFileClass extends AbstractDebugTest {
22+
23+
24+
public ConditionalBreakpointsWithFileClass(String name) {
25+
super(name);
26+
}
27+
28+
@Override
29+
protected IJavaProject getProjectContext() {
30+
return get14Project();
31+
}
32+
33+
public void testFileConditionalBreakpointforFalse() throws Exception {
34+
String typeName = "FileConditionSnippet2";
35+
IJavaLineBreakpoint bp3 = createLineBreakpoint(20, typeName);
36+
IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(364, "java.io.File", "false", true);
37+
IJavaThread mainThread = null;
38+
try {
39+
Thread.sleep(10);
40+
mainThread = launchToBreakpoint(typeName);
41+
int hitLine = 0;
42+
assertTrue("Thread should be suspended", mainThread.isSuspended());
43+
hitLine = mainThread.getStackFrames()[0].getLineNumber();
44+
assertEquals("Didn't suspend at the expected line", 20, hitLine);
45+
46+
bp2.delete();
47+
bp3.delete();
48+
} finally {
49+
terminateAndRemove(mainThread);
50+
removeAllBreakpoints();
51+
}
52+
}
53+
54+
public void testFileConditionalBreakpointforTrue() throws Exception {
55+
String typeName = "FileConditionSnippet2";
56+
IJavaLineBreakpoint bp3 = createLineBreakpoint(20, typeName);
57+
IJavaThread mainThread = null;
58+
59+
try {
60+
Thread.sleep(10);
61+
mainThread = launchToBreakpoint(typeName);
62+
mainThread.getTopStackFrame().stepInto();
63+
IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(364, "java.io.File", "true", true);
64+
int hitLine = 0;
65+
mainThread.resume();
66+
Thread.sleep(1000);
67+
assertTrue("Thread should be suspended", mainThread.isSuspended());
68+
hitLine = mainThread.getStackFrames()[0].getLineNumber();
69+
assertEquals("Didn't suspend at the expected line", 364, hitLine);
70+
71+
bp2.delete();
72+
bp3.delete();
73+
} finally {
74+
terminateAndRemove(mainThread);
75+
removeAllBreakpoints();
76+
}
77+
}
78+
79+
}

0 commit comments

Comments
 (0)