List of usage examples for org.objectweb.asm Opcodes ASM5
int ASM5
To view the source code for org.objectweb.asm Opcodes ASM5.
Click Source Link
From source file:com.tonicsystems.jarjar.transform.asm.GetNameClassWriter.java
License:Apache License
/** * Constructs a new GetNameClassWriter./* www . j a v a 2s .c o m*/ */ // * @param flags may include {@link ClassWriter#COMPUTE_FRAMES} * or {@link ClassWriter#COMPUTE_MAXS}. public GetNameClassWriter(ClassVisitor cv) { super(Opcodes.ASM5, cv); }
From source file:com.trigersoft.jaque.expression.ExpressionClassVisitor.java
License:Apache License
public ExpressionClassVisitor(Object lambda, Method method) { super(Opcodes.ASM5); _me = Expression.constant(lambda, lambda.getClass()); _method = method.getName();/*from w w w . j av a2 s . c o m*/ _methodDesc = Type.getMethodDescriptor(method); }
From source file:com.trigersoft.jaque.expression.ExpressionMethodVisitor.java
License:Apache License
ExpressionMethodVisitor(ExpressionClassVisitor classVisitor, ConstantExpression me, Class<?>[] argTypes) {
super(Opcodes.ASM5);
_classVisitor = classVisitor;
_me = me;
_argTypes = argTypes;
}
From source file:com.tsc9526.monalisa.tools.clazz.MelpAsm.java
License:Open Source License
public static String[] getMethodParamNames(final Method m) { final String[] paramNames = new String[m.getParameterTypes().length]; final String n = m.getDeclaringClass().getName(); ClassReader cr = null;//from w w w .j a v a 2s .c o m try { cr = new ClassReader(n); } catch (IOException e) { throw new RuntimeException(e); } cr.accept(new ClassVisitor(Opcodes.ASM5) { public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { final Type[] args = Type.getArgumentTypes(desc); // ????? if (!name.equals(m.getName()) || !sameType(args, m.getParameterTypes())) { return super.visitMethod(access, name, desc, signature, exceptions); } MethodVisitor v = super.visitMethod(access, name, desc, signature, exceptions); return new MethodVisitor(Opcodes.ASM5, v) { public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) { int i = index - 1; // ??? // ???"this"??? if (Modifier.isStatic(m.getModifiers())) { i = index; } if (i >= 0) { setParamName(paramNames, name); } super.visitLocalVariable(name, desc, signature, start, end, index); } }; } }, 0); return paramNames; }
From source file:com.uphyca.galette.GAletteInstrumentation.java
License:Apache License
/** * Weave tracking method call if the annotations present. */// w ww.j av a 2 s.c o m private static void weaveIfNecessary(ClassReader classReader, File dest) throws IOException { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); ModifierClassWriter mcw = new ModifierClassWriter(Opcodes.ASM5, cw); classReader.accept(new CheckClassAdapter(mcw), ClassReader.EXPAND_FRAMES); if (!mcw.isProceed()) { return; } OutputStream out = null; try { out = new FileOutputStream(dest); out.write(cw.toByteArray()); out.flush(); } finally { closeQuietly(out); } }
From source file:com.uphyca.galette.GAletteInstrumentation.java
License:Apache License
/** * Returns true if the class had weaved. *///from w w w . j ava 2s . c o m private static boolean hadWeaved(ClassReader classReader) { BakedAnnotationReader annotationReadClassVisitor = new BakedAnnotationReader(Opcodes.ASM5); classReader.accept(annotationReadClassVisitor, ClassReader.SKIP_CODE); return annotationReadClassVisitor.weaved; }
From source file:com.xiaoqq.practise.threadmonitor.Agent.java
License:Apache License
public byte[] transform(ClassLoader classLoader, String className, Class clazz, java.security.ProtectionDomain domain, byte[] bytes) { try {// w w w.j ava 2s. c o m if (inIgnoreList(className)) { return bytes; } ClassReader cr = new ClassReader(bytes); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS); /*ClassVisitor thCV = new ThreadImplementationClassVisitor(Opcodes.ASM5, cw, classLoader); ClassVisitor cv = new MonitoringClassVisitor(Opcodes.ASM5, thCV, classLoader); */ ClassVisitor cv = new LookupRelationShipClassVisitor(Opcodes.ASM5, cw, classLoader); cr.accept(cv, ClassReader.EXPAND_FRAMES); byte[] transformedBytes = cw.toByteArray(); //TODO: remove it try { FileUtils.writeByteArrayToFile( new File("d:\\workspace\\tmp\\generatedclasses\\" + className + "_gen.class"), transformedBytes); } catch (IOException e) { e.printStackTrace(); } return transformedBytes; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:cuchaz.enigma.analysis.index.JarIndex.java
License:Open Source License
public void indexJar(ClassCache classCache, ProgressListener progress) { progress.init(4, "Indexing jar"); progress.step(1, "Entries..."); classCache.visit(() -> new IndexClassVisitor(this, Opcodes.ASM5), ClassReader.SKIP_CODE); progress.step(2, "Entry references..."); classCache.visit(() -> new IndexReferenceVisitor(this, entryIndex, inheritanceIndex, Opcodes.ASM5), 0); progress.step(3, "Bridge methods..."); bridgeMethodIndex.findBridgeMethods(); progress.step(4, "Processing..."); processIndex(this); }
From source file:cuchaz.enigma.analysis.JarIndex.java
License:Open Source License
public void indexJar(ParsedJar jar, boolean buildInnerClasses) { // step 1: read the class names obfClassEntries.addAll(jar.getClassEntries()); // step 2: index classes, fields, methods, interfaces jar.visit(node -> node.accept(new IndexClassVisitor(this, Opcodes.ASM5))); // step 3: index field, method, constructor references jar.visit(node -> node.accept(new IndexReferenceVisitor(this, Opcodes.ASM5))); // step 4: index access and bridged methods for (MethodDefEntry methodEntry : methods.values()) { // look for access and bridged methods MethodEntry accessedMethod = findAccessMethod(methodEntry); if (accessedMethod != null) { if (isBridgedMethod(accessedMethod, methodEntry)) { this.bridgedMethods.put(methodEntry, accessedMethod); }//from w w w .j ava2s.co m } } if (buildInnerClasses) { // step 5: index inner classes and anonymous classes jar.visit(node -> node.accept(new IndexInnerClassVisitor(this, Opcodes.ASM5))); // step 6: update other indices with inner class info Map<String, String> renames = Maps.newHashMap(); for (ClassEntry innerClassEntry : this.innerClassesByOuter.values()) { String newName = innerClassEntry.buildClassEntry(getObfClassChain(innerClassEntry)).getName(); if (!innerClassEntry.getName().equals(newName)) { // DEBUG //System.out.println("REPLACE: " + innerClassEntry.getName() + " WITH " + newName); renames.put(innerClassEntry.getName(), newName); } } EntryRenamer.renameClassesInSet(renames, this.obfClassEntries); this.translationIndex.renameClasses(renames); EntryRenamer.renameClassesInMultimap(renames, this.methodImplementations); EntryRenamer.renameClassesInMultimap(renames, this.methodsReferencing); EntryRenamer.renameClassesInMultimap(renames, this.methodReferences); EntryRenamer.renameClassesInMultimap(renames, this.fieldReferences); EntryRenamer.renameClassesInMap(renames, this.access); } }
From source file:cuchaz.enigma.Deobfuscator.java
License:Open Source License
public void protectifyJar(File out, ProgressListener progress) { transformJar(out, progress, (node, writer) -> { node.accept(new ClassProtectifier(Opcodes.ASM5, writer)); return node.name; });//from w w w .ja v a2 s .c o m }