List of usage examples for org.objectweb.asm Opcodes ACC_STATIC
int ACC_STATIC
To view the source code for org.objectweb.asm Opcodes ACC_STATIC.
Click Source Link
From source file:org.actorsguildframework.internal.codegenerator.ActorProxyCreator.java
License:Apache License
/** * Creates and loads the actor's proxy class. * @param actorClass the Actor class/* w ww. j a va2 s.c o m*/ * @param acd the actor's class descriptor * @throws ConfigurationException if the agent is not configured correctly */ @SuppressWarnings("unchecked") private static Class<?> generateProxyClass(Class<?> actorClass, final ActorClassDescriptor acd) throws NoSuchMethodException { BeanClassDescriptor bcd = acd.getBeanClassDescriptor(); String className = String.format("%s__ACTORPROXY", actorClass.getName()); final String classNameInternal = className.replace('.', '/'); String classNameDescriptor = "L" + classNameInternal + ";"; final Type actorState = Type .getType(acd.getConcurrencyModel().isMultiThreadingCapable() ? MultiThreadedActorState.class : SingleThreadedActorState.class); ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); MethodVisitor mv; cw.visit(codeVersion, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER + Opcodes.ACC_SYNTHETIC, classNameInternal, null, Type.getInternalName(actorClass), new String[] { "org/actorsguildframework/internal/ActorProxy" }); cw.visitSource(null, null); { for (int i = 0; i < acd.getMessageCount(); i++) cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, String.format(MESSAGE_CALLER_NAME_FORMAT, i), "Lorg/actorsguildframework/internal/MessageCaller;", "Lorg/actorsguildframework/internal/MessageCaller<*>;", null).visitEnd(); cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "actorState__ACTORPROXY", actorState.getDescriptor(), null, null).visitEnd(); } BeanCreator.writePropFields(bcd, cw); { mv = cw.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode(); for (int i = 0; i < acd.getMessageCount(); i++) { Class<?> caller = createMessageCaller(acd.getMessage(i).getOwnerClass(), acd.getMessage(i).getMethod()); String mcName = Type.getInternalName(caller); mv.visitTypeInsn(Opcodes.NEW, mcName); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, mcName, "<init>", "()V"); mv.visitFieldInsn(Opcodes.PUTSTATIC, classNameInternal, String.format(MESSAGE_CALLER_NAME_FORMAT, i), "Lorg/actorsguildframework/internal/MessageCaller;"); } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } BeanCreator.writeConstructor(actorClass, bcd, classNameInternal, cw, new BeanCreator.SnippetWriter() { @Override public void write(MethodVisitor mv) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitTypeInsn(Opcodes.NEW, actorState.getInternalName()); mv.visitInsn(Opcodes.DUP); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, actorState.getInternalName(), "<init>", "(Lorg/actorsguildframework/internal/Controller;Lorg/actorsguildframework/Actor;)V"); mv.visitFieldInsn(Opcodes.PUTFIELD, classNameInternal, "actorState__ACTORPROXY", actorState.getDescriptor()); } }); BeanCreator.writePropAccessors(bcd, classNameInternal, cw); { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getState__ACTORPROXYMETHOD", "()Lorg/actorsguildframework/internal/ActorState;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, classNameInternal, "actorState__ACTORPROXY", actorState.getDescriptor()); mv.visitInsn(Opcodes.ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", classNameDescriptor, null, l0, l1, 0); mv.visitMaxs(0, 0); mv.visitEnd(); } for (int i = 0; i < acd.getMessageCount(); i++) { MessageImplDescriptor mid = acd.getMessage(i); Method method = mid.getMethod(); String simpleDescriptor = Type.getMethodDescriptor(method); String genericSignature = GenericTypeHelper.getSignature(method); writeProxyMethod(classNameInternal, classNameDescriptor, cw, i, actorState, acd.getConcurrencyModel(), mid, method, simpleDescriptor, genericSignature); writeSuperProxyMethod(actorClass, classNameDescriptor, cw, method, simpleDescriptor, genericSignature, !acd.getConcurrencyModel().isMultiThreadingCapable()); } { mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_SYNCHRONIZED, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "toString", "()Ljava/lang/String;"); mv.visitInsn(Opcodes.ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", classNameDescriptor, null, l0, l1, 0); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); try { return (Class<? extends ActorProxy>) GenerationUtils.loadClass(className, cw.toByteArray()); } catch (Exception e) { throw new ConfigurationException("Failure loading ActorProxy", e); } }
From source file:org.actorsguildframework.internal.codegenerator.BeanCreator.java
License:Apache License
/** * Creates and loads the bean implementation class. * @param beanClass the bean class//from w w w .j a va2 s.co m * @param bcd the BeanClassDescriptor to use * @throws ConfigurationException if the agent is not configured correctly */ private static Class<?> generateBeanClass(Class<?> beanClass, BeanClassDescriptor bcd) throws NoSuchMethodException { String className = String.format("%s__BEAN", beanClass.getName()); String classNameInternal = className.replace('.', '/'); ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); MethodVisitor mv; cw.visit(codeVersion, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER + Opcodes.ACC_SYNTHETIC, classNameInternal, null, Type.getInternalName(beanClass), new String[] {}); cw.visitSource(null, null); // write @Prop fields writePropFields(bcd, cw); // static constructor { mv = cw.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode(); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } // constructor(Controller, Props) writeConstructor(beanClass, bcd, classNameInternal, cw, null); // Write @Prop accessors writePropAccessors(bcd, classNameInternal, cw); cw.visitEnd(); try { return (Class<?>) GenerationUtils.loadClass(className, cw.toByteArray()); } catch (Exception e) { throw new ConfigurationException("Failure loading generated Bean", e); } }
From source file:org.adjective.stout.tools.StackVisualiserClassVisitor.java
License:Apache License
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (_method.equals(name)) { _output.print("Method: " + Type.getReturnType(desc) + " " + name + "( "); Type[] arguments = Type.getArgumentTypes(desc); for (Type type : arguments) { _output.print(type);/*from w w w . ja va2 s .c o m*/ _output.print(" "); } _output.println(")"); Type thisType = Type.getType("L" + _name + ";"); Type superType = Type.getType("L" + _superName + ";"); return new StackVisualiserMethodVisitor(_output, thisType, superType, (access & Opcodes.ACC_STATIC) > 0, arguments); } return null; }
From source file:org.adjective.stout.writer.ByteCodeWriter.java
License:Apache License
private int getModifierCode(Set<ElementModifier> modifiers, MemberType type) { int code = getModifierCode(modifiers, (Sort) null); int illegal = Opcodes.ACC_ANNOTATION | Opcodes.ACC_BRIDGE | Opcodes.ACC_ENUM | Opcodes.ACC_INTERFACE | Opcodes.ACC_SUPER;// w ww . ja va 2 s. c o m switch (type) { case FIELD: illegal |= Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT | Opcodes.ACC_SYNCHRONIZED; break; case METHOD: if (isBitSet(Opcodes.ACC_ABSTRACT, code)) { illegal |= Opcodes.ACC_NATIVE | Opcodes.ACC_STRICT | Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL; } break; } if (isBitSet(illegal, code)) { throw new IllegalStateException( "Illegal combination of modifier codes: " + code + " (illegal codes: " + illegal + ")"); } return code; }
From source file:org.anon.smart.base.stt.asm.ASMMethodContext.java
License:Open Source License
public boolean shouldBCI(boolean entry) { boolean bci = (!name().equals(CONSTRUCTOR_NAME)); if (!entry)//from ww w .jav a 2 s . co m bci = true; bci = (bci && ((access() & Opcodes.ACC_STATIC) != Opcodes.ACC_STATIC)); return bci; }
From source file:org.anon.smart.base.stt.asm.ASMSTTReader.java
License:Open Source License
public boolean validate(int access) throws CtxException { if ((access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) return false; return true;// w ww. j ava 2 s .c o m }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.GatherInnerClassVisitor.java
License:Apache License
@Override public void visitInnerClass(String name, String outerName, String innerName, int access) { if ((className == null || !name.equals(className)) && ((access & Opcodes.ACC_PUBLIC) == 0 || (access & Opcodes.ACC_STATIC) == 0)) { innerClassNames.add(name);//from w w w . j a v a2 s. co m } }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.RenameClassVisitor.java
License:Apache License
@Override public void visitInnerClass(String name, String outerName, String innerName, int access) { if ((access & Opcodes.ACC_PUBLIC) != 0 && (access & Opcodes.ACC_STATIC) != 0) { super.visitInnerClass(name, outerName, innerName, access); }/*from w w w . j a v a 2 s . c om*/ }
From source file:org.apache.commons.javaflow.providers.asm3.ContinuableClassVisitor.java
License:Apache License
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { if (MaybeContinuableClassVisitor.MARKER_FIELD_NAME.equals(name) && (access & Opcodes.ACC_STATIC) != 0) { skipEnchancing = true;/* ww w . j a v a2s . c om*/ classInfo.markClassProcessed(); throw StopException.INSTANCE; } return super.visitField(access, name, desc, signature, value); }
From source file:org.apache.commons.javaflow.providers.asm3.ContinuableClassVisitor.java
License:Apache License
@Override public void visitEnd() { if (!skipEnchancing) { super.visitField( (isInterface ? Opcodes.ACC_PUBLIC : Opcodes.ACC_PRIVATE) + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, MaybeContinuableClassVisitor.MARKER_FIELD_NAME, "Ljava/lang/String;", null, "A").visitEnd(); }/* w w w.jav a 2s .c om*/ super.visitEnd(); }