< prev index next >

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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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.  Oracle designates this

@@ -33,10 +33,12 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeSet;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
+
+import jdk.tools.jlink.internal.Platform;
 import jdk.tools.jlink.plugin.Plugin;
 import jdk.tools.jlink.plugin.ResourcePool;
 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
 import jdk.tools.jlink.plugin.ResourcePoolModule;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;

@@ -113,11 +115,11 @@
     }
 
     @Override
     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
         ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get();
-        String[] jvmlibs = jvmlibs(javaBase.osName());
+        String[] jvmlibs = jvmlibs(javaBase);
         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);

@@ -255,23 +257,17 @@
         byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8);
 
         return orig.copyWithContent(content);
     }
 
-    private static String[] jvmlibs(String osName) {
-        if (isWindows(osName)) {
+    private static String[] jvmlibs(ResourcePoolModule module) {
+        Platform platform = Platform.getTargetPlatform(module);
+        switch (platform) {
+            case WINDOWS:
             return new String[] { "jvm.dll" };
-        } else if (isMac(osName)) {
+            case MACOS:
             return new String[] { "libjvm.dylib", "libjvm.a" };
-        } else {
+            default:
             return new String[] { "libjvm.so", "libjvm.a" };
         }
     }
-
-    private static boolean isWindows(String osName) {
-        return osName.startsWith("Windows");
-    }
-
-    private static boolean isMac(String osName) {
-        return osName.startsWith("Mac OS") || osName.startsWith("Darwin");
-    }
 }
< prev index next >