List of usage examples for org.objectweb.asm Opcodes ASM4
int ASM4
To view the source code for org.objectweb.asm Opcodes ASM4.
Click Source Link
From source file:org.jacoco.core.test.validation.FramesTest.java
License:Open Source License
private byte[] calculateFrames(byte[] source) { ClassReader rc = new ClassReader(source); ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); // Adjust Version to 1.6 to enable frames: rc.accept(new ClassVisitor(Opcodes.ASM4, cw) { @Override/*from ww w . java 2 s. c o m*/ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { super.visit(Opcodes.V1_6, access, name, signature, superName, interfaces); } }, 0); return cw.toByteArray(); }
From source file:org.jboss.errai.GwtLinkerClassHider.java
License:Apache License
/** * Generates a class with a no-args public constructor. * //from ww w. j a v a2 s. c o m * @param loader * ignored. * @param className * The generated class has this package and name. * @param classBeingRedefined * ignored. * @param protectionDomain * ignored. * @param classfileBuffer * ignored. * @return bytecode for an empty class whose package and class name are * determined by the {@code className} parameter. */ public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { if (className.contains("Linker")) { final List<String> annotations = new ArrayList<String>(); ClassReader cr = new ClassReader(classfileBuffer); ClassVisitor cv = new ClassVisitor(Opcodes.ASM4) { @Override public AnnotationVisitor visitAnnotation(String name, boolean val) { annotations.add(name); return super.visitAnnotation(name, val); } }; cr.accept(cv, 0); if (annotations.contains("Lcom/google/gwt/core/ext/linker/Shardable;") || annotations.contains("Lcom/google/gwt/core/ext/linker/LinkerOrder;")) { if (debug) { System.out.println("client-local-class-hider (linkers): hiding GWT linker class: " + className); } return EmtpyClassGenerator.generateEmptyClass(className); } } if (debug) { System.out.println("client-local-class-hider (linkers): NOT hiding class (not a linker): " + className); } return null; }
From source file:org.krzogr.trackthread.instrument.ThreadClassTransformer.java
License:Open Source License
private byte[] transformThreadClass(final ClassLoader loader, final String className, final Class<?> classBeingRedefined, final ProtectionDomain protectionDomain, final byte[] classfileBuffer, final boolean isThreadSubclass) { try {/*w ww. jav a 2 s . com*/ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); ClassVisitor cv = isThreadSubclass ? new ThreadSubclassVisitor(Opcodes.ASM4, cw) : new ThreadClassVisitor(Opcodes.ASM4, cw); ClassReader cr = new ClassReader(classfileBuffer); cr.accept(cv, ClassReader.EXPAND_FRAMES); return cw.toByteArray(); } catch (Exception e) { System.err.println("Fatal error while transforming class " + className + ": " + e.getMessage()); e.printStackTrace(); } return classfileBuffer; }
From source file:org.krzogr.trackthread.instrument.ThreadClassVisitor.java
License:Open Source License
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { if (StartMethodVisitor.matches(access, name, desc)) { return new StartMethodVisitor(Opcodes.ASM4, super.visitMethod(access, name, desc, signature, exceptions)); } else if (SetNameMethodVisitor.matches(access, name, desc)) { return new SetNameMethodVisitor(Opcodes.ASM4, super.visitMethod(access, name, desc, signature, exceptions)); } else if (RunMethodVisitor.matches(access, name, desc)) { return new RunMethodVisitor(Opcodes.ASM4, super.visitMethod(access, name, desc, signature, exceptions), access, name, desc);//from w w w.j av a 2 s . co m } else { return super.visitMethod(access, name, desc, signature, exceptions); } }
From source file:org.krzogr.trackthread.instrument.ThreadSubclassVisitor.java
License:Open Source License
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { if (RunMethodVisitor.matches(access, name, desc)) { return new RunMethodVisitor(Opcodes.ASM4, super.visitMethod(access, name, desc, signature, exceptions), access, name, desc);/* w w w . j ava2 s. c o m*/ } else { return super.visitMethod(access, name, desc, signature, exceptions); } }
From source file:org.mutabilitydetector.checkers.AsmMutabilityChecker.java
License:Apache License
public AsmMutabilityChecker() { super(Opcodes.ASM4); }
From source file:org.mutabilitydetector.checkers.CollectionFieldTest.java
License:Apache License
private String[] descAndSignatureOfSingleFieldIn(Class<?> class1) throws IOException { final String[] fieldDescSignature = new String[2]; ClassReader classReader = new ClassReader(class1.getName()); classReader.accept(new ClassVisitor(Opcodes.ASM4) { @Override// w w w .j a v a2 s . c om public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { fieldDescSignature[0] = desc; fieldDescSignature[1] = signature; return super.visitField(access, name, desc, signature, value); }; }, 0); return fieldDescSignature; }
From source file:org.openjdk.jmh.generators.asm.AnnotationInvocationHandler.java
License:Open Source License
public AnnotationInvocationHandler(String className, AnnotationVisitor annotationVisitor) { super(Opcodes.ASM4, annotationVisitor); this.className = className; this.values = new HashMultimap<>(); }
From source file:org.openjdk.jmh.generators.asm.AnnotationInvocationHandler.java
License:Open Source License
@Override public AnnotationVisitor visitArray(final String name) { return new AnnotationVisitor(Opcodes.ASM4, super.visitArray(name)) { @Override//www . j a va2s. co m public void visitEnum(String n, String desc, String value) { values.put(name, value); super.visitEnum(n, desc, value); } @Override public void visit(String n, Object value) { values.put(name, value); super.visit(n, value); } }; }
From source file:org.openjdk.jmh.generators.asm.ASMClassInfo.java
License:Open Source License
public ASMClassInfo(ClassInfoRepo classInfos) { super(Opcodes.ASM4); this.classInfos = classInfos; this.methods = new ArrayList<>(); this.constructors = new ArrayList<>(); this.fields = new ArrayList<>(); }