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:ch.eiafr.cojac.CojacClassVisitor.java
License:Apache License
public CojacClassVisitor(ClassVisitor cv, CojacReferences references, CojacAnnotationVisitor cav) { super(Opcodes.ASM5, cv); this.references = references; this.stats = references.getStats(); this.args = references.getArgs(); this.factory = references.getOpCodeInstrumenterFactory(); this.cav = cav; }
From source file:ch.eiafr.cojac.EmptyVisitor.java
License:Apache License
public EmptyVisitor() { super(Opcodes.ASM5); }
From source file:ch.eiafr.cojac.EmptyVisitor.java
License:Apache License
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { return new FieldVisitor(Opcodes.ASM5) { @Override/*from w w w . ja v a 2s .c o m*/ public AnnotationVisitor visitAnnotation(String desc, boolean visible) { return av; } }; }
From source file:ch.eiafr.cojac.EmptyVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { return new MethodVisitor(Opcodes.ASM5) { @Override// ww w .j av a2 s.com public AnnotationVisitor visitAnnotationDefault() { return av; } @Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { return av; } @Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { return av; } }; }
From source file:ch.eiafr.cojac.FloatReplaceClassVisitor.java
License:Apache License
private Printer newPrinter(final String s) { Printer printer = new ASMifier(Opcodes.ASM5, "mv", 0) { // or Textifier(ASM5) @Override/*from w ww. j ava 2 s . co m*/ public void visitMethodEnd() { System.out.println("======================== " + s + " =================="); PrintWriter p = new PrintWriter(System.out); print(p); p.flush(); // don't forget that! } }; return printer; }
From source file:ch.eiafr.cojac.FloatReplacerMethodVisitor.java
License:Apache License
FloatReplacerMethodVisitor(AnalyzerAdapter aa, MethodVisitor lvs, ReplaceFloatsMethods rfm, InstrumentationStats stats, IOpcodeInstrumenterFactory factory, CojacReferences references) { super(Opcodes.ASM5, lvs); //this.lvs=lvs; this.aa = aa; this.rfm = rfm; this.references = references; this.stats = stats; this.factory = factory; }
From source file:ch.eiafr.cojac.FloatVariablesSorter.java
License:Apache License
public FloatVariablesSorter(int access, String oldDesc, AnalyzerAdapter mv) { super(Opcodes.ASM5, mv); Type[] args = Type.getArgumentTypes(oldDesc); firstFrameMapping = new int[1 + args.length * 2]; // +1 for 'this' Arrays.fill(firstFrameMapping, -1); // so that erroneously using unwritten cells will cause problems... boolean hasTarget = (Opcodes.ACC_STATIC & access) == 0; // not static -> there is a 'this' param int oldVarIndex = 0; int newVarIndex = 0; int lastIndexSet = -1; if (hasTarget) { oldVarIndex = newVarIndex = 1;/*ww w. j a v a 2 s . com*/ firstFrameMapping[0] = 0; // 'this' remains 'this' after remapping... lastIndexSet = 0; } for (Type arg : args) { firstFrameMapping[oldVarIndex] = newVarIndex; lastIndexSet = oldVarIndex; oldVarIndex += arg.getSize(); newVarIndex += arg.getSize(); if (arg.equals(Type.DOUBLE_TYPE)) { newVarIndex--; } assert !arg.equals(COJAC_DOUBLE_WRAPPER_TYPE); // this would be strange (the descriptor is the old one) } maxRenumber = lastIndexSet; }
From source file:ch.sourcepond.utils.podescoin.devel.PrintClassVisitor.java
License:Apache License
public PrintClassVisitor(final ClassVisitor cv) { super(Opcodes.ASM5, cv); }
From source file:ch.sourcepond.utils.podescoin.devel.PrintClassVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { final MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); final Printer p = new Textifier(Opcodes.ASM5) { @Override/* w ww .j a v a 2 s . c om*/ public void visitMethodEnd() { print(new PrintWriter(System.out)); // print it after it has // been visited } }; return new TraceMethodVisitor(mv, p); }
From source file:co.cask.cdap.app.runtime.spark.SparkRunnerClassLoader.java
License:Apache License
/** * Defines the DStreamGraph class by rewriting calls to parallel array with a call to * SparkRuntimeUtils#setTaskSupport(ParArray). *//*from w w w .ja v a2 s . c o m*/ private Class<?> defineDStreamGraph(String name, InputStream byteCodeStream) throws IOException { ClassReader cr = new ClassReader(byteCodeStream); ClassWriter cw = new ClassWriter(0); cr.accept(new ClassVisitor(Opcodes.ASM5, cw) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return new MethodVisitor(Opcodes.ASM5, mv) { @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { super.visitMethodInsn(opcode, owner, name, desc, itf); // If detected call to ArrayBuffer.par(), set the TaskSupport to avoid thread leak. //INVOKEVIRTUAL scala/collection/mutable/ ArrayBuffer.par ()Lscala/collection/parallel/mutable/ParArray; Type returnType = Type.getReturnType(desc); if (opcode == Opcodes.INVOKEVIRTUAL && name.equals("par") && owner.equals("scala/collection/mutable/ArrayBuffer") && returnType.getClassName().equals("scala.collection.parallel.mutable.ParArray")) { super.visitMethodInsn(Opcodes.INVOKESTATIC, SPARK_RUNTIME_UTILS_TYPE.getInternalName(), "setTaskSupport", Type.getMethodDescriptor(returnType, returnType), false); } } }; } }, ClassReader.EXPAND_FRAMES); byte[] byteCode = cw.toByteArray(); return defineClass(name, byteCode, 0, byteCode.length); }