mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-08 09:35:16 +00:00
8209963: source file mode for JVM should provide a hook to locate the source file
Reviewed-by: darcy
This commit is contained in:
parent
065fdac559
commit
db6295f8a2
@ -399,6 +399,7 @@ public class Main {
|
||||
*/
|
||||
private void execute(String mainClassName, String[] appArgs, Context context)
|
||||
throws Fault, InvocationTargetException {
|
||||
System.setProperty("jdk.launcher.sourcefile", context.file.toString());
|
||||
ClassLoader cl = context.getClassLoader(ClassLoader.getSystemClassLoader());
|
||||
try {
|
||||
Class<?> appClass = Class.forName(mainClassName, true, cl);
|
||||
|
||||
@ -250,6 +250,22 @@ public class SourceLauncherTest extends TestRunner {
|
||||
"access denied (\"java.util.PropertyPermission\" \"user.dir\" \"write\")");
|
||||
}
|
||||
|
||||
public void testSystemProperty(Path base) throws IOException {
|
||||
tb.writeJavaFiles(base,
|
||||
"class ShowProperty {\n" +
|
||||
" public static void main(String... args) {\n" +
|
||||
" System.out.println(System.getProperty(\"jdk.launcher.sourcefile\"));\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
|
||||
Path file = base.resolve("ShowProperty.java");
|
||||
String log = new JavaTask(tb)
|
||||
.className(file.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.getOutput(Task.OutputKind.STDOUT);
|
||||
checkEqual("stdout", log.trim(), file.toAbsolutePath().toString());
|
||||
}
|
||||
|
||||
void testSuccess(Path file, String expect) throws IOException {
|
||||
Result r = run(file, Collections.emptyList(), List.of("1", "2", "3"));
|
||||
checkEqual("stdout", r.stdOut, expect);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user