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.eclipse.objectteams.otredyn.bytecode.asm.AddEmptyMethodAdapter.java
License:Open Source License
@Override public void visitEnd() { MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); if ((this.access & Opcodes.ACC_ABSTRACT) != 0) { mv.visitEnd();//from w w w.j a v a2 s. c o m return; } mv.visitCode(); boolean needConstValue = true; if (superToCall != null) { needConstValue = false; boolean isStatic = (this.access & Opcodes.ACC_STATIC) != 0; int firstArgIndex = isStatic ? 0 : 1; if (!isStatic) mv.visitVarInsn(Opcodes.ALOAD, 0); // "this" Type[] args = Type.getArgumentTypes(desc); for (int i = 0, slot = firstArgIndex; i < args.length; slot += args[i++].getSize()) mv.visitVarInsn(args[i].getOpcode(Opcodes.ILOAD), slot); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, superToCall, name, desc, false); } Type returnType = Type.getReturnType(this.desc); switch (returnType.getSort()) { case Type.VOID: mv.visitInsn(Opcodes.RETURN); break; case Type.INT: case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: if (needConstValue) mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IRETURN); break; case Type.FLOAT: if (needConstValue) mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FRETURN); break; case Type.LONG: if (needConstValue) mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LRETURN); break; case Type.DOUBLE: case Type.OBJECT: case Type.ARRAY: if (needConstValue) mv.visitInsn(Opcodes.ACONST_NULL); mv.visitInsn(Opcodes.ARETURN); break; } mv.visitMaxs(1, maxLocals); mv.visitEnd(); }
From source file:org.eclipse.objectteams.otredyn.bytecode.asm.AddGlobalTeamActivationAdapter.java
License:Open Source License
private boolean isMainMethod(String name, String desc, int access) { if (access != (Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC)) return false; if (!"main".equals(name)) return false; if (!"([Ljava/lang/String;)V".equals(desc)) return false; return true;/*from w w w . j a va2s. c o m*/ }
From source file:org.eclipse.objectteams.otredyn.bytecode.asm.AddImplicitActivationAdapter.java
License:Open Source License
private static boolean canImplicitlyActivate(int methFlags, String methName, String methDesc) { boolean isCandidate = ((methFlags & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC)) == 0) && (!methName.startsWith("_OT$")) && (!methName.equals("<init>")) && (!(methName.equals("activate") && methDesc.equals("()V"))) && (!(methName.equals("deactivate") && methDesc.equals("()V"))) && (!ConstantMembers.isReflectiveOTMethod(methName, methDesc)); return isCandidate; }
From source file:org.eclipse.objectteams.otredyn.bytecode.asm.AsmClassVisitor.java
License:Open Source License
/** * Parses the methods of the class/*from w ww.j a v a2 s . c om*/ */ @Override public MethodVisitor visitMethod(int access, final String name, final String desc, String signature, String[] exceptions) { clazz.addMethod(name, desc, (access & Opcodes.ACC_STATIC) != 0, (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE))); if (clazz.isTeam() || clazz.isRole()) // check for method annotation ImplicitTeamActivation: return new MethodVisitor(this.api) { @Override public AnnotationVisitor visitAnnotation(String annDesc, boolean visible) { if (annDesc.equals(AddImplicitActivationAdapter.ANNOTATION_IMPLICIT_ACTIVATION)) clazz.registerMethodForImplicitActivation(name + desc); return super.visitAnnotation(annDesc, visible); } }; return super.visitMethod(access, name, desc, signature, exceptions); }
From source file:org.eclipse.objectteams.otredyn.bytecode.asm.AsmClassVisitor.java
License:Open Source License
/** * Parses the fields of the class//from w w w . j a v a 2s. c o m */ @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { clazz.addField(name, desc, (access & Opcodes.ACC_STATIC) != 0, (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE))); return super.visitField(access, name, desc, signature, value); }
From source file:org.eclipse.objectteams.otredyn.bytecode.asm.CreateDispatchCodeInOrgMethodAdapter.java
License:Open Source License
@Override protected InsnList createInstructionsToCheackTeams(MethodNode method) { InsnList instructions = new InsnList(); instructions.add(new InsnNode(Opcodes.DUP)); LabelNode label = new LabelNode(); //if (teams == null) { instructions.add(new JumpInsnNode(Opcodes.IFNONNULL, label)); instructions.add(new InsnNode(Opcodes.POP)); //put the boundMethodId on the stack instructions.add(createLoadIntConstant(boundMethodId)); Type[] args = Type.getArgumentTypes(method.desc); // box the arguments instructions.add(getBoxingInstructions(args, (method.access & Opcodes.ACC_STATIC) != 0)); //callOrigStatic(boundMethodId, args); instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, name, ConstantMembers.callOrigStatic.getName(), ConstantMembers.callOrigStatic.getSignature())); Type returnType = Type.getReturnType(method.desc); instructions.add(getUnboxingInstructionsForReturnValue(returnType)); instructions.add(label);//from ww w . j a v a 2 s . c o m return instructions; }
From source file:org.elasticsearch.painless.node.SFunction.java
License:Apache License
/** Writes the function to given ClassVisitor. */ void write(ClassVisitor writer, CompilerSettings settings, Globals globals) { int access = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC; if (synthetic) { access |= Opcodes.ACC_SYNTHETIC; }//ww w .j a v a2s . com final MethodWriter function = new MethodWriter(access, method.method, writer, globals.getStatements(), settings); function.visitCode(); write(function, globals); function.endMethod(); }
From source file:org.elasticsearch.painless.node.SSource.java
License:Apache License
public void write() { // Create the ClassWriter. int classFrames = ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS; int classAccess = Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER | Opcodes.ACC_FINAL; String classBase = BASE_CLASS_TYPE.getInternalName(); String className = CLASS_TYPE.getInternalName(); String classInterfaces[] = reserved.usesScore() ? new String[] { WriterConstants.NEEDS_SCORE_TYPE.getInternalName() } : null;/*from w w w.ja v a 2s . c om*/ ClassWriter writer = new ClassWriter(classFrames); ClassVisitor visitor = writer; // if picky is enabled, turn on some checks. instead of VerifyError at the end, you get a helpful stacktrace. if (settings.isPicky()) { visitor = new SimpleChecksAdapter(visitor); } if (debugStream != null) { visitor = new TraceClassVisitor(visitor, debugStream, null); } visitor.visit(WriterConstants.CLASS_VERSION, classAccess, className, null, classBase, classInterfaces); visitor.visitSource(Location.computeSourceName(name, source), null); // Write the constructor: MethodWriter constructor = new MethodWriter(Opcodes.ACC_PUBLIC, CONSTRUCTOR, visitor, globals.getStatements(), settings); constructor.visitCode(); constructor.loadThis(); constructor.loadArgs(); constructor.invokeConstructor(org.objectweb.asm.Type.getType(Executable.class), CONSTRUCTOR); constructor.returnValue(); constructor.endMethod(); // Write the execute method: MethodWriter execute = new MethodWriter(Opcodes.ACC_PUBLIC, EXECUTE, visitor, globals.getStatements(), settings); execute.visitCode(); write(execute, globals); execute.endMethod(); // Write all functions: for (SFunction function : functions) { function.write(visitor, settings, globals); } // Write all synthetic functions. Note that this process may add more :) while (!globals.getSyntheticMethods().isEmpty()) { List<SFunction> current = new ArrayList<>(globals.getSyntheticMethods().values()); globals.getSyntheticMethods().clear(); for (SFunction function : current) { function.write(visitor, settings, globals); } } // Write the constants if (false == globals.getConstantInitializers().isEmpty()) { Collection<Constant> inits = globals.getConstantInitializers().values(); // Fields for (Constant constant : inits) { visitor.visitField(Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, constant.name, constant.type.getDescriptor(), null, null).visitEnd(); } // Initialize the constants in a static initializer final MethodWriter clinit = new MethodWriter(Opcodes.ACC_STATIC, WriterConstants.CLINIT, visitor, globals.getStatements(), settings); clinit.visitCode(); for (Constant constant : inits) { constant.initializer.accept(clinit); clinit.putStatic(CLASS_TYPE, constant.name, constant.type); } clinit.returnValue(); clinit.endMethod(); } // End writing the class and store the generated bytes. visitor.visitEnd(); bytes = writer.toByteArray(); }
From source file:org.enerj.enhancer.MetaData.java
License:Open Source License
/** * Determine if the access modifiers are static or final. * /* w w w .j a v a2 s . com*/ * @param someModifiers the ASM Opcodes.ACC_* modifiers. * * @return true if the modifiers represent static or final. */ // TODO Refactor to ASMUtil private static boolean isStaticOrFinal(int someModifiers) { return (someModifiers & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC || (someModifiers & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL; }
From source file:org.evosuite.graphs.cfg.ControlFlowGraph.java
License:Open Source License
/** * <p>isStaticMethod</p>/*ww w .j ava2 s . c o m*/ * * @return a boolean. */ public boolean isStaticMethod() { return (access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC; }