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.github.jasmo.obfuscate.InlineAccessors.java
License:Open Source License
private boolean local(int access) { return (access & Opcodes.ACC_STATIC) == 0; }
From source file:com.github.jasmo.obfuscate.ScrambleStrings.java
License:Open Source License
private void createStaticConstructor(ClassNode owner) throws UnsupportedEncodingException { MethodNode original = BytecodeHelper.getMethod(owner, "<clinit>", "()V"); MethodVisitor mv = owner.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); // generate instructions InstructionAdapter builder = new InstructionAdapter(mv); builder.iconst(stringList.size());//from www .j a v a 2 s . c o m builder.newarray(Type.getType(String.class)); for (int i = 0; i < stringList.size(); i++) { builder.dup(); builder.iconst(i); builder.aconst(Base64.getEncoder().encodeToString(stringList.get(i).getBytes("UTF-8"))); builder.astore(InstructionAdapter.OBJECT_TYPE); } builder.putstatic(unscrambleClass.name, FIELD_NAME, "[Ljava/lang/String;"); // merge with original if it exists if (original != null) { // original should already end with RETURN owner.methods.remove(original); original.instructions.accept(builder); } else { builder.areturn(Type.VOID_TYPE); } }
From source file:com.github.megatronking.stringfog.plugin.StringFogClassVisitor.java
License:Apache License
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { if (ClassStringField.STRING_DESC.equals(desc) && name != null && !mIgnoreClass) { // static final, in this condition, the value is null or not null. if ((access & Opcodes.ACC_STATIC) != 0 && (access & Opcodes.ACC_FINAL) != 0) { mStaticFinalFields.add(new ClassStringField(name, (String) value)); value = null;//from www .j av a 2 s .co m } // static, in this condition, the value is null. if ((access & Opcodes.ACC_STATIC) != 0 && (access & Opcodes.ACC_FINAL) == 0) { mStaticFields.add(new ClassStringField(name, (String) value)); value = null; } // final, in this condition, the value is null or not null. if ((access & Opcodes.ACC_STATIC) == 0 && (access & Opcodes.ACC_FINAL) != 0) { mFinalFields.add(new ClassStringField(name, (String) value)); value = null; } // normal, in this condition, the value is null. if ((access & Opcodes.ACC_STATIC) != 0 && (access & Opcodes.ACC_FINAL) != 0) { mFields.add(new ClassStringField(name, (String) value)); value = null; } } return super.visitField(access, name, desc, signature, value); }
From source file:com.github.megatronking.stringfog.plugin.StringFogClassVisitor.java
License:Apache License
@Override public void visitEnd() { if (!mIgnoreClass && !isClInitExists && !mStaticFinalFields.isEmpty()) { MethodVisitor mv = super.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode();//from w w w .j ava 2 s. c om // Here init static final fields. for (ClassStringField field : mStaticFinalFields) { if (!canEncrypted(field.value)) { continue; } String originValue = field.value; String encryptValue = mStringFogImpl.encrypt(originValue, mKey); mMappingPrinter.output(getJavaClassName(), originValue, encryptValue); mv.visitLdcInsn(encryptValue); mv.visitMethodInsn(Opcodes.INVOKESTATIC, mFogClassName, "decrypt", "(Ljava/lang/String;)Ljava/lang/String;", false); mv.visitFieldInsn(Opcodes.PUTSTATIC, mClassName, field.name, ClassStringField.STRING_DESC); } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 0); mv.visitEnd(); } super.visitEnd(); }
From source file:com.google.code.jconts.instrument.context.MethodContext.java
License:Apache License
/** * If we are transforming a static method. * * @return */ public boolean isStatic() { return (access & Opcodes.ACC_STATIC) != 0; }
From source file:com.google.code.jtracert.instrument.impl.asm.JTracertClassAdapter.java
License:Open Source License
/** * @param access/*from w w w . j a v a2s. c o m*/ * @param name * @param desc * @param signature * @param exceptions * @return */ @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { //if (0 == (access & Opcodes.ACC_SYNTHETIC)) { if (0 == 0) { MethodVisitor parentMethodVisitor = super.visitMethod(access, name, desc, signature, exceptions); // instrument java.lang.Object default constructor /*if ("java.lang.Object".equals(getClassName())) { if (!"<init>".equals(name)) return parentMethodVisitor; if ((null != getInstrumentationProperties()) && (getInstrumentationProperties().isVerbose())) { System.out.println("Instrumenting java.lang.Object constructor: " + getClassName() + "." + name); } return new JTracertObjectConstructorAdapter( parentMethodVisitor ); }*/ // instrumenting loadClass method if (("loadClass".equals(name) && ("(Ljava/lang/String;)Ljava/lang/Class;".equals(desc) || "(Ljava/lang/String;Z)Ljava/lang/Class;".equals(desc)))) { if (0 == (access & Opcodes.ACC_STATIC)) { if (null != getInstrumentationProperties() && getInstrumentationProperties().isVerbose()) { System.out.println( "Instrumenting class loader method: " + getClassName() + "." + name + " " + desc); } parentMethodVisitor = new InstrumentClassLoaderMethodVisitor(parentMethodVisitor); } } // instrumenting other methods if (isInstrumentClass()) { if (getClassName().startsWith("java.io") || getClassName().startsWith("java.util.concurrent") || getClassName().startsWith("java.net") || getClassName().startsWith("sun") || getClassName().startsWith("com.sun") || getClassName().startsWith("java.util.jar") || getClassName().startsWith("java.util.zip") || getClassName().startsWith("java.nio") || getClassName().startsWith("java.security")) { return parentMethodVisitor; } /*// todo: add a classloader check above if (getClassName().startsWith("java") || getClassName().startsWith("sun") || getClassName().startsWith("org.xml") || getClassName().startsWith("com.sun") || getClassName().startsWith("$")) { if (getClassName().startsWith("java.util")) { return new JTracertSystemMethodAdapter( parentMethodVisitor, access, name, desc, getClassName() ); } else { return parentMethodVisitor; } } else { return new JTracertMethodAdapter( parentMethodVisitor, access, name, desc, getClassName(), getInstrumentationProperties(), getParentClassName() ); }*/ return new JTracertMethodAdapter(parentMethodVisitor, access, name, desc, getClassName(), getInstrumentationProperties(), getParentClassName()); } else { return parentMethodVisitor; } } else { if ((null != getInstrumentationProperties()) && (getInstrumentationProperties().isVerbose())) { System.out.println("Skiping syntetic method " + getClassName() + "." + name); } return super.visitMethod(access, name, desc, signature, exceptions); } }
From source file:com.google.code.jtracert.instrument.impl.asm.JTracertClassAdapter.java
License:Open Source License
/** * *//*www.ja va 2 s .c o m*/ @Override public void visitEnd() { if (!isInterface) { // Apply class transformations } if ("java.lang.System".equals(getClassName()) || "java/lang/System".equals(getClassName())) { MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_SYNCHRONIZED, "constructor", "(Ljava/lang/Object;)V", null, null); mv.visitCode(); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 1); mv.visitEnd(); } super.visitEnd(); }
From source file:com.google.common.truth.ActualValueInference.java
License:Open Source License
private static boolean isStatic(int access) { return isSet(access, Opcodes.ACC_STATIC); }
From source file:com.google.devtools.build.android.desugar.BitFlags.java
License:Open Source License
public static boolean isStatic(int access) { return isSet(access, Opcodes.ACC_STATIC); }
From source file:com.google.devtools.build.android.desugar.BytecodeTypeInference.java
License:Open Source License
/** * Create the types of local variables at the very beginning of the method with the information of * the declaring class and the method descriptor. *//*w w w.j av a 2s .c o m*/ private static ArrayList<InferredType> createInitialLocalVariableTypes(int access, String ownerClass, String methodName, String methodDescriptor) { ArrayList<InferredType> types = new ArrayList<>(); if (!BitFlags.isSet(access, Opcodes.ACC_STATIC)) { // Instance method, and this is the receiver types.add(InferredType.createNonUninitializedType(convertToDescriptor(ownerClass))); } Type[] argumentTypes = Type.getArgumentTypes(methodDescriptor); for (Type argumentType : argumentTypes) { switch (argumentType.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.SHORT: case Type.INT: types.add(InferredType.INT); break; case Type.FLOAT: types.add(InferredType.FLOAT); break; case Type.LONG: types.add(InferredType.LONG); types.add(InferredType.TOP); break; case Type.DOUBLE: types.add(InferredType.DOUBLE); types.add(InferredType.TOP); break; case Type.ARRAY: case Type.OBJECT: types.add(InferredType.createNonUninitializedType(argumentType.getDescriptor())); break; default: throw new RuntimeException("Unhandled argument type: " + argumentType + " in " + ownerClass + "." + methodName + methodDescriptor); } } return types; }