Skip to content

Commit 181a7bb

Browse files
committed
8210927: JDB tests do not update source path after doing a redefine class
Backport-of: 61ac53f6e5a149c6ec68a8df43106e72bfd1ebb2
1 parent bf51354 commit 181a7bb

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

test/jdk/com/sun/jdi/RedefineTTYLineNumber.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@ public static void main(String[] args) {
5959

6060
public class RedefineTTYLineNumber extends JdbTest {
6161

62-
public static void main(String argv[]) {
62+
public static void main(String[] argv) {
6363
new RedefineTTYLineNumber().run();
6464
}
6565

@@ -104,7 +104,7 @@ protected void runCases() {
104104
// so bp2Line should be equals bp1Line-1
105105
Asserts.assertEquals(bp2Line, bp1Line - 1, "BP line numbers");
106106
verifyBPSource(1, bp1Reply);
107-
// uncomment the following line to reproduce JDK-8210927
108-
//verifyBPSource(2, bp2Reply);
107+
// verify source code is printed correctly
108+
verifyBPSource(2, bp2Reply);
109109
}
110110
}

test/jdk/com/sun/jdi/lib/jdb/JdbCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323

2424
package lib.jdb;
2525

26+
import java.io.File;
2627
import java.util.Arrays;
2728
import java.util.regex.Pattern;
2829
import java.util.stream.Collectors;
@@ -275,4 +276,8 @@ public static JdbCommand pop() {
275276
public static JdbCommand redefine(String classId, String classFileName) {
276277
return new JdbCommand("redefine " + classId + " " + classFileName);
277278
}
279+
280+
public static JdbCommand use(String... sourcePath) {
281+
return new JdbCommand("use " + String.join(File.pathSeparator, sourcePath));
282+
}
278283
}

test/jdk/com/sun/jdi/lib/jdb/JdbTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -198,14 +198,17 @@ protected int setBreakpoints(int id) {
198198
return setBreakpointsFromTestSource(launchOptions.sourceFilename, id);
199199
}
200200

201-
// transforms class with the specified id (see {@code ClassTransformer})
202-
// and executes "redefine" jdb command for {@code launchOptions.debuggeeClass}.
203-
// returns reply for the command.
201+
// transforms class with the specified id (see {@code ClassTransformer}),
202+
// executes "redefine" jdb command for {@code launchOptions.debuggeeClass}
203+
// and updates source path by using "use" jdb command.
204+
// returns reply for the commands.
204205
protected List<String> redefineClass(int id, String... compilerOptions) {
205206
verifySourceFilename();
206207
String transformedClassFile = ClassTransformer.fromTestSource(launchOptions.sourceFilename)
207208
.transform(id, launchOptions.debuggeeClass, compilerOptions);
208-
return jdb.command(JdbCommand.redefine(launchOptions.debuggeeClass, transformedClassFile));
209+
List<String> reply = jdb.command(JdbCommand.redefine(launchOptions.debuggeeClass, transformedClassFile));
210+
reply.addAll(jdb.command(JdbCommand.use(Paths.get(transformedClassFile).getParent().toString())));
211+
return reply;
209212
}
210213

211214
// gets full test source path for the given test filename

0 commit comments

Comments
 (0)