/** * External entry point for ScriptClassInfoCollector if invoked from the command line * * @param args argument vector, args contains a class for which to collect info * @throws IOException if there were problems parsing args or class */ public static void main(final String[] args) throws IOException { if (args.length != 1) { System.err.println("Usage: " + ScriptClassInfoCollector.class.getName() + " <class>"); System.exit(1); } args[0] = args[0].replace('.', '/'); final ScriptClassInfoCollector scic = new ScriptClassInfoCollector(); try (final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(args[0] + ".class"))) { final ClassReader reader = new ClassReader(bis); reader.accept(scic, 0); } final ScriptClassInfo sci = scic.getScriptClassInfo(); final PrintStream out = System.out; if (sci != null) { out.println("script class: " + sci.getName()); out.println("==================================="); for (final MemberInfo memInfo : sci.getMembers()) { out.println("kind : " + memInfo.getKind()); out.println("name : " + memInfo.getName()); out.println("attributes: " + memInfo.getAttributes()); out.println("javaName: " + memInfo.getJavaName()); out.println("javaDesc: " + memInfo.getJavaDesc()); out.println("where: " + memInfo.getWhere()); out.println("====================================="); } } else { out.println(args[0] + " is not a @ScriptClass"); } }
public static boolean check() { Class<?> cls = HotSpotVMConfig.class; String classFilePath = "/" + cls.getName().replace('.', '/') + ".class"; try { InputStream classfile = cls.getResourceAsStream(classFilePath); ClassReader cr = new ClassReader( Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName())); ClassVisitor cv = new HotSpotVMConfigVerifier(); cr.accept(cv, 0); return true; } catch (IOException e) { throw new JVMCIError(e); } }