Skip to content

Commit

Permalink
8286510: Tests under dynamicArchive/methodHandles should check for lo…
Browse files Browse the repository at this point in the history
…ading of lambda proxy classes

Reviewed-by: iklam
  • Loading branch information
calvinccheung committed Feb 7, 2023
1 parent 74485a3 commit 53f72ed
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 29 deletions.
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -31,7 +31,7 @@ do
fname="$i$name_suffix"
cat << EOF > $fname
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -94,6 +94,9 @@ public class $i extends DynamicArchiveTestBase {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "$i";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.$i[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";
static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -104,10 +107,20 @@ public class $i extends DynamicArchiveTestBase {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";
String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;
dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});
run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}
EOF
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -62,6 +62,9 @@ public void test() throws Exception {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "MethodHandlesAsCollectorTest";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.MethodHandlesAsCollectorTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";

static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -72,9 +75,19 @@ static void testImpl() throws Exception {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";

String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;

dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});

run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});

dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -62,6 +62,9 @@ public void test() throws Exception {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "MethodHandlesCastFailureTest";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.MethodHandlesCastFailureTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";

static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -72,9 +75,19 @@ static void testImpl() throws Exception {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";

String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;

dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});

run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});

dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -62,6 +62,9 @@ public void test() throws Exception {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "MethodHandlesGeneralTest";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.MethodHandlesGeneralTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";

static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -72,9 +75,19 @@ static void testImpl() throws Exception {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";

String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;

dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});

run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});

dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -62,6 +62,9 @@ public void test() throws Exception {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "MethodHandlesInvokersTest";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.MethodHandlesInvokersTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";

static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -72,9 +75,19 @@ static void testImpl() throws Exception {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";

String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;

dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});

run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});

dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -62,6 +62,9 @@ public void test() throws Exception {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "MethodHandlesPermuteArgumentsTest";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.MethodHandlesPermuteArgumentsTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";

static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -72,9 +75,19 @@ static void testImpl() throws Exception {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";

String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;

dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});

run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});

dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
Expand Down Expand Up @@ -62,6 +62,9 @@ public void test() throws Exception {
private static final String ps = System.getProperty("path.separator");
private static final String testPackageName = "test.java.lang.invoke";
private static final String testClassName = "MethodHandlesSpreadArgumentsTest";
private static final String loggingOpts = "-Xlog:cds,cds+dynamic=debug,class+load=trace";
private static final String lambdaLoadedFromArchive =
".class.load. test.java.lang.invoke.MethodHandlesSpreadArgumentsTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)";

static void testImpl() throws Exception {
String topArchiveName = getNewArchiveName();
Expand All @@ -72,9 +75,19 @@ static void testImpl() throws Exception {
Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-showversion";

String junitJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
String jars = appJar + ps + junitJar;
String className = testPackageName + "." + testClassName;

dump(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldContain("Written dynamic archive 0x");
});

run(topArchiveName, loggingOpts, "-cp", jars, verifyOpt, mainClass, className)
.assertNormalExit(output -> {
output.shouldMatch(lambdaLoadedFromArchive)
.shouldHaveExitValue(0);
});

dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
"-cp", appJar + ps + junitJar, verifyOpt,
mainClass, testPackageName + "." + testClassName);
}
}

1 comment on commit 53f72ed

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.