public static ClassVisitor newCheckClassAdapter(ClassVisitor cv) { try { Class<? extends ClassVisitor> tmvClass = Class.forName("org.objectweb.asm.util.CheckClassAdapter").asSubclass(ClassVisitor.class); Constructor<? extends ClassVisitor> c = tmvClass.getDeclaredConstructor(ClassVisitor.class); return c.newInstance(cv); } catch (Throwable t) { return cv; } }
public static ClassVisitor newTraceClassVisitor(PrintWriter out) { try { Class<? extends ClassVisitor> tmvClass = Class.forName("org.objectweb.asm.util.TraceClassVisitor").asSubclass(ClassVisitor.class); Constructor<? extends ClassVisitor> c = tmvClass.getDeclaredConstructor(PrintWriter.class); return c.newInstance(out); } catch (Throwable t) { throw new RuntimeException(t); } }
public static MethodVisitor newTraceMethodVisitor(MethodVisitor mv) { try { Class<? extends MethodVisitor> tmvClass = Class.forName("org.objectweb.asm.util.TraceMethodVisitor") .asSubclass(MethodVisitor.class); Constructor<? extends MethodVisitor> c = tmvClass.getDeclaredConstructor(MethodVisitor.class); return c.newInstance(mv); } catch (Throwable t) { return mv; } }