|
| 1 | +/* |
| 2 | + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +/* |
| 26 | + * @test |
| 27 | + * @bug 8274944 |
| 28 | + * @summary VM should not crash during CDS dump when a lambda proxy class |
| 29 | + * contains an old version of interface. |
| 30 | + * @requires vm.cds |
| 31 | + * @library /test/lib |
| 32 | + * @compile test-classes/OldProvider.jasm |
| 33 | + * @compile test-classes/LambdaContainsOldInfApp.java |
| 34 | + * @run driver LambdaContainsOldInf |
| 35 | + */ |
| 36 | + |
| 37 | +import jdk.test.lib.cds.CDSOptions; |
| 38 | +import jdk.test.lib.cds.CDSTestUtils; |
| 39 | +import jdk.test.lib.process.OutputAnalyzer; |
| 40 | + |
| 41 | +public class LambdaContainsOldInf { |
| 42 | + |
| 43 | + public static void main(String[] args) throws Exception { |
| 44 | + String mainClass = "LambdaContainsOldInfApp"; |
| 45 | + String namePrefix = "lambdacontainsoldinf"; |
| 46 | + JarBuilder.build(namePrefix, mainClass, "OldProvider"); |
| 47 | + |
| 48 | + String appJar = TestCommon.getTestJar(namePrefix + ".jar"); |
| 49 | + String classList = namePrefix + ".list"; |
| 50 | + String archiveName = namePrefix + ".jsa"; |
| 51 | + |
| 52 | + // dump class list |
| 53 | + CDSTestUtils.dumpClassList(classList, "-cp", appJar, mainClass); |
| 54 | + |
| 55 | + // create archive with the class list |
| 56 | + CDSOptions opts = (new CDSOptions()) |
| 57 | + .addPrefix("-XX:ExtraSharedClassListFile=" + classList, |
| 58 | + "-cp", appJar, |
| 59 | + "-Xlog:class+load,cds") |
| 60 | + .setArchiveName(archiveName); |
| 61 | + OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts); |
| 62 | + TestCommon.checkExecReturn(output, 0, true, |
| 63 | + "Skipping OldProvider: Old class has been linked"); |
| 64 | + output.shouldMatch("Skipping.LambdaContainsOldInfApp[$][$]Lambda[$].*0x.*:.*Old.class.has.been.linked"); |
| 65 | + |
| 66 | + // run with archive |
| 67 | + CDSOptions runOpts = (new CDSOptions()) |
| 68 | + .addPrefix("-cp", appJar, "-Xlog:class+load,cds=debug") |
| 69 | + .setArchiveName(archiveName) |
| 70 | + .setUseVersion(false) |
| 71 | + .addSuffix(mainClass); |
| 72 | + output = CDSTestUtils.runWithArchive(runOpts); |
| 73 | + TestCommon.checkExecReturn(output, 0, true, |
| 74 | + "[class,load] LambdaContainsOldInfApp source: shared objects file"); |
| 75 | + output.shouldMatch(".class.load. OldProvider.source:.*lambdacontainsoldinf.jar") |
| 76 | + .shouldMatch(".class.load. LambdaContainsOldInfApp[$][$]Lambda[$].*/0x.*source:.*LambdaContainsOldInf"); |
| 77 | + } |
| 78 | +} |
0 commit comments