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:org.apache.aries.proxy.impl.interfaces.InterfaceCombiningClassAdapter.java
License:Apache License
/** * Construct an {@link InterfaceCombiningClassAdapter} to combine the supplied * interfaces into a class with the supplied name using the supplied classloader * @param className// ww w . j a va 2 s . c o m * @param loader * @param interfaces */ InterfaceCombiningClassAdapter(String className, ClassLoader loader, Class<?> superclass, Collection<Class<?>> interfaces) { super(Opcodes.ASM5); writer = new OSGiFriendlyClassWriter(ClassWriter.COMPUTE_FRAMES, loader); ClassVisitor cv = new OSGiFriendlyClassVisitor(writer, ClassWriter.COMPUTE_FRAMES); adapter = new InterfaceUsingWovenProxyAdapter(cv, className, loader); this.interfaces = interfaces; this.superclass = superclass; String[] interfaceNames = new String[interfaces.size()]; int i = 0; for (Class<?> in : interfaces) { interfaceNames[i] = Type.getInternalName(in); i++; } adapter.visit(ProxyUtils.getWeavingJavaVersion(), ACC_PUBLIC | ACC_SYNTHETIC, className, null, (superclass == null) ? AbstractWovenProxyAdapter.OBJECT_TYPE.getInternalName() : Type.getInternalName(superclass), interfaceNames); }
From source file:org.apache.aries.proxy.impl.interfaces.InterfaceProxyGenerator.java
License:Apache License
public InterfaceProxyGenerator() { super(Opcodes.ASM5); }
From source file:org.apache.aries.spifly.weaver.TCCLSetterVisitor.java
License:Apache License
public TCCLSetterVisitor(ClassVisitor cv, String className, Set<WeavingData> weavingData) { super(Opcodes.ASM5, cv); this.targetClass = Type.getType("L" + className.replace('.', '/') + ";"); this.weavingData = weavingData; }
From source file:org.apache.aries.versioning.utils.SerialVersionClassVisitor.java
License:Apache License
public SerialVersionClassVisitor(ClassVisitor cv) { super(Opcodes.ASM5, cv); }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorMissingCheckVisitor.java
License:Apache License
public EvaluatorMissingCheckVisitor(ClassVisitor downStreamVisitor) { super(Opcodes.ASM5, downStreamVisitor); }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorMissingCheckVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); if (!METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature)) && !name.equals(CONSTRUCTOR)) { return mv; }//from w w w . j av a 2s .c o m if (name.equals(CONSTRUCTOR) && mv != null) { return new ConstructorVisitor(Opcodes.ASM5, mv); } if (mv != null) { return new InjectMissingCheckVisitor(Opcodes.ASM5, mv); } return null; }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorNullCheckVisitor.java
License:Apache License
public EvaluatorNullCheckVisitor(ClassVisitor downStreamVisitor, Label lastAddedLabel) { super(Opcodes.ASM5, downStreamVisitor); this.lastAddedLabel = lastAddedLabel; }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorNullCheckVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); if (!METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature))) { return mv; }//from w ww . j a v a 2 s.co m if (mv != null) { return new InjectNullCheckVisitor(Opcodes.ASM5, mv); } return null; }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorVisitor.java
License:Apache License
public EvaluatorVisitor(ClassVisitor downStreamVisitor) { super(Opcodes.ASM5, downStreamVisitor); }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); if (!METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature))) { return mv; }//from w ww . ja va2 s.c om if (mv != null) { return new MethodVisitor(Opcodes.ASM5, mv) { private FieldInsnNode fieldAccessNode = null; private List<AbstractInsnNode> instructionsAfterFieldAccess = new ArrayList<>(); @Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { mv.visitFieldInsn(opcode, owner, name, desc); fieldAccessNode = new FieldInsnNode(opcode, owner, name, desc); instructionsAfterFieldAccess.clear(); } @Override public void visitIincInsn(int var, int increment) { if (fieldAccessNode != null) { instructionsAfterFieldAccess.add(new IincInsnNode(var, increment)); } super.visitIincInsn(var, increment); } @Override public void visitInsn(int opcode) { if (fieldAccessNode != null) { instructionsAfterFieldAccess.add(new InsnNode(opcode)); } super.visitInsn(opcode); } @Override public void visitIntInsn(int opcode, int operand) { if (fieldAccessNode != null) { instructionsAfterFieldAccess.add(new IntInsnNode(opcode, operand)); } super.visitIntInsn(opcode, operand); } @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { mv.visitMethodInsn(opcode, owner, name, desc, itf); if (fieldAccessNode == null || !METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature))) { return; } // Loads "this". mv.visitVarInsn(Opcodes.ALOAD, 0); // Replays the field access instruction. fieldAccessNode.accept(mv); // Replays other instruction between the field access and the evaluator call. for (AbstractInsnNode instruction : instructionsAfterFieldAccess) { instruction.accept(mv); } // Loads the result IPointable. mv.visitVarInsn(Opcodes.ALOAD, 2); // Invokes the null check method. mv.visitMethodInsn(Opcodes.INVOKESTATIC, TYPECHECK_CLASS, IS_NULL, TYPECHECK_METHOD_DESC, false); Label notNull = new Label(); // Adds the if branch. mv.visitJumpInsn(Opcodes.IFEQ, notNull); mv.visitInsn(Opcodes.RETURN); mv.visitLabel(notNull); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); } }; } return null; }