1/* 2 * Copyright (c) 2016, 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 24import java.nio.file.Path; 25import java.util.Collection; 26import java.util.List; 27import java.util.stream.Collectors; 28 29import jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin; 30 31import tests.Helper; 32import tests.JImageGenerator; 33import tests.JImageValidator; 34import tests.Result; 35 36 /* 37 * @test 38 * @library ../../lib 39 * @summary Test --generate-jli-classes plugin 40 * @modules java.base/jdk.internal.jimage 41 * jdk.jdeps/com.sun.tools.classfile 42 * jdk.jlink/jdk.tools.jlink.internal 43 * jdk.jlink/jdk.tools.jlink.internal.plugins 44 * jdk.jlink/jdk.tools.jmod 45 * jdk.jlink/jdk.tools.jimage 46 * @build tests.* 47 * @run main/othervm GenerateJLIClassesPluginTest 48 */ 49public class GenerateJLIClassesPluginTest { 50 51 private static Helper helper; 52 53 public static void main(String[] args) throws Exception { 54 helper = Helper.newHelper(); 55 if (helper == null) { 56 System.err.println("Test not run"); 57 return; 58 } 59 60 helper.generateDefaultModules(); 61 62 63 // Test that generate-jli is enabled by default 64 Result result = JImageGenerator.getJLinkTask() 65 .modulePath(helper.defaultModulePath()) 66 .output(helper.createNewImageDir("generate-jli")) 67 .addMods("java.base") 68 .call(); 69 70 Path image = result.assertSuccess(); 71 72 JImageValidator.validate( 73 image.resolve("lib").resolve("modules"), 74 classFilesForSpecies(GenerateJLIClassesPlugin.defaultSpecies()), 75 List.of()); 76 77 } 78 79 private static List<String> classFilesForSpecies(Collection<String> species) { 80 return species.stream() 81 .map(s -> "/java.base/java/lang/invoke/BoundMethodHandle$Species_" + s + ".class") 82 .collect(Collectors.toList()); 83 } 84} 85