-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8280767: -XX:ArchiveClassesAtExit does not archive BoundMethodHandle$…
…Species classes Reviewed-by: iklam, ccheung
- Loading branch information
Showing
7 changed files
with
167 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/CDSLambdaInvoker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2022, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
import java.lang.invoke.MethodHandle; | ||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.MethodType; | ||
|
||
public class CDSLambdaInvoker { | ||
public static void main(String args[]) throws Throwable { | ||
invoke(MethodHandles.identity(double.class), 1.0); | ||
invoke(MethodHandles.identity(long.class), 1); | ||
invoke(MethodHandles.identity(int.class), 1); | ||
invoke(MethodHandles.identity(float.class), 1.0f); | ||
|
||
MethodHandles.Lookup lookup = MethodHandles.lookup(); | ||
MethodType mt = MethodType.methodType(void.class, float.class, double.class, int.class, | ||
boolean.class, Object.class, long.class, double.class); | ||
MethodHandle mh = lookup.findStatic(CDSLambdaInvoker.class, "callme", mt); | ||
mh.invokeExact(4.0f, 5.0, 6, true, (Object)args, 7L, 8.0); | ||
} | ||
|
||
private static Object invoke(MethodHandle mh, Object ... args) throws Throwable { | ||
try { | ||
for (Object o : args) { | ||
mh = MethodHandles.insertArguments(mh, 0, o); | ||
} | ||
return mh.invoke(); | ||
} catch (Throwable t) { | ||
System.out.println("Failed to find, link and/or invoke " + mh.toString() + ": " + t.getMessage()); | ||
throw t; | ||
} | ||
} | ||
|
||
private static void callme(float f, double d, int i, boolean b, Object o, long l, double d2) { | ||
|
||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/TestLambdaInvokers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2022, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @key randomness | ||
* @summary test archive lambda invoker species type in dynamic dump | ||
* @bug 8280767 | ||
* @requires vm.cds | ||
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive | ||
* @compile CDSLambdaInvoker.java | ||
* @build sun.hotspot.WhiteBox | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar cds-test.jar CDSLambdaInvoker | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox | ||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestLambdaInvokers | ||
*/ | ||
|
||
public class TestLambdaInvokers extends DynamicArchiveTestBase { | ||
private static final String mainClass = "CDSLambdaInvoker"; | ||
private static final String jarFile = "cds-test.jar"; | ||
private static void doTest(String topArchiveName) throws Exception { | ||
dump(topArchiveName, | ||
"-Xlog:cds", | ||
"-Xlog:cds+dynamic=debug", | ||
"-cp", | ||
jarFile, | ||
mainClass) | ||
.assertNormalExit(output -> { | ||
output.shouldContain("Skip regenerating for shared"); | ||
}); | ||
run(topArchiveName, | ||
"-Xlog:cds", | ||
"-Xlog:cds+dynamic=debug", | ||
"-Xlog:class+load", | ||
"-cp", | ||
jarFile, | ||
mainClass) | ||
.assertNormalExit(output -> { | ||
// java.lang.invoke.BoundMethodHandle$Species_JL is generated from CDSLambdaInvoker | ||
output.shouldContain("java.lang.invoke.BoundMethodHandle$Species_JL source: shared objects file (top)"); | ||
}); | ||
} | ||
|
||
static void testWithDefaultBase() throws Exception { | ||
String topArchiveName = getNewArchiveName("top"); | ||
doTest(topArchiveName); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
runTest(TestLambdaInvokers::testWithDefaultBase); | ||
} | ||
} |
8e4ef81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues