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:net.sf.cglib.transform.ClassTransformer.java
License:Apache License
public ClassTransformer() { super(Opcodes.ASM5); }
From source file:net.sf.cglib.transform.ClassTransformerTee.java
License:Apache License
public ClassTransformerTee(ClassVisitor branch) { super(Opcodes.ASM5); this.branch = branch; }
From source file:net.sf.cglib.transform.ClassVisitorTee.java
License:Apache License
public ClassVisitorTee(ClassVisitor cv1, ClassVisitor cv2) { super(Opcodes.ASM5); this.cv1 = cv1; this.cv2 = cv2; }
From source file:net.sf.cglib.transform.FieldVisitorTee.java
License:Apache License
public FieldVisitorTee(FieldVisitor fv1, FieldVisitor fv2) { super(Opcodes.ASM5); this.fv1 = fv1; this.fv2 = fv2; }
From source file:net.sf.cglib.transform.MethodVisitorTee.java
License:Apache License
public MethodVisitorTee(MethodVisitor mv1, MethodVisitor mv2) { super(Opcodes.ASM5); this.mv1 = mv1; this.mv2 = mv2; }
From source file:net.yrom.tools.PredicateClassVisitor.java
License:Apache License
PredicateClassVisitor() {
super(Opcodes.ASM5);
}
From source file:net.yrom.tools.PredicateClassVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (attemptToVisitR) return null; return new MethodVisitor(Opcodes.ASM5, null) { @Override/*from ww w. jav a2 s. c om*/ public void visitFieldInsn(int opcode, String owner, String fieldName, String fieldDesc) { if (attemptToVisitR || opcode != Opcodes.GETSTATIC || owner.startsWith("java/lang/")) { return; } attemptToVisitR = isRClass(owner); } }; }
From source file:net.yrom.tools.RSymbols.java
License:Apache License
private void drainSymbols(Path file) { final String filename = file.getFileName().toString(); String typeName = filename.substring(0, filename.length() - ".class".length()); byte[] bytes; try {/* w w w .ja v a 2 s . c o m*/ bytes = Files.readAllBytes(file); } catch (IOException e) { throw new UncheckedIOException(e); } ClassVisitor visitor = new ClassVisitor(Opcodes.ASM5) { @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { // read constant value if (value instanceof Integer) { String key = typeName + '.' + name; Integer old = symbols.get(key); if (old != null && !old.equals(value)) { throw new IllegalStateException("Value of " + key + " mismatched! " + "Excepted 0x" + Integer.toHexString(old) + " but was 0x" + Integer.toHexString((Integer) value)); } else { symbols.put(key, (Integer) value); } } return null; } @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (access == Opcodes.ACC_STATIC && "<clinit>".equals(name)) { return new MethodVisitor(Opcodes.ASM5) { int[] current = null; LinkedList<Integer> intStack = new LinkedList<>(); @Override public void visitIntInsn(int opcode, int operand) { if (opcode == Opcodes.NEWARRAY && operand == Opcodes.T_INT) { current = new int[intStack.pop()]; } else if (opcode == Opcodes.BIPUSH) { intStack.push(operand); } } @Override public void visitLdcInsn(Object cst) { if (cst instanceof Integer) { intStack.push((Integer) cst); } } @Override public void visitInsn(int opcode) { if (opcode >= Opcodes.ICONST_0 && opcode <= Opcodes.ICONST_5) { intStack.push(opcode - Opcodes.ICONST_0); } else if (opcode == Opcodes.IASTORE) { int value = intStack.pop(); int index = intStack.pop(); current[index] = value; } } @Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { if (opcode == Opcodes.PUTSTATIC) { int[] old = styleables.get(name); if (old != null && old.length != current.length && !Arrays.equals(old, current)) { throw new IllegalStateException("Value of styleable." + name + " mismatched! " + "Excepted " + Arrays.toString(old) + " but was " + Arrays.toString(current)); } else { styleables.put(name, current); } current = null; intStack.clear(); } } }; } return null; } }; new ClassReader(bytes).accept(visitor, SKIP_DEBUG | SKIP_FRAMES); }
From source file:net.yrom.tools.ShrinkRClassVisitor.java
License:Apache License
ShrinkRClassVisitor(ClassWriter cv, RSymbols rSymbols) { super(Opcodes.ASM5, cv); this.rSymbols = rSymbols; }
From source file:net.yrom.tools.ShrinkRClassVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) { @Override// ww w .j a v a 2 s.c o m public void visitFieldInsn(int opcode, String owner, String fieldName, String fieldDesc) { if (opcode != Opcodes.GETSTATIC || owner.startsWith("java/lang/")) { // skip! this.mv.visitFieldInsn(opcode, owner, fieldName, fieldDesc); return; } String typeName = owner.substring(owner.lastIndexOf('/') + 1); String key = typeName + '.' + fieldName; if (rSymbols.containsKey(key)) { Integer value = rSymbols.get(key); if (value == null) throw new UnsupportedOperationException("value of " + key + " is null!"); if (logger.isEnabled(LogLevel.DEBUG)) { logger.debug("replace {}.{} to 0x{}", owner, fieldName, Integer.toHexString(value)); } pushInt(this.mv, value); } else if (owner.endsWith("/R$styleable")) { // replace all */R$styleable ref! this.mv.visitFieldInsn(opcode, RSymbols.R_STYLEABLES_CLASS_NAME, fieldName, fieldDesc); } else { this.mv.visitFieldInsn(opcode, owner, fieldName, fieldDesc); } } }; }