DebugGenerators { public static InsnList debugPrint(InsnList text) { Validate.notNull(text); InsnList ret = new InsnList(); ret.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); ret.add(text); ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); return ret; } private  DebugGenerators(); static InsnList debugMarker(MarkerType markerType, String text); static InsnList debugPrint(InsnList text);  }
@Test public void mustNotCrashOnDebugPrint() throws Exception { methodNode.desc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { }); VariableTable varTable = new VariableTable(classNode, methodNode); methodNode.instructions = merge( debugPrint(loadStringConst("marker1")), returnVoid() ); try (URLClassLoader cl = createJarAndLoad(classNode)) { Object obj = cl.loadClass(STUB_CLASSNAME).newInstance(); MethodUtils.invokeMethod(obj, STUB_METHOD_NAME); } }