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:com.mebigfatguy.deadmethods.MethodInfo.java
License:Apache License
@Override public boolean equals(Object o) { if (o instanceof MethodInfo) { MethodInfo that = (MethodInfo) o; return methodName.equals(that.methodName) && methodSignature.equals(that.methodSignature) && ((methodAccess & Opcodes.ACC_STATIC) == (that.methodAccess & Opcodes.ACC_STATIC)); }//from www . j a va 2 s.c o m return false; }
From source file:com.mebigfatguy.exagent.StackTraceMethodVisitor.java
License:Apache License
public StackTraceMethodVisitor(MethodVisitor mv, String cls, String mName, int access, String desc, int parmSizeLimit) { super(Opcodes.ASM5, mv); clsName = cls;//from w w w. j a v a 2s . c o m methodName = mName; maxParmSize = parmSizeLimit; int nextSlot = ((access & Opcodes.ACC_STATIC) != 0) ? 0 : 1; lastParmSlot = nextSlot - 1; List<String> sigs = parseSignature(desc); for (String sig : sigs) { parms.add(new Parm(sig, nextSlot)); lastParmSlot = nextSlot; nextSlot += ("J".equals(sig) || "D".equals(sig)) ? 2 : 1; } exLocalSlot = nextSlot++; depthLocalSlot = nextSlot; }
From source file:com.microsoft.applicationinsights.agent.internal.agent.ByteCodeUtilsTest.java
License:Open Source License
@Test public void testIsStatic() throws Exception { assertTrue(ByteCodeUtils.isStatic(Opcodes.ACC_STATIC)); }
From source file:com.microsoft.applicationinsights.agent.internal.agent.ByteCodeUtilsTest.java
License:Open Source License
@Test public void testNotIsStatic() throws Exception { assertFalse(ByteCodeUtils.isStatic(~Opcodes.ACC_STATIC)); }
From source file:com.mogujie.instantrun.IncrementalChangeVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (instantRunDisabled || !isAccessCompatibleWithInstantRun(access)) { // Nothing to generate. return null; }//from ww w . j a va 2 s . c o m if (name.equals("<clinit>")) { // we skip the class init as it can reset static fields which we don't support right now return null; } Log.v("visit method " + name + " " + desc); boolean isStatic = (access & Opcodes.ACC_STATIC) != 0; boolean isPrivate = (access & Opcodes.ACC_PRIVATE) != 0; boolean isSync = (access & Opcodes.ACC_SYNCHRONIZED) != 0; String newDesc = computeOverrideMethodDesc(desc, isStatic); // Do not carry on any access flags from the original method. For example synchronized // on the original method would translate into a static synchronized method here. access = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC; // MethodNode method = getMethodByNameInClass(name, desc, classNode); if (name.equals("<init>")) { return null; } else { String newName = isStatic ? computeOverrideMethodName(name, desc) : name; MethodVisitor original = super.visitMethod(access, newName, newDesc, signature, exceptions); for (MethodNode methodNode : methodNodes) { if (desc.equals(methodNode.desc) && name.equals(methodNode.name)) { processNew(methodNode); } } return new ISVisitor(original, access, newName, newDesc, IncrementalTool.getMtdSig(name, desc), isStatic, false /* isConstructor */); } }
From source file:com.mogujie.instantrun.IncrementalChangeVisitor.java
License:Apache License
/** * To each class, add the dispatch method called by the original code that acts as a trampoline to * invoke the changed methods.//from w ww .j av a2 s . com * <p/> * Pseudo code: * <code> * Object access$dispatch(String name, object[] args) { * if (name.equals( * "firstMethod.(L$type;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;")) { * return firstMethod(($type)arg[0], (String)arg[1], arg[2]); * } * if (name.equals("secondMethod.(L$type;Ljava/lang/String;I;)V")) { * secondMethod(($type)arg[0], (String)arg[1], (int)arg[2]); * return; * } * ... * StringBuilder $local1 = new StringBuilder(); * $local1.append("Method not found "); * $local1.append(name); * $local1.append(" in " + visitedClassName + * "$dispatch implementation, restart the application"); * throw new $package/InstantReloadException($local1.toString()); * } * </code> */ private void addDispatchMethod() { int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_VARARGS; Method m = new Method("access$dispatch", "(I[Ljava/lang/Object;)Ljava/lang/Object;"); MethodVisitor visitor = super.visitMethod(access, m.getName(), m.getDescriptor(), null, null); final GeneratorAdapter mv = new GeneratorAdapter(access, m, visitor); if (TRACING_ENABLED) { mv.push("Redirecting "); mv.loadArg(0); trace(mv, 2); } List<MethodNode> allMethods = new ArrayList(); // if we are disabled, do not generate any dispatch, the method will throw an exception // if invoked which should never happen. if (!instantRunDisabled) { //noinspection unchecked allMethods.addAll(classNode.methods); allMethods.addAll(addedMethods); } final Map<String, MethodNode> methods = new HashMap(); for (MethodNode methodNode : allMethods) { if (methodNode.name.equals("<clinit>") || methodNode.name.equals("<init>")) { continue; } if (!isAccessCompatibleWithInstantRun(methodNode.access)) { continue; } methods.put(methodNode.name + "." + methodNode.desc, methodNode); } new IntSwitch() { @Override void visitString() { mv.visitVarInsn(Opcodes.ALOAD, 1); } @Override void visitInt() { mv.visitVarInsn(Opcodes.ILOAD, 1); } @Override void visitCase(String methodName) { MethodNode methodNode = methods.get(methodName); String name = methodNode.name; boolean isStatic = (methodNode.access & Opcodes.ACC_STATIC) != 0; String newDesc = computeOverrideMethodDesc(methodNode.desc, isStatic); if (TRACING_ENABLED) { trace(mv, "M: " + name + " P:" + newDesc); } Type[] args = Type.getArgumentTypes(newDesc); int argc = 0; for (Type t : args) { mv.visitVarInsn(Opcodes.ALOAD, 2); mv.push(argc); mv.visitInsn(Opcodes.AALOAD); ByteCodeUtils.unbox(mv, t); argc++; } mv.visitMethodInsn(Opcodes.INVOKESTATIC, visitedClassName + "$override", isStatic ? computeOverrideMethodName(name, methodNode.desc) : name, newDesc, false); Type ret = Type.getReturnType(methodNode.desc); if (ret.getSort() == Type.VOID) { mv.visitInsn(Opcodes.ACONST_NULL); } else { mv.box(ret); } mv.visitInsn(Opcodes.ARETURN); } @Override void visitDefault() { writeMissingMessageWithHash(mv, visitedClassName); } }.visit(mv, methods.keySet(), visitedClassName); mv.visitMaxs(0, 0); mv.visitEnd(); }
From source file:com.mogujie.instantrun.IncrementalSupportVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { AcesoProguardMap.instance().putMethod(visitedClassName, IncrementalTool.getMtdSig(name, desc)); access = IncrementalTool.transformAccessForInstantRun(access); MethodVisitor defaultVisitor = super.visitMethod(access, name, desc, signature, exceptions); MethodNode method = getMethodByNameInClass(name, desc, classNode); // does the method use blacklisted APIs. boolean hasIncompatibleChange = InstantRunMethodVerifier.verifyMethod(method); if (hasIncompatibleChange || disableRedirectionForClass || !isAccessCompatibleWithInstantRun(access) || name.equals(ByteCodeUtils.CLASS_INITIALIZER)) { return defaultVisitor; } else {/*w ww .j a va2s . c om*/ ArrayList<Type> args = new ArrayList<Type>(Arrays.asList(Type.getArgumentTypes(desc))); boolean isStatic = (access & Opcodes.ACC_STATIC) != 0; if (!isStatic) { args.add(0, Type.getType(Object.class)); } ISMethodVisitor mv = new ISMethodVisitor(defaultVisitor, access, name, desc); if (name.equals(ByteCodeUtils.CONSTRUCTOR)) { } else { mv.addRedirection(new MethodRedirection(new LabelNode(mv.getStartLabel()), visitedClassName, name, desc, args, Type.getReturnType(desc), isStatic)); } method.accept(mv); return null; } }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMFieldNodeAdapter.java
License:Apache License
public boolean isStatic() { return (this.fieldNode.access & Opcodes.ACC_STATIC) != 0; }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodNodeAdapter.java
License:Apache License
public boolean isStatic() { return (this.methodNode.access & Opcodes.ACC_STATIC) != 0; }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
private boolean isStatic() { return (this.methodNode.access & Opcodes.ACC_STATIC) != 0; }