/** * Makes the given visitor visit the JVMS ClassFile structure passed to the constructor of this * {@link ClassReader}. * * @param classVisitor the visitor that must visit this class. * @param parsingOptions the options to use to parse this class. One or more of {@link * #SKIP_CODE}, {@link #SKIP_DEBUG}, {@link #SKIP_FRAMES} or {@link #EXPAND_FRAMES}. */ public void accept(final ClassVisitor classVisitor, final int parsingOptions) { accept(classVisitor, new Attribute[0], parsingOptions); }
/** * Makes the given visitor visit the Java class of this {@link ClassReader}. * This class is the one specified in the constructor (see * {@link #ClassReader(byte[]) ClassReader}). * * @param classVisitor the visitor that must visit this class. * @param flags option flags that can be used to modify the default behavior * of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES}. */ public void accept(final ClassVisitor classVisitor, final int flags) { accept(classVisitor, new Attribute[0], flags); }
/** * Makes the given visitor visit the Java class of this {@link ClassReader} * . This class is the one specified in the constructor (see * {@link #ClassReader(byte[]) ClassReader}). * * @param classVisitor * the visitor that must visit this class. * @param flags * option flags that can be used to modify the default behavior * of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES} * , {@link #SKIP_FRAMES}, {@link #SKIP_CODE}. */ public void accept(final ClassVisitor classVisitor, final int flags) { accept(classVisitor, new Attribute[0], flags); }
/** * This will return a series of bytecode instructions which can be used to compare one method with another. * debug info like local var declarations and line numbers are ignored, so the focus is on the content. */ public List getMethodBytecode(final String methodName, final ClassReader classReader) { final Tracer visit = new Tracer( methodName ); classReader.accept( visit, ClassReader.SKIP_DEBUG ); final TraceMethodVisitor trace = visit.getTrace(); return trace.getText(); }
cr = new ClassReader(args[i]); cr.accept(new TraceClassVisitor(new PrintWriter(System.out)), flags);
public static java.util.List getMethodBytecode(Class cls, String ruleClassName, String packageName, String methodName, String resource) { org.drools.core.util.asm.MethodComparator.Tracer visit = new org.drools.core.util.asm.MethodComparator.Tracer(methodName); java.io.InputStream is = cls.getClassLoader().getResourceAsStream( resource ); java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); try { byte[] data = new byte[1024]; int byteCount; while ( (byteCount = is.read( data, 0, 1024 )) > -1 ) { bos.write(data, 0, byteCount); } } catch ( java.io.IOException e ) { throw new org.drools.RuntimeDroolsException("Unable getResourceAsStream for Class '" + ruleClassName+ "' "); } org.mvel2.asm.ClassReader classReader = new org.mvel2.asm.ClassReader( bos.toByteArray() ); classReader.accept( visit, org.mvel2.asm.ClassReader.SKIP_DEBUG ); org.mvel2.asm.util.TraceMethodVisitor trace = visit.getTrace(); return trace.getText(); }
cr = new ClassReader(args[i]); cr.accept(new TraceClassVisitor(new PrintWriter(System.out)), getDefaultAttributes(), flags);
cr = new ClassReader(args[i]); cr.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter( System.out)), flags);
/** * This will return a series of bytecode instructions which can be used to compare one method with another. * debug info like local var declarations and line numbers are ignored, so the focus is on the content. */ public static List getMethodBytecode(final String methodName, final byte[] bytes) { final Tracer visit = new Tracer( methodName ); final ClassReader classReader = new ClassReader( bytes ); classReader.accept( visit, ClassReader.SKIP_DEBUG ); final TraceMethodVisitor trace = visit.getTrace(); return trace.getText(); }
private void processEntry(final ZipInputStream zis, final ZipEntry ze, final ContentHandlerFactory handlerFactory) { ContentHandler handler = handlerFactory.createContentHandler(); try { // if (CODE2ASM.equals(command)) { // read bytecode and process it // // with TraceClassVisitor // ClassReader cr = new ClassReader(readEntry(zis, ze)); // cr.accept(new TraceClassVisitor(null, new PrintWriter(os)), // false); // } boolean singleInputDocument = inRepresentation == SINGLE_XML; if (inRepresentation == BYTECODE) { // read bytecode and process it // with handler ClassReader cr = new ClassReader(readEntry(zis, ze)); cr.accept(new SAXClassAdapter(handler, singleInputDocument), 0); } else { // read XML and process it with handler XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setContentHandler(handler); reader.parse(new InputSource( singleInputDocument ? (InputStream) new ProtectedInputStream( zis) : new ByteArrayInputStream(readEntry(zis, ze)))); } } catch (Exception ex) { update(ze.getName(), 0); update(ex, 0); } }
includeFinalMethods, this ); reader.accept( visitor, 0 ); if ( clazz.getSuperclass() != null ) {
compute = hasFrames ? MethodWriter.COMPUTE_INSERTED_FRAMES : MethodWriter.COMPUTE_NOTHING; new ClassReader(classFile, 0, /* checkClassVersion = */ false) .accept( this, attributes,
final boolean dump, final PrintWriter pw) { ClassNode cn = new ClassNode(); cr.accept(new CheckClassAdapter(cn, false), ClassReader.SKIP_DEBUG);
classReader.accept(visitor, 0);
hasFrames ? MethodWriter.INSERTED_FRAMES : MethodWriter.NOTHING; hasAsmInsns = false; new ClassReader(out.data).accept(this, (hasFrames ? ClassReader.EXPAND_FRAMES : 0) | ClassReader.EXPAND_ASM_INSNS);
new ClassReader(out.data).accept(cw, ClassReader.SKIP_FRAMES); return cw.toByteArray();