List of usage examples for org.objectweb.asm Opcodes ACC_PRIVATE
int ACC_PRIVATE
To view the source code for org.objectweb.asm Opcodes ACC_PRIVATE.
Click Source Link
From source file:com.gargoylesoftware.js.nashorn.internal.ir.debug.NashornTextifier.java
License:Open Source License
private static void appendAccess(final StringBuilder sb, final int access) { if ((access & Opcodes.ACC_PUBLIC) != 0) { sb.append("public "); }//from w ww . j a v a 2 s .co m if ((access & Opcodes.ACC_PRIVATE) != 0) { sb.append("private "); } if ((access & Opcodes.ACC_PROTECTED) != 0) { sb.append("protected "); } if ((access & Opcodes.ACC_FINAL) != 0) { sb.append("final "); } if ((access & Opcodes.ACC_STATIC) != 0) { sb.append("static "); } if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { sb.append("synchronized "); } if ((access & Opcodes.ACC_VOLATILE) != 0) { sb.append("volatile "); } if ((access & Opcodes.ACC_TRANSIENT) != 0) { sb.append("transient "); } if ((access & Opcodes.ACC_ABSTRACT) != 0) { sb.append("abstract "); } if ((access & Opcodes.ACC_STRICT) != 0) { sb.append("strictfp "); } if ((access & Opcodes.ACC_SYNTHETIC) != 0) { sb.append("synthetic "); } if ((access & Opcodes.ACC_MANDATED) != 0) { sb.append("mandated "); } if ((access & Opcodes.ACC_ENUM) != 0) { sb.append("enum "); } }
From source file:com.github.yihtserns.camelscript.transform.CamelScriptASTTransformation.java
License:Apache License
/** * @param fieldName name for the field/* w ww .ja v a 2 s . c o m*/ * @param type field type * @param initialValueExpression initial value for the field * @return {@link FieldNode} of the given type and initial value */ private FieldNode fieldNode(final String fieldName, final Class<?> type, final Expression initialValueExpression) { return new FieldNode(fieldName, Opcodes.ACC_PRIVATE, ClassHelper.make(type), null, initialValueExpression); }
From source file:com.google.code.jconts.instrument.gen.ComputationClassGenerator.java
License:Apache License
public void accept(TransformationContext context) { ClassVisitor cv = context.writer();/*from w w w . java 2 s . c o m*/ // extends Object implements Computation<ValueType> SignatureWriter sign = new SignatureWriter(); SignatureVisitor supsign = sign.visitSuperclass(); supsign.visitClassType(OBJECT_NAME); supsign.visitEnd(); SignatureVisitor iface = sign.visitInterface(); iface.visitClassType(COMPUTATION_NAME); SignatureVisitor argsign = iface.visitTypeArgument('='); new SignatureReader(info.valueSignature).acceptType(argsign); argsign.visitEnd(); cv.visit(Opcodes.V1_6, Opcodes.ACC_FINAL, info.computationClassName, sign.toString(), OBJECT_NAME, new String[] { COMPUTATION_NAME }); cv.visitSource(info.ownerSource, null); cv.visitInnerClass(info.stateClassName, info.owner, info.stateSimpleName, 0); cv.visitInnerClass(info.computationClassName, info.owner, info.computationSimpleName, 0); cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "state", stateDesc, null, null); generateConstructor(cv); generateExecute(cv); cv.visitEnd(); }
From source file:com.google.code.jconts.instrument.gen.ComputationClassGenerator.java
License:Apache License
private void generateConstructor(ClassVisitor cv) { final String name = info.computationClassName; final Type outerType = Type.getObjectType(info.owner); // Constructor have form either <init>(OuterClass this$0, State state) // or <init>(State state) String ctorDesc;/*from w w w . j a v a 2 s.c o m*/ if (info.isStatic()) { ctorDesc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { info.stateType }); } else { cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "this$0", 'L' + info.owner + ';', null, null); ctorDesc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { outerType, info.stateType }); } // Generate constructor MethodVisitor mv = cv.visitMethod(0, CTOR_NAME, ctorDesc, null, null); mv.visitCode(); Label start = new Label(); Label end = new Label(); mv.visitLabel(start); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, OBJECT_NAME, CTOR_NAME, DEFAULT_CTOR_DESC); // Save state field mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 1 + info.thisOffset); mv.visitFieldInsn(Opcodes.PUTFIELD, name, "state", stateDesc); // Save outer this if (!info.isStatic()) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitFieldInsn(Opcodes.PUTFIELD, name, "this$0", outerType.getDescriptor()); } mv.visitInsn(Opcodes.RETURN); mv.visitLabel(end); mv.visitLocalVariable("this", 'L' + name + ';', signature, start, end, 0); if (!info.isStatic()) { mv.visitLocalVariable("this$0", outerType.getDescriptor(), null, start, end, 1); } mv.visitLocalVariable("state", stateDesc, null, start, end, 1 + info.thisOffset); mv.visitMaxs(2, 2 + info.thisOffset); mv.visitEnd(); }
From source file:com.google.code.jconts.instrument.gen.ContinuationClassGenerator.java
License:Apache License
public void accept(TransformationContext context) { ClassVisitor cv = context.writer();/*from w w w . j av a 2s . c o m*/ cv.visit(Opcodes.V1_6, Opcodes.ACC_FINAL, info.continuationClassName, signature, OBJECT_NAME, new String[] { CONTINUATION_NAME }); cv.visitSource(info.ownerSource, null); cv.visitInnerClass(info.stateClassName, info.owner, info.stateSimpleName, 0); cv.visitInnerClass(info.continuationClassName, info.owner, info.continuationSimpleName, 0); cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "state", stateDesc, null, null); cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "index", "I", null, null); generateConstructor(cv); generateExecute(cv, true); generateExecute(cv, false); cv.visitEnd(); }
From source file:com.google.code.jconts.instrument.gen.ContinuationClassGenerator.java
License:Apache License
private void generateConstructor(ClassVisitor cv) { final String name = info.continuationClassName; final Type outerType = Type.getObjectType(info.owner); // Constructor have form either <init>(OuterClass this$0, State state, // int index) // or <init>(State state, int index) String ctorDesc;//from www . j av a2 s . com if (info.isStatic()) { ctorDesc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { info.stateType, Type.INT_TYPE }); } else { cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "this$0", 'L' + info.owner + ';', null, null); ctorDesc = Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { outerType, info.stateType, Type.INT_TYPE }); } // Generate constructor MethodVisitor mv = cv.visitMethod(0, CTOR_NAME, ctorDesc, null, null); mv.visitCode(); Label start = new Label(); Label end = new Label(); mv.visitLabel(start); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, OBJECT_NAME, CTOR_NAME, DEFAULT_CTOR_DESC); // Save state field mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 1 + info.thisOffset); mv.visitFieldInsn(Opcodes.PUTFIELD, name, "state", stateDesc); // Save index field mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ILOAD, 2 + info.thisOffset); mv.visitFieldInsn(Opcodes.PUTFIELD, name, "index", "I"); // Save outer this if (!info.isStatic()) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitFieldInsn(Opcodes.PUTFIELD, name, "this$0", outerType.getDescriptor()); } mv.visitInsn(Opcodes.RETURN); mv.visitLabel(end); mv.visitLocalVariable("this", 'L' + name + ';', signature, start, end, 0); if (!info.isStatic()) { mv.visitLocalVariable("this$0", outerType.getDescriptor(), null, start, end, 1); } mv.visitLocalVariable("state", stateDesc, null, start, end, 1 + info.thisOffset); mv.visitLocalVariable("index", "I", null, start, end, 2 + info.thisOffset); mv.visitMaxs(2, 3 + info.thisOffset); mv.visitEnd(); }
From source file:com.google.code.nanorm.internal.introspect.asm.AccessorBuilder.java
License:Apache License
/** * Constructor. Starts generating the Java class code. * //www .j a va 2 s . co m * @param name accessor class name * @param isSetter if we building accessor for setter. */ public AccessorBuilder(String name, boolean isSetter) { this.isSetter = isSetter; cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Type owner = Type.getType('L' + name + ';'); String iface = isSetter ? "com/google/code/nanorm/internal/introspect/Setter" : "com/google/code/nanorm/internal/introspect/Getter"; cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", new String[] { iface }); cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "type", "Ljava/lang/reflect/Type;", null, null); visitConstructor(owner); visitGetType(owner); }
From source file:com.google.code.nanorm.internal.introspect.asm.MapperBuilder.java
License:Apache License
/** * Build mapper./*w w w.j a v a2 s . c o m*/ * * @param name class name * @param mapper mapper interface or base class * @param configs method configurations * @return mapper byte-code */ public static byte[] buildMapper(String name, Class<?> mapper, MethodConfig[] configs) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Type owner = Type.getType('L' + name + ';'); if (mapper.isInterface()) { cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", new String[] { mapper.getName().replace('.', '/') }); } else { cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, name, null, mapper.getName().replace('.', '/'), null); } // Copy the annotations copyAnnotations(mapper, cw, null); cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "delegate", QUERY_DELEGATE_TYPE.getDescriptor(), null, null); cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "configs", STATEMENT_CONFIGS_ARR_TYPE.getDescriptor(), null, null); if (mapper.isInterface()) { visitConstructor(cw, owner, OBJECT_TYPE); } else { visitConstructor(cw, owner, Type.getType(mapper)); } for (MethodConfig cfg : configs) { visitMethod(owner, cw, cfg); } cw.visitEnd(); return cw.toByteArray(); }
From source file:com.google.devtools.build.android.desugar.DefaultMethodClassFixer.java
License:Open Source License
/** * Returns {@code true} for non-bridge default methods not in {@link #instanceMethods}. */// ww w . ja va 2 s .c o m private boolean shouldStub(int access, String name, String desc) { // Ignore private methods, which technically aren't default methods and can only be called from // other methods defined in the interface. This also ignores lambda body methods, which is fine // as we don't want or need to stub those. Also ignore bridge methods as javac adds them to // concrete classes as needed anyway and we handle them separately for generated lambda classes. return BitFlags.noneSet(access, Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC | Opcodes.ACC_BRIDGE | Opcodes.ACC_PRIVATE) && !instanceMethods.contains(name + ":" + desc); }
From source file:com.google.devtools.build.android.desugar.InterfaceDesugaring.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor result;//from w ww. j a va 2 s . co m if (BitFlags.isSet(accessFlags, Opcodes.ACC_INTERFACE) && BitFlags.noneSet(access, Opcodes.ACC_ABSTRACT | Opcodes.ACC_BRIDGE) && !"<clinit>".equals(name)) { checkArgument(BitFlags.noneSet(access, Opcodes.ACC_NATIVE), "Forbidden per JLS ch 9.4"); boolean isLambdaBody = name.startsWith("lambda$") && BitFlags.isSet(access, Opcodes.ACC_SYNTHETIC); if (isLambdaBody) { access &= ~Opcodes.ACC_PUBLIC; // undo visibility change from LambdaDesugaring // Rename lambda method to reflect the new owner. Not doing so confuses LambdaDesugaring // if it's run over this class again. name += COMPANION_SUFFIX; } if (BitFlags.isSet(access, Opcodes.ACC_STATIC)) { // Completely move static interface methods, which requires rewriting call sites result = companion().visitMethod(access & ~Opcodes.ACC_PRIVATE, name, desc, signature, exceptions); } else { MethodVisitor abstractDest; if (isLambdaBody) { // Completely move lambda bodies, which requires rewriting call sites access &= ~Opcodes.ACC_PRIVATE; abstractDest = null; } else { // Make default methods abstract but move their implementation into a static method with // corresponding signature. Doesn't require callsite rewriting but implementing classes // may need to implement default methods explicitly. checkArgument(BitFlags.noneSet(access, Opcodes.ACC_PRIVATE), "Unexpected private interface method %s.%s : %s", name, internalName, desc); abstractDest = super.visitMethod(access | Opcodes.ACC_ABSTRACT, name, desc, signature, exceptions); } // TODO(b/37110951): adjust signature with explicit receiver type, which may be generic MethodVisitor codeDest = companion().visitMethod(access | Opcodes.ACC_STATIC, name, companionDefaultMethodDescriptor(internalName, desc), (String) null, // drop signature, since given one doesn't include the new param exceptions); result = abstractDest != null ? new MultiplexAnnotations(codeDest, abstractDest) : codeDest; } } else { result = super.visitMethod(access, name, desc, signature, exceptions); } return result != null ? new InterfaceInvocationRewriter(result) : null; }