annotate mx/FilterTypes.java @ 21886:b1234c06ea49

removed timestamp from "unknown" Graal version string
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 22:31:05 +0200
parents b6aadfd3dfbe
children 543f150e7fa0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24 public class FilterTypes {
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 /**
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 * Prints to {@link System#out} the values in {@code args[1 .. N]} that denote classes that are
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 * {@link Class#isAssignableFrom(Class) assignable} to the type denoted in {@code args[0]}. The
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 * values are separated by {@code "|"}.
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 */
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 public static void main(String... args) throws Exception {
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 Class<?> jvmciServiceInterface = Class.forName(args[0]);
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 boolean needSep = false;
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 StringBuilder buf = new StringBuilder();
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 for (int i = 1; i < args.length; ++i) {
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 String serviceName = args[i];
21635
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
37 Class<?> service = lookupService(serviceName);
21638
b6aadfd3dfbe fixed compile error in FilterTypes.java
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
38 if (service != null && jvmciServiceInterface.isAssignableFrom(service)) {
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 if (buf.length() != 0) {
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 buf.append('|');
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 }
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 buf.append(serviceName);
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 needSep = true;
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 }
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 }
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 System.out.print(buf);
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 }
21635
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
48
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
49 private static Class<?> lookupService(String serviceName) {
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
50 try {
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
51 // This can fail in the case of running against a JDK
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
52 // with out of date JVMCI jars. In that case, just print
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
53 // a warning sinc the expectation is that the jars will be
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
54 // updated later on.
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
55 return Class.forName(serviceName, false, FilterTypes.class.getClassLoader());
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
56 } catch (ClassNotFoundException e) {
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
57 // Must be stderr to avoid polluting the result being
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
58 // written to stdout.
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
59 System.err.println(e);
21638
b6aadfd3dfbe fixed compile error in FilterTypes.java
Doug Simon <doug.simon@oracle.com>
parents: 21635
diff changeset
60 return null;
21635
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
61 }
b311a60991da more graceful failure in context of stale mx-deployed JDK jars
Doug Simon <doug.simon@oracle.com>
parents: 21613
diff changeset
62 }
21613
60154926b513 replaced use of javap with a small Java utility for refining service class list to only those implementing com.oracle.jvmci.service.Service
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 }