Skip to content

Commit

Permalink
Incorporated latest code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SougandhS committed Sep 3, 2024
1 parent c3209f7 commit 2a0a97c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ public static void main(String[] ecs) {
File file = new File(parent,"test");
System.out.println("COMPLETED");
}

}

/////////////////////////////////////////
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
public static final String BOUND_JRE_PROJECT_NAME = "BoundJRE";
public static final String CLONE_SUFFIX = "Clone";

final String[] LAUNCH_CONFIG_NAMES_1_4 = { "java.io.File", "FileConditionSnippet2", "LargeSourceFile", "LotsOfFields",
final String[] LAUNCH_CONFIG_NAMES_1_4 = { "java.io.File", "LargeSourceFile", "LotsOfFields",
"Breakpoints",
"InstanceVariablesTests",
"LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
Expand All @@ -204,7 +204,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
"StepResult2", "StepResult3", "StepUncaught", "TriggerPoint_01", "BulkThreadCreationTest", "MethodExitAndException",
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303", "Bug540243",
"OutSync", "OutSync2", "ConsoleOutputUmlaut", "ErrorRecurrence", "ModelPresentationTests", "Bug565982",
"SuspendVMConditionalBreakpointsTestSnippet" };
"SuspendVMConditionalBreakpointsTestSnippet", "FileConditionSnippet2" };

/**
* the default timeout
Expand Down Expand Up @@ -1539,22 +1539,20 @@ protected IJavaThread launchToLineBreakpoint(String mainTypeName, ILineBreakpoin
*/
protected IJavaThread launchToLineBreakpoint(ILaunchConfiguration config, ILineBreakpoint bp, boolean register) throws Exception {
DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.BREAKPOINT);
waiter.setTimeout(30000);
waiter.setTimeout(DEFAULT_TIMEOUT);
waiter.setEnableUIEventLoopProcessing(enableUIEventLoopProcessingInWaiter());

Object suspendee= launchAndWait(config, waiter, register);
assertTrue("suspendee was not an IJavaThread", suspendee instanceof IJavaThread); //$NON-NLS-1$
IJavaThread thread = (IJavaThread) suspendee;
IBreakpoint hit = getBreakpoint(thread);

assertNotNull("suspended, but not by breakpoint", hit); //$NON-NLS-1$
assertEquals("hit un-registered breakpoint", bp, hit); //$NON-NLS-1$
assertTrue("suspended, but not by line breakpoint", hit instanceof ILineBreakpoint); //$NON-NLS-1$
ILineBreakpoint breakpoint= (ILineBreakpoint) hit;
int lineNumber = breakpoint.getLineNumber();
int stackLine = thread.getTopStackFrame().getLineNumber();
assertEquals("line numbers of breakpoint and stack frame do not match", lineNumber, stackLine); //$NON-NLS-1$

return thread;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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.ConditionalBreakpointsWithFileClass;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithGenerics;
import org.eclipse.jdt.debug.tests.breakpoints.DeferredBreakpointTests;
import org.eclipse.jdt.debug.tests.breakpoints.ExceptionBreakpointTests;
Expand Down Expand Up @@ -392,6 +393,7 @@ public AutomatedSuite() {
addTest(new TestSuite(TestToggleBreakpointsTarget.class));
addTest(new TestSuite(TriggerPointBreakpointsTests.class));
addTest(new TestSuite(JavaThreadEventHandlerTests.class));
addTest(new TestSuite(ConditionalBreakpointsWithFileClass.class));

if (JavaProjectHelper.isJava8Compatible()) {
addTest(new TestSuite(TestToggleBreakpointsTarget8.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,40 @@ public ConditionalBreakpointsWithFileClass(String name) {

public void testFileConditionalBreakpointForTrue() throws Exception {
String typeName = "FileConditionSnippet2";
IJavaLineBreakpoint bp = createLineBreakpoint(7, typeName);
createConditionalLineBreakpoint(374, "java.io.File", "child.equals(\"test\")", true);

IJavaLineBreakpoint bp2 = createLineBreakpoint(7, typeName);
IJavaLineBreakpoint bp = createConditionalLineBreakpoint(374, "java.io.File", "child.equals(\"test\")", true);
IJavaThread mainThread = null;
try {
mainThread = launchToLineBreakpoint(typeName, bp);
mainThread = launchToBreakpoint(typeName);
mainThread.getTopStackFrame().stepInto();
Thread.sleep(100);
mainThread.resume();
Thread.sleep(100);
int hitLine = 0;
if (mainThread.isSuspended()) {
hitLine = mainThread.getStackFrames()[0].getLineNumber();
}
assertTrue("Should hit", (hitLine == 374) && (mainThread.isSuspended() == true));
} finally {
assertTrue("Thread should be suspended", mainThread.isSuspended());
hitLine = mainThread.getStackFrames()[0].getLineNumber();
assertEquals("Should've hit", 374, hitLine);
bp2.delete();
bp.delete();
} finally {
terminateAndRemove(mainThread);
removeAllBreakpoints();
}
}

public void testFileConditionalBreakpointForFalse() throws Exception {
String typeName = "FileConditionSnippet2";
IJavaLineBreakpoint bp = createLineBreakpoint(7, typeName);
createConditionalLineBreakpoint(374, "java.io.File", "child.equals(\"test2\")", true);

IJavaLineBreakpoint bp = createLineBreakpoint(8, typeName);
IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(374, "java.io.File", "child.equals(\"test2\")", true);
IJavaThread mainThread = null;
try {
mainThread = launchToLineBreakpoint(typeName, bp);
mainThread.resume();
Thread.sleep(100);
mainThread = launchToBreakpoint(typeName);
int hitLine = 0;
if (mainThread.isSuspended()) {
hitLine = mainThread.getStackFrames()[0].getLineNumber();
}
assertFalse("Should hit", (hitLine == 374) && (mainThread.isSuspended() == true));
} finally {
hitLine = mainThread.getTopStackFrame().getLineNumber();
assertEquals("Should've hit", 8, hitLine);
bp2.delete();
bp.delete();
} finally {
terminateAndRemove(mainThread);
removeAllBreakpoints();
}
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.debug; singleton:=true
Bundle-Version: 3.21.500.qualifier
Bundle-Version: 3.21.600.qualifier
Bundle-ClassPath: jdimodel.jar
Bundle-Activator: org.eclipse.jdt.internal.debug.core.JDIDebugPlugin
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -690,7 +690,6 @@ private ICompiledExpression createExpressionFromAST(String snippet,
|| problemId == IProblem.UnexpectedStaticModifierForMethod || problemId == IProblem.AmbiguousType) {
continue;
}

if (problem.isError()) {
if (codeSnippetStart <= errorOffset
&& errorOffset <= codeSnippetEnd) {
Expand Down

0 comments on commit 2a0a97c

Please sign in to comment.