/** * Main entry point * * @param args args[0] is the class library (harmony or gnu classpath) args[1] is the classpath to * use to read classes, args[2] is the destination directory */ public static void main(final String[] args) { Set<Class<?>> processedClasses = new HashSet<Class<?>>(); classLibrary = args[0]; RVMClassLoader.init(args[1]); destinationDir = args[2] + "/"; setup(); for (AnnotatedElement elem : thingsToAnnotate.keySet()) { try { Class<?> c = getClassForElement(elem); if (!processedClasses.contains(c)) { adaptClass(c.getName()); processedClasses.add(c); } } catch (Exception e) { throw new Error("Error processing " + elem, e); } } Set<String> processedClasses2 = new HashSet<String>(); for (ElementTriple triple : thingsToAnnotate2.keySet()) { String c = triple.getClassName(); if (!processedClasses2.contains(c)) { adaptClass(c); processedClasses2.add(c); } } for (AnnotatedElement elem : annotatedElements) { thingsToAnnotate.remove(elem); } for (ElementTriple triple : annotatedElements2) { thingsToAnnotate2.remove(triple); } if (thingsToAnnotate.size() > 0 || thingsToAnnotate2.size() > 0) { for (AnnotatedElement elem : thingsToAnnotate.keySet()) { System.out.println("Error finding element to annotate: " + elem); } for (ElementTriple triple : thingsToAnnotate2.keySet()) { System.out.println("Error finding element to annotate: " + triple); } throw new Error("Error finding elements to annotate"); } }
/** * Establish the RVMMethod for a given MethodReference gracefully. * * @param ref The MethodReference * @return The RVMMethod, or null on failure. */ private static RVMMethod getMethod(MethodReference ref) { if (ref.getType().getClassLoader() == RVMClassLoader.getApplicationClassLoader()) { try { return ref.resolve(); } catch (NoClassDefFoundError e) { if (Controller.options.BULK_COMPILATION_VERBOSITY >= 1) VM.sysWriteln("Warning: could not define class: " + ref.getType()); return null; } catch (NoSuchMethodError e) { if (Controller.options.BULK_COMPILATION_VERBOSITY >= 1) VM.sysWriteln("Warning: could not load method: " + ref); return null; } } else { return ref.getResolvedMember(); } }