comparison mx/FilterTypes.java @ 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 60154926b513
children b6aadfd3dfbe
comparison
equal deleted inserted replaced
21634:0a2fc09f6ed6 21635:b311a60991da
32 Class<?> jvmciServiceInterface = Class.forName(args[0]); 32 Class<?> jvmciServiceInterface = Class.forName(args[0]);
33 boolean needSep = false; 33 boolean needSep = false;
34 StringBuilder buf = new StringBuilder(); 34 StringBuilder buf = new StringBuilder();
35 for (int i = 1; i < args.length; ++i) { 35 for (int i = 1; i < args.length; ++i) {
36 String serviceName = args[i]; 36 String serviceName = args[i];
37 Class<?> service = Class.forName(serviceName, false, FilterTypes.class.getClassLoader()); 37 Class<?> service = lookupService(serviceName);
38 if (jvmciServiceInterface.isAssignableFrom(service)) { 38 if (jvmciServiceInterface.isAssignableFrom(service)) {
39 if (buf.length() != 0) { 39 if (buf.length() != 0) {
40 buf.append('|'); 40 buf.append('|');
41 } 41 }
42 buf.append(serviceName); 42 buf.append(serviceName);
43 needSep = true; 43 needSep = true;
44 } 44 }
45 } 45 }
46 System.out.print(buf); 46 System.out.print(buf);
47 } 47 }
48
49 private static Class<?> lookupService(String serviceName) {
50 try {
51 // This can fail in the case of running against a JDK
52 // with out of date JVMCI jars. In that case, just print
53 // a warning sinc the expectation is that the jars will be
54 // updated later on.
55 return Class.forName(serviceName, false, FilterTypes.class.getClassLoader());
56 } catch (ClassNotFoundException e) {
57 // Must be stderr to avoid polluting the result being
58 // written to stdout.
59 System.err.println(e);
60 }
61 }
48 } 62 }