Skip to content

Commit 52dbfa9

Browse files
sormurascalvinccheung
authored andcommitted
8286460: Remove dependence on JAR filename in CDS tests
Reviewed-by: ccheung, iklam
1 parent 9073a98 commit 52dbfa9

14 files changed

+28
-126
lines changed

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/CDSMHTest_generate.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2020, 2022, 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
@@ -102,14 +102,7 @@ public class $i extends DynamicArchiveTestBase {
102102
String verifyOpt =
103103
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
104104
105-
String[] classPaths = javaClassPath.split(File.pathSeparator);
106-
String junitJar = null;
107-
for (String path : classPaths) {
108-
if (path.endsWith("junit.jar")) {
109-
junitJar = path;
110-
break;
111-
}
112-
}
105+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
113106
114107
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
115108
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesAsCollectorTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -70,14 +70,7 @@ static void testImpl() throws Exception {
7070
String verifyOpt =
7171
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7272

73-
String[] classPaths = javaClassPath.split(File.pathSeparator);
74-
String junitJar = null;
75-
for (String path : classPaths) {
76-
if (path.endsWith("junit.jar")) {
77-
junitJar = path;
78-
break;
79-
}
80-
}
73+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8174

8275
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
8376
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesCastFailureTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -70,14 +70,7 @@ static void testImpl() throws Exception {
7070
String verifyOpt =
7171
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7272

73-
String[] classPaths = javaClassPath.split(File.pathSeparator);
74-
String junitJar = null;
75-
for (String path : classPaths) {
76-
if (path.endsWith("junit.jar")) {
77-
junitJar = path;
78-
break;
79-
}
80-
}
73+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8174

8275
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
8376
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesGeneralTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -70,14 +70,7 @@ static void testImpl() throws Exception {
7070
String verifyOpt =
7171
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7272

73-
String[] classPaths = javaClassPath.split(File.pathSeparator);
74-
String junitJar = null;
75-
for (String path : classPaths) {
76-
if (path.endsWith("junit.jar")) {
77-
junitJar = path;
78-
break;
79-
}
80-
}
73+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8174

8275
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
8376
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesInvokersTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -70,14 +70,7 @@ static void testImpl() throws Exception {
7070
String verifyOpt =
7171
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7272

73-
String[] classPaths = javaClassPath.split(File.pathSeparator);
74-
String junitJar = null;
75-
for (String path : classPaths) {
76-
if (path.endsWith("junit.jar")) {
77-
junitJar = path;
78-
break;
79-
}
80-
}
73+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8174

8275
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
8376
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesPermuteArgumentsTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -70,14 +70,7 @@ static void testImpl() throws Exception {
7070
String verifyOpt =
7171
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7272

73-
String[] classPaths = javaClassPath.split(File.pathSeparator);
74-
String junitJar = null;
75-
for (String path : classPaths) {
76-
if (path.endsWith("junit.jar")) {
77-
junitJar = path;
78-
break;
79-
}
80-
}
73+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8174

8275
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
8376
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesSpreadArgumentsTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -70,14 +70,7 @@ static void testImpl() throws Exception {
7070
String verifyOpt =
7171
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7272

73-
String[] classPaths = javaClassPath.split(File.pathSeparator);
74-
String junitJar = null;
75-
for (String path : classPaths) {
76-
if (path.endsWith("junit.jar")) {
77-
junitJar = path;
78-
break;
79-
}
80-
}
73+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8174

8275
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
8376
"-cp", appJar + ps + junitJar, verifyOpt,

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2020, 2022, 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
@@ -106,14 +106,7 @@ public class $i {
106106
String verifyOpt =
107107
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
108108
109-
String[] classPaths = javaClassPath.split(File.pathSeparator);
110-
String junitJar = null;
111-
for (String path : classPaths) {
112-
if (path.endsWith("junit.jar")) {
113-
junitJar = path;
114-
break;
115-
}
116-
}
109+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
117110
118111
String jars = appJar + ps + junitJar;
119112

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -74,14 +74,7 @@ static void testImpl() throws Exception {
7474
String verifyOpt =
7575
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7676

77-
String[] classPaths = javaClassPath.split(File.pathSeparator);
78-
String junitJar = null;
79-
for (String path : classPaths) {
80-
if (path.endsWith("junit.jar")) {
81-
junitJar = path;
82-
break;
83-
}
84-
}
77+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8578

8679
String jars = appJar + ps + junitJar;
8780

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesCastFailureTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -74,14 +74,7 @@ static void testImpl() throws Exception {
7474
String verifyOpt =
7575
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7676

77-
String[] classPaths = javaClassPath.split(File.pathSeparator);
78-
String junitJar = null;
79-
for (String path : classPaths) {
80-
if (path.endsWith("junit.jar")) {
81-
junitJar = path;
82-
break;
83-
}
84-
}
77+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8578

8679
String jars = appJar + ps + junitJar;
8780

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesGeneralTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -74,14 +74,7 @@ static void testImpl() throws Exception {
7474
String verifyOpt =
7575
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7676

77-
String[] classPaths = javaClassPath.split(File.pathSeparator);
78-
String junitJar = null;
79-
for (String path : classPaths) {
80-
if (path.endsWith("junit.jar")) {
81-
junitJar = path;
82-
break;
83-
}
84-
}
77+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8578

8679
String jars = appJar + ps + junitJar;
8780

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesInvokersTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -74,14 +74,7 @@ static void testImpl() throws Exception {
7474
String verifyOpt =
7575
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7676

77-
String[] classPaths = javaClassPath.split(File.pathSeparator);
78-
String junitJar = null;
79-
for (String path : classPaths) {
80-
if (path.endsWith("junit.jar")) {
81-
junitJar = path;
82-
break;
83-
}
84-
}
77+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8578

8679
String jars = appJar + ps + junitJar;
8780

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesPermuteArgumentsTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -74,14 +74,7 @@ static void testImpl() throws Exception {
7474
String verifyOpt =
7575
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7676

77-
String[] classPaths = javaClassPath.split(File.pathSeparator);
78-
String junitJar = null;
79-
for (String path : classPaths) {
80-
if (path.endsWith("junit.jar")) {
81-
junitJar = path;
82-
break;
83-
}
84-
}
77+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8578

8679
String jars = appJar + ps + junitJar;
8780

test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesSpreadArgumentsTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2022, 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
@@ -74,14 +74,7 @@ static void testImpl() throws Exception {
7474
String verifyOpt =
7575
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
7676

77-
String[] classPaths = javaClassPath.split(File.pathSeparator);
78-
String junitJar = null;
79-
for (String path : classPaths) {
80-
if (path.endsWith("junit.jar")) {
81-
junitJar = path;
82-
break;
83-
}
84-
}
77+
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
8578

8679
String jars = appJar + ps + junitJar;
8780

0 commit comments

Comments
 (0)