changeset 21635:b311a60991da

more graceful failure in context of stale mx-deployed JDK jars
author Doug Simon <doug.simon@oracle.com>
date Mon, 01 Jun 2015 15:01:34 +0200
parents 0a2fc09f6ed6
children 6d9c8d0d0f7c
files mx/FilterTypes.java mx/mx_graal.py
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mx/FilterTypes.java	Mon Jun 01 15:24:37 2015 +0200
+++ b/mx/FilterTypes.java	Mon Jun 01 15:01:34 2015 +0200
@@ -34,7 +34,7 @@
         StringBuilder buf = new StringBuilder();
         for (int i = 1; i < args.length; ++i) {
             String serviceName = args[i];
-            Class<?> service = Class.forName(serviceName, false, FilterTypes.class.getClassLoader());
+            Class<?> service = lookupService(serviceName);
             if (jvmciServiceInterface.isAssignableFrom(service)) {
                 if (buf.length() != 0) {
                     buf.append('|');
@@ -45,4 +45,18 @@
         }
         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);
+    	}
+    }
 }
--- a/mx/mx_graal.py	Mon Jun 01 15:24:37 2015 +0200
+++ b/mx/mx_graal.py	Mon Jun 01 15:01:34 2015 +0200
@@ -555,7 +555,7 @@
     """
     _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__))
     cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serviceImplNames
-    services = subprocess.check_output(cmd, stderr=subprocess.PIPE)
+    services = subprocess.check_output(cmd)
     if len(services) == 0:
         return []
     return services.split('|')