List of usage examples for org.objectweb.asm Opcodes ACC_PROTECTED
int ACC_PROTECTED
To view the source code for org.objectweb.asm Opcodes ACC_PROTECTED.
Click Source Link
From source file:com.mebigfatguy.baremetal4j.Sourcifier.java
License:Apache License
public String accessString(int access) { String separator = ""; StringBuilder sb = new StringBuilder(32); if ((access & Opcodes.ACC_PUBLIC) != 0) { sb.append("public"); separator = " "; } else if ((access & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected"); separator = " "; } else if ((access & Opcodes.ACC_PRIVATE) != 0) { sb.append("private"); separator = " "; }/*www . j a v a 2 s . c o m*/ if ((access & Opcodes.ACC_STATIC) != 0) { sb.append(separator).append("static"); separator = " "; } if ((access & Opcodes.ACC_FINAL) != 0) { sb.append(separator).append("final"); separator = " "; } return sb.toString(); }
From source file:com.mebigfatguy.junitflood.classpath.ClassDetails.java
License:Apache License
private Access convertAccess(int access) { switch (access) { case Opcodes.ACC_PRIVATE: return Access.PRIVATE; case Opcodes.ACC_PROTECTED: return Access.PROTECTED; case Opcodes.ACC_PUBLIC: return Access.PUBLIC; default://from ww w. ja v a 2s .c om return Access.PACKAGE; } }
From source file:com.microsoft.applicationinsights.agent.internal.agent.sql.PreparedStatementClassVisitor.java
License:Open Source License
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { FieldVisitor fv = super.visitField(access, name, desc, signature, value); if (fv != null && shouldAdd) { shouldAdd = false;// ww w . j av a2s. co m FieldVisitor fv1 = super.visitField(Opcodes.ACC_PROTECTED, SqlConstants.AI_SDK_SQL_STRING, "Ljava/lang/String;", null, null); if (fv1 != null) { fv1.visitEnd(); } fv1 = super.visitField(Opcodes.ACC_PROTECTED, SqlConstants.AI_SDK_ARGS_ARRAY, "[Ljava/lang/Object;", null, null); if (fv1 != null) { fv1.visitEnd(); } fv1 = super.visitField(Opcodes.ACC_PROTECTED, SqlConstants.AI_SDK_BATCH_COUNTER, "I", null, null); if (fv1 != null) { fv1.visitEnd(); } } return fv; }
From source file:com.mogujie.instantrun.IncrementalSupportVisitor.java
License:Apache License
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { // InstantProguardMap.instance().putField(InstantRunTool.getFieldSig(name, desc)); // access = transformAccessForInstantRun(access); //make all field to public access &= ~Opcodes.ACC_PROTECTED; access &= ~Opcodes.ACC_PRIVATE;// ww w. ja va 2 s.c o m access = access | Opcodes.ACC_PUBLIC; return super.visitField(access, name, desc, signature, value); }
From source file:com.mogujie.instantrun.IncrementalTool.java
License:Apache License
public static int transformAccessToPublic(int access) { access &= ~Opcodes.ACC_PROTECTED; access &= ~Opcodes.ACC_PRIVATE;/*from ww w .ja v a 2 s. com*/ return access | Opcodes.ACC_PUBLIC; }
From source file:com.mogujie.instantrun.IncrementalTool.java
License:Apache License
public static int transformAccessForInstantRun(int access) { IncrementalVisitor.AccessRight accessRight = IncrementalVisitor.AccessRight.fromNodeAccess(access); if (accessRight != IncrementalVisitor.AccessRight.PRIVATE) { access &= ~Opcodes.ACC_PROTECTED; access &= ~Opcodes.ACC_PRIVATE; return access | Opcodes.ACC_PUBLIC; }//from w w w . ja v a2s . c om return access; }
From source file:com.nginious.http.xsp.expr.ExpressionCompiler.java
License:Apache License
/** * Creates a compiled expression from the specified tree value node expression. The class bytecode for the * compiled expression is generated at runtime. * /* w w w . j a v a 2 s .co m*/ * @param uncompiled the uncompiled tree value node expression * @return the compiled expression * @throws ExpressionException if unable to compile expression */ public Expression compile(TreeExpression uncompiled) throws ExpressionException { ClassWriter writer = new ClassWriter(0); // Create class String className = classBaseName + classNameCounter.getAndIncrement(); String classIdentifier = className.replace('.', '/'); writer.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, classIdentifier, "L" + classIdentifier + ";", "com/nginious/http/xsp/expr/Expression", null); // Create constructor MethodVisitor visitor = writer.visitMethod(Opcodes.ACC_PROTECTED, "<init>", "()V", null, null); visitor.visitCode(); visitor.visitVarInsn(Opcodes.ALOAD, 0); visitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "com/nginious/http/xsp/expr/Expression", "<init>", "()V"); visitor.visitInsn(Opcodes.RETURN); visitor.visitMaxs(1, 1); visitor.visitEnd(); // protected abstract boolean evaluateBoolean(); visitor = writer.visitMethod(Opcodes.ACC_PROTECTED, "evaluateBoolean", "()Z", null, null); if (uncompiled.getType() == Type.BOOLEAN) { uncompiled.compile(visitor); } else if (uncompiled.getType() == Type.DOUBLE) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateDouble", "()D"); Label endLabel = new Label(); Label falseLabel = new Label(); visitor.visitLdcInsn(0.0d); visitor.visitInsn(Opcodes.DCMPL); visitor.visitJumpInsn(Opcodes.IFEQ, falseLabel); visitor.visitLdcInsn(true); visitor.visitJumpInsn(Opcodes.GOTO, endLabel); visitor.visitLabel(falseLabel); visitor.visitLdcInsn(false); visitor.visitLabel(endLabel); } else if (uncompiled.getType() == Type.INT) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateInt", "()I"); Label endLabel = new Label(); Label falseLabel = new Label(); visitor.visitLdcInsn(0); visitor.visitJumpInsn(Opcodes.IFNE, falseLabel); visitor.visitLdcInsn(true); visitor.visitJumpInsn(Opcodes.GOTO, endLabel); visitor.visitLabel(falseLabel); visitor.visitLdcInsn(false); visitor.visitLabel(endLabel); } else if (uncompiled.getType() == Type.STRING) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateString", "()Ljava/lang/String;"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "parseBoolean", "(Ljava/lang/String;)Z"); } visitor.visitInsn(Opcodes.IRETURN); visitor.visitMaxs(5, 5); visitor.visitEnd(); // protected abstract int evaluateInt(); visitor = writer.visitMethod(Opcodes.ACC_PROTECTED, "evaluateInt", "()I", null, null); if (uncompiled.getType() == Type.BOOLEAN) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateBoolean", "()Z"); Label endLabel = new Label(); Label falseLabel = new Label(); visitor.visitJumpInsn(Opcodes.IFEQ, falseLabel); visitor.visitLdcInsn(1); visitor.visitJumpInsn(Opcodes.GOTO, endLabel); visitor.visitLabel(falseLabel); visitor.visitLdcInsn(0); visitor.visitLabel(endLabel); } else if (uncompiled.getType() == Type.DOUBLE) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateDouble", "()D"); visitor.visitInsn(Opcodes.D2I); } else if (uncompiled.getType() == Type.INT) { uncompiled.compile(visitor); } else if (uncompiled.getType() == Type.STRING) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateString", "()Ljava/lang/String;"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I"); } visitor.visitInsn(Opcodes.IRETURN); visitor.visitMaxs(5, 5); visitor.visitEnd(); // protected abstract double evaluateDouble(); visitor = writer.visitMethod(Opcodes.ACC_PROTECTED, "evaluateDouble", "()D", null, null); if (uncompiled.getType() == Type.BOOLEAN) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateBoolean", "()Z"); Label endLabel = new Label(); Label falseLabel = new Label(); visitor.visitJumpInsn(Opcodes.IFEQ, falseLabel); visitor.visitLdcInsn(1.0d); visitor.visitJumpInsn(Opcodes.GOTO, endLabel); visitor.visitLabel(falseLabel); visitor.visitLdcInsn(0.0d); visitor.visitLabel(endLabel); } else if (uncompiled.getType() == Type.DOUBLE) { uncompiled.compile(visitor); } else if (uncompiled.getType() == Type.INT) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateInt", "()I"); visitor.visitInsn(Opcodes.I2D); } else if (uncompiled.getType() == Type.STRING) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateString", "()Ljava/lang/String;"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "parseDouble", "(Ljava/lang/String;)D"); } visitor.visitInsn(Opcodes.DRETURN); visitor.visitMaxs(5, 5); visitor.visitEnd(); // protected abstract String evaluateString(); visitor = writer.visitMethod(Opcodes.ACC_PROTECTED, "evaluateString", "()Ljava/lang/String;", null, null); if (uncompiled.getType() == Type.BOOLEAN) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateBoolean", "()Z"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "toString", "(Z)Ljava/lang/String;"); } else if (uncompiled.getType() == Type.DOUBLE) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateDouble", "()D"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "toString", "(D)Ljava/lang/String;"); } else if (uncompiled.getType() == Type.INT) { visitor.visitVarInsn(Opcodes.ALOAD, 0); // this visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classIdentifier, "evaluateInt", "()I"); visitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "toString", "(I)Ljava/lang/String;"); } else if (uncompiled.getType() == Type.STRING) { uncompiled.compile(visitor); } visitor.visitInsn(Opcodes.ARETURN); visitor.visitMaxs(6, 6); visitor.visitEnd(); // public abstract Type getType(); visitor = writer.visitMethod(Opcodes.ACC_PUBLIC, "getType", "()Lcom/nginious/http/xsp/expr/Type;", null, null); if (uncompiled.getType() == Type.BOOLEAN) { visitor.visitFieldInsn(Opcodes.GETSTATIC, "com/nginious/http/xsp/expr/Type", "BOOLEAN", "Lcom/nginious/http/xsp/expr/Type;"); visitor.visitInsn(Opcodes.ARETURN); } else if (uncompiled.getType() == Type.DOUBLE) { visitor.visitFieldInsn(Opcodes.GETSTATIC, "com/nginious/http/xsp/expr/Type", "DOUBLE", "Lcom/nginious/http/xsp/expr/Type;"); visitor.visitInsn(Opcodes.ARETURN); } else if (uncompiled.getType() == Type.INT) { visitor.visitFieldInsn(Opcodes.GETSTATIC, "com/nginious/http/xsp/expr/Type", "INT", "Lcom/nginious/http/xsp/expr/Type;"); visitor.visitInsn(Opcodes.ARETURN); } else if (uncompiled.getType() == Type.STRING) { visitor.visitFieldInsn(Opcodes.GETSTATIC, "com/nginious/http/xsp/expr/Type", "STRING", "Lcom/nginious/http/xsp/expr/Type;"); visitor.visitInsn(Opcodes.ARETURN); } visitor.visitMaxs(1, 1); visitor.visitEnd(); try { writer.visitEnd(); byte[] clazzBytes = writer.toByteArray(); Class<?> clazz = loadClass(className, clazzBytes); return (Expression) clazz.newInstance(); } catch (Exception e) { throw new ExpressionException("Can't instantiate compiled expression", e); } }
From source file:com.nginious.http.xsp.XspCompiler.java
License:Apache License
/** * Creates bytecode that overrides the {@link XspService#executeXsp(com.nginious.http.HttpRequest, com.nginious.http.HttpResponse)} * method for the XSP service class being created with the specified class writer. * //from www . ja v a2 s.c o m * @param writer the class writer * @return a method writer for adding bytecode to the created method */ private MethodVisitor createXspMethod(ClassWriter writer) { // 0 = this, 1 = HttpRequest, 2 = HttpResponse String[] exceptions = { "java/io/IOException", "com/nginious/http/HttpException" }; MethodVisitor visitor = writer.visitMethod(Opcodes.ACC_PROTECTED, "executeXsp", "(Lcom/nginious/http/HttpRequest;Lcom/nginious/http/HttpResponse;)Z", null, exceptions); visitor.visitCode(); return visitor; }
From source file:com.poolik.classfinder.info.ClassInfo.java
License:BSD License
/** * Convert an ASM access mask to a reflection Modifier mask. * * @param asmAccessMask the ASM access mask * @return the Modifier mask//from w w w . ja va 2 s . co m */ private int convertAccessMaskToModifierMask(int asmAccessMask) { int modifier = 0; // Convert the ASM access info into Reflection API modifiers. if ((asmAccessMask & Opcodes.ACC_FINAL) != 0) modifier |= Modifier.FINAL; if ((asmAccessMask & Opcodes.ACC_NATIVE) != 0) modifier |= Modifier.NATIVE; if ((asmAccessMask & Opcodes.ACC_INTERFACE) != 0) modifier |= Modifier.INTERFACE; if ((asmAccessMask & Opcodes.ACC_ABSTRACT) != 0) modifier |= Modifier.ABSTRACT; if ((asmAccessMask & Opcodes.ACC_PRIVATE) != 0) modifier |= Modifier.PRIVATE; if ((asmAccessMask & Opcodes.ACC_PROTECTED) != 0) modifier |= Modifier.PROTECTED; if ((asmAccessMask & Opcodes.ACC_PUBLIC) != 0) modifier |= Modifier.PUBLIC; if ((asmAccessMask & Opcodes.ACC_STATIC) != 0) modifier |= Modifier.STATIC; if ((asmAccessMask & Opcodes.ACC_STRICT) != 0) modifier |= Modifier.STRICT; if ((asmAccessMask & Opcodes.ACC_SYNCHRONIZED) != 0) modifier |= Modifier.SYNCHRONIZED; if ((asmAccessMask & Opcodes.ACC_TRANSIENT) != 0) modifier |= Modifier.TRANSIENT; if ((asmAccessMask & Opcodes.ACC_VOLATILE) != 0) modifier |= Modifier.VOLATILE; return modifier; }
From source file:com.sun.tdk.jcov.instrument.DataClass.java
License:Open Source License
/** * Check whether <b>access</b> field has ACC_PUBLIC or ACC_PROTECTED flag * * @see #getAccess()// w w w . ja va 2 s . co m * @see org.objectweb.asm.Opcodes * @return true if <b>access</b> field has ACC_PUBLIC or ACC_PROTECTED flag */ @Deprecated public boolean isPublic() { return (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED)) != 0; }