< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java

Print this page

        

*** 97,133 **** * VM paths: * /java.base/native/{architecture}/{server|client|minimal}/{shared lib} * e.g.: /java.base/native/amd64/server/libjvm.so * /java.base/native/server/libjvm.dylib */ ! private List<ResourcePoolEntry> getVMs(ResourcePoolModule javaBase, String jvmlib) { List<ResourcePoolEntry> ret = javaBase.entries().filter((t) -> { return t.path().endsWith("/" + jvmlib); }).collect(Collectors.toList()); return ret; } @Override public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get(); ! String jvmlib = jvmlib(javaBase.descriptor().osName().get()); TreeSet<Jvm> existing = new TreeSet<>(new JvmComparator()); TreeSet<Jvm> removed = new TreeSet<>(new JvmComparator()); if (!keepAll) { // First retrieve all available VM names and removed VM ! List<ResourcePoolEntry> jvms = getVMs(javaBase, jvmlib); for (Jvm jvm : Jvm.values()) { for (ResourcePoolEntry md : jvms) { ! if (md.path().endsWith("/" + jvm.getName() + "/" + jvmlib)) { existing.add(jvm); if (isRemoved(md)) { removed.add(jvm); } } } } } // Check that target exists if (!keepAll) { if (!existing.contains(target)) { throw new PluginException("Selected VM " + target.getName() + " doesn't exist."); } --- 97,140 ---- * VM paths: * /java.base/native/{architecture}/{server|client|minimal}/{shared lib} * e.g.: /java.base/native/amd64/server/libjvm.so * /java.base/native/server/libjvm.dylib */ ! private List<ResourcePoolEntry> getVMs(ResourcePoolModule javaBase, String[] jvmlibs) { List<ResourcePoolEntry> ret = javaBase.entries().filter((t) -> { + String path = t.path(); + for (String jvmlib : jvmlibs) { return t.path().endsWith("/" + jvmlib); + } + return false; }).collect(Collectors.toList()); return ret; } @Override public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get(); ! String[] jvmlibs = jvmlibs(javaBase.descriptor().osName().get()); TreeSet<Jvm> existing = new TreeSet<>(new JvmComparator()); TreeSet<Jvm> removed = new TreeSet<>(new JvmComparator()); if (!keepAll) { // First retrieve all available VM names and removed VM ! List<ResourcePoolEntry> jvms = getVMs(javaBase, jvmlibs); for (Jvm jvm : Jvm.values()) { for (ResourcePoolEntry md : jvms) { ! String mdPath = md.path(); ! for (String jvmlib : jvmlibs) { ! if (mdPath.endsWith("/" + jvm.getName() + "/" + jvmlib)) { existing.add(jvm); if (isRemoved(md)) { removed.add(jvm); } } } } } + } // Check that target exists if (!keepAll) { if (!existing.contains(target)) { throw new PluginException("Selected VM " + target.getName() + " doesn't exist."); }
*** 246,263 **** byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8); return orig.copyWithContent(content); } ! private static String jvmlib(String osName) { ! String lib = "libjvm.so"; if (isWindows(osName)) { ! lib = "jvm.dll"; } else if (isMac(osName)) { ! lib = "libjvm.dylib"; } - return lib; } private static boolean isWindows(String osName) { return osName.startsWith("Windows"); } --- 253,270 ---- byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8); return orig.copyWithContent(content); } ! private static String[] jvmlibs(String osName) { if (isWindows(osName)) { ! return new String[] { "jvm.dll" }; } else if (isMac(osName)) { ! return new String[] { "libjvm.dylib", "libjvm.a" }; ! } else { ! return new String[] { "libjvm.so", "libjvm.a" }; } } private static boolean isWindows(String osName) { return osName.startsWith("Windows"); }
< prev index next >