mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8335896: Source launcher should set TCCL
Reviewed-by: alanb
This commit is contained in:
parent
b21cb44e38
commit
ad498f57fc
3 changed files with 25 additions and 4 deletions
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8192920 8204588 8246774 8248843 8268869 8235876 8328339
|
||||
* @bug 8192920 8204588 8246774 8248843 8268869 8235876 8328339 8335896
|
||||
* @summary Test source launcher
|
||||
* @library /tools/lib
|
||||
* @enablePreview
|
||||
|
@ -276,6 +276,27 @@ public class SourceLauncherTest extends TestRunner {
|
|||
checkEqual("stdout", log.trim(), file.toAbsolutePath().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThreadContextClassLoader(Path base) throws IOException {
|
||||
tb.writeJavaFiles(base, //language=java
|
||||
"""
|
||||
class ThreadContextClassLoader {
|
||||
public static void main(String... args) {
|
||||
var expected = ThreadContextClassLoader.class.getClassLoader();
|
||||
var actual = Thread.currentThread().getContextClassLoader();
|
||||
System.out.println(expected == actual);
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
Path file = base.resolve("ThreadContextClassLoader.java");
|
||||
String log = new JavaTask(tb)
|
||||
.className(file.toString())
|
||||
.run(Task.Expect.SUCCESS)
|
||||
.getOutput(Task.OutputKind.STDOUT);
|
||||
checkEqual("stdout", log.trim(), "true");
|
||||
}
|
||||
|
||||
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…
Add table
Add a link
Reference in a new issue