8210927: JDB tests do not update source path after doing a redefine class

Reviewed-by: sspitsyn
This commit is contained in:
Alex Menkov 2021-09-24 21:50:39 +00:00
parent 341de49f8f
commit 61ac53f6e5
3 changed files with 18 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -59,7 +59,7 @@ class RedefineTTYLineNumberTarg {
public class RedefineTTYLineNumber extends JdbTest {
public static void main(String argv[]) {
public static void main(String[] argv) {
new RedefineTTYLineNumber().run();
}
@ -104,7 +104,7 @@ public class RedefineTTYLineNumber extends JdbTest {
// so bp2Line should be equals bp1Line-1
Asserts.assertEquals(bp2Line, bp1Line - 1, "BP line numbers");
verifyBPSource(1, bp1Reply);
// uncomment the following line to reproduce JDK-8210927
//verifyBPSource(2, bp2Reply);
// verify source code is printed correctly
verifyBPSource(2, bp2Reply);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,7 @@
package lib.jdb;
import java.io.File;
import java.util.Arrays;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -275,4 +276,8 @@ public class JdbCommand {
public static JdbCommand redefine(String classId, String classFileName) {
return new JdbCommand("redefine " + classId + " " + classFileName);
}
public static JdbCommand use(String... sourcePath) {
return new JdbCommand("use " + String.join(File.pathSeparator, sourcePath));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -198,14 +198,17 @@ public abstract class JdbTest {
return setBreakpointsFromTestSource(launchOptions.sourceFilename, id);
}
// transforms class with the specified id (see {@code ClassTransformer})
// and executes "redefine" jdb command for {@code launchOptions.debuggeeClass}.
// returns reply for the command.
// transforms class with the specified id (see {@code ClassTransformer}),
// executes "redefine" jdb command for {@code launchOptions.debuggeeClass}
// and updates source path by using "use" jdb command.
// returns reply for the commands.
protected List<String> redefineClass(int id, String... compilerOptions) {
verifySourceFilename();
String transformedClassFile = ClassTransformer.fromTestSource(launchOptions.sourceFilename)
.transform(id, launchOptions.debuggeeClass, compilerOptions);
return jdb.command(JdbCommand.redefine(launchOptions.debuggeeClass, transformedClassFile));
List<String> reply = jdb.command(JdbCommand.redefine(launchOptions.debuggeeClass, transformedClassFile));
reply.addAll(jdb.command(JdbCommand.use(Paths.get(transformedClassFile).getParent().toString())));
return reply;
}
// gets full test source path for the given test filename