public static void defineClasses() throws CannotCompileException { if (frozen) { new Exception("Attempted to defined patched classes again").printStackTrace(); return; } for (String name : definedClasses.keySet()) { final CtClass clazz = definedClasses.get(name); if (clazz.isFrozen() || !clazz.isModified()) { // assume that ij-legacy did something about it continue; } try { clazz.toClass(); } catch (CannotCompileException e) { final Throwable cause = e.getCause(); if (cause != null && !(cause instanceof LinkageError)) { throw e; } } } frozen = true; }
@Override final public void run() { if (frozen) { System.err.println("Attempted to patch classes again: " + getClass().getName()); return; } try { instrumentClasses(); } catch (BadBytecode e) { e.printStackTrace(); } catch (NotFoundException e) { e.printStackTrace(); } catch (RuntimeException e) { e.printStackTrace(); } catch (CannotCompileException e) { System.err.println(e.getMessage() + "\n" + e.getReason()); e.printStackTrace(); Throwable cause = e.getCause(); if (cause != null) cause.printStackTrace(); } }