diff mx/FilterTypes.java @ 21887:543f150e7fa0

com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 22:44:34 +0200
parents b6aadfd3dfbe
children
line wrap: on
line diff
--- a/mx/FilterTypes.java	Tue Jun 09 22:31:05 2015 +0200
+++ b/mx/FilterTypes.java	Tue Jun 09 22:44:34 2015 +0200
@@ -23,41 +23,46 @@
 
 public class FilterTypes {
 
-    /**
-     * Prints to {@link System#out} the values in {@code args[1 .. N]} that denote classes that are
-     * {@link Class#isAssignableFrom(Class) assignable} to the type denoted in {@code args[0]}. The
-     * values are separated by {@code "|"}.
-     */
     public static void main(String... args) throws Exception {
         Class<?> jvmciServiceInterface = Class.forName(args[0]);
-        boolean needSep = false;
         StringBuilder buf = new StringBuilder();
         for (int i = 1; i < args.length; ++i) {
-            String serviceName = args[i];
-            Class<?> service = lookupService(serviceName);
-            if (service != null && jvmciServiceInterface.isAssignableFrom(service)) {
+            String[] e = args[i].split("=");
+            String serviceName = e[0];
+            String implNames = e[1];
+
+            StringBuilder impls = new StringBuilder();
+            for (String implName : implNames.split(",")) {
+                Class<?> impl = lookup(implName);
+                if (impl != null && jvmciServiceInterface.isAssignableFrom(impl)) {
+                    if (impls.length() != 0) {
+                        impls.append(',');
+                    }
+                    impls.append(implName);
+                }
+            }
+            if (impls.length() != 0) {
                 if (buf.length() != 0) {
-                    buf.append('|');
+                    buf.append(' ');
                 }
-                buf.append(serviceName);
-                needSep = true;
+                buf.append(serviceName).append('=').append(impls);
             }
         }
         System.out.print(buf);
     }
-    
-    private static Class<?> lookupService(String serviceName) {
-    	try {
-    		// This can fail in the case of running against a JDK
-    		// with out of date JVMCI jars. In that case, just print
-    		// a warning sinc the expectation is that the jars will be
-    		// updated later on.
-    	    return Class.forName(serviceName, false, FilterTypes.class.getClassLoader());
-    	} catch (ClassNotFoundException e) {
-    		// Must be stderr to avoid polluting the result being
-    		// written to stdout.
-    		System.err.println(e);
-    		return null;
-    	}
+
+    private static Class<?> lookup(String name) {
+        try {
+            // This can fail in the case of running against a JDK
+            // with out of date JVMCI jars. In that case, just print
+            // a warning since the expectation is that the jars will be
+            // updated later on.
+            return Class.forName(name, false, FilterTypes.class.getClassLoader());
+        } catch (ClassNotFoundException e) {
+            // Must be stderr to avoid polluting the result being
+            // written to stdout.
+            System.err.println(e);
+            return null;
+        }
     }
 }