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.google.devtools.build.android.desugar.LambdaClassFixer.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (name.equals("writeReplace") && BitFlags.noneSet(access, Opcodes.ACC_STATIC) && desc.equals("()Ljava/lang/Object;")) { // Lambda serialization hooks use java/lang/invoke/SerializedLambda, which isn't available on // Android. Since Jack doesn't do anything special for serializable lambdas we just drop these // serialization hooks. // https://docs.oracle.com/javase/8/docs/platform/serialization/spec/output.html#a5324 gives // details on the role and signature of this method. return null; }/*ww w . j a v a2s. c o m*/ if (BitFlags.noneSet(access, Opcodes.ACC_ABSTRACT | Opcodes.ACC_STATIC)) { // Keep track of instance methods implemented in this class for later. Since this visitor // is intended for lambda classes, no need to look at the superclass. implementedMethods.add(name + ":" + desc); } if (FACTORY_METHOD_NAME.equals(name)) { hasFactory = true; if (!lambdaInfo.needFactory()) { return null; // drop generated factory method if we won't call it } access &= ~Opcodes.ACC_PRIVATE; // make factory method accessible } else if ("<init>".equals(name)) { this.desc = desc; this.signature = signature; if (!lambdaInfo.needFactory() && !desc.startsWith("()")) { access &= ~Opcodes.ACC_PRIVATE; // make constructor accessible if we'll call it directly } } MethodVisitor methodVisitor = new LambdaClassMethodRewriter( super.visitMethod(access, name, desc, signature, exceptions)); if (!lambdaInfo.bridgeMethod().equals(lambdaInfo.methodReference())) { // Skip UseBridgeMethod unless we actually need it methodVisitor = new UseBridgeMethod(methodVisitor, lambdaInfo, access, name, desc, signature, exceptions); } if (!FACTORY_METHOD_NAME.equals(name) && !"<init>".equals(name)) { methodVisitor = new LambdaClassInvokeSpecialRewriter(methodVisitor); } return methodVisitor; }
From source file:com.google.devtools.build.android.desugar.LambdaDesugaring.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (name.equals("$deserializeLambda$") && BitFlags.isSet(access, Opcodes.ACC_SYNTHETIC)) { // Android doesn't do anything special for lambda serialization so drop the special // deserialization hook that javac generates. This also makes sure we don't reference // java/lang/invoke/SerializedLambda, which doesn't exist on Android. return null; }// w w w. j a v a2 s .co m if (name.startsWith("lambda$") && BitFlags.isSet(access, Opcodes.ACC_SYNTHETIC)) { if (!allowDefaultMethods && isInterface && BitFlags.isSet(access, Opcodes.ACC_STATIC)) { // There must be a lambda in the interface (which in the absence of hand-written default or // static interface methods must mean it's in the <clinit> method or inside another lambda). // We'll move this method out of this class, so just record and drop it here. // (Note lambda body methods have unique names, so we don't need to remember desc here.) aggregateInterfaceLambdaMethods.add(internalName + '#' + name); return null; } if (BitFlags.isSet(access, Opcodes.ACC_PRIVATE)) { // Make lambda body method accessible from lambda class access &= ~Opcodes.ACC_PRIVATE; if (allowDefaultMethods && isInterface) { // java 8 requires interface methods to have exactly one of ACC_PUBLIC and ACC_PRIVATE access |= Opcodes.ACC_PUBLIC; } else { // Method was private so it can be final, which should help VMs perform dispatch. access |= Opcodes.ACC_FINAL; } } // Guarantee unique lambda body method name to avoid accidental overriding. This wouldn't be // be necessary for static methods but in visitOuterClass we don't know whether a potential // outer lambda$ method is static or not, so we just always do it. name = uniqueInPackage(internalName, name); } MethodVisitor dest = super.visitMethod(access, name, desc, signature, exceptions); return dest != null ? new InvokedynamicRewriter(dest, access, name, desc, signature, exceptions) : null; }
From source file:com.google.devtools.build.wireless.testing.java.injector.StackServantTest.java
License:Apache License
/** * Tests {@link StackServant#getArgumentSize()} and * {@link StackServant#getArgumentTypeAt(int)}. *//*w ww.j a v a 2 s . c o m*/ public void testGetArguments() { StackServant servant = null; StringBuilder builder = new StringBuilder(); for (int i = 0; i < symbols.length; i++) { for (int j = 0; j < i; j++) { builder.append(symbols[j]); } servant = new StackServant(null, Opcodes.ACC_PRIVATE, "(" + builder.toString() + ")V"); assertEquals("Wrong arguments size.", i, servant.getArgumentSize()); for (int j = 0; j < i; j++) { assertEquals("Wrong arguments at index.", symbols[j], servant.getArgumentTypeAt(j)); } builder.setLength(0); } }
From source file:com.google.singletondetector.visitors.SingletonClassVisitor.java
License:Apache License
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { if ((access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) { if ((access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) { sd.visitStaticField(name, desc); }/*from ww w . j av a 2 s . c o m*/ if ((access & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE && (access & Opcodes.ACC_FINAL) != Opcodes.ACC_FINAL) { sd.addStaticField(name, desc); } } return null; }
From source file:com.google.template.soy.jbcsrc.FieldRef.java
License:Apache License
static FieldRef createFinalField(TypeInfo owner, String name, Type type) { return new AutoValue_FieldRef(owner, name, type, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, !BytecodeUtils.isPrimitive(type)); }
From source file:com.google.template.soy.jbcsrc.FieldRef.java
License:Apache License
static FieldRef createField(TypeInfo owner, String name, Type type) { return new AutoValue_FieldRef(owner, name, type, Opcodes.ACC_PRIVATE, !BytecodeUtils.isPrimitive(type)); }
From source file:com.google.template.soy.jbcsrc.restricted.FieldRef.java
License:Apache License
public static FieldRef createFinalField(TypeInfo owner, String name, Type type) { return new AutoValue_FieldRef(owner, name, type, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, !BytecodeUtils.isPrimitive(type)); }
From source file:com.google.template.soy.jbcsrc.restricted.FieldRef.java
License:Apache License
public static FieldRef createField(TypeInfo owner, String name, Type type) { return new AutoValue_FieldRef(owner, name, type, Opcodes.ACC_PRIVATE, !BytecodeUtils.isPrimitive(type)); }
From source file:com.google.template.soy.jbcsrc.TemplateVariableManager.java
License:Apache License
/** * Adds a private static final field and returns a reference to it. * * @param proposedName The proposed name, the actual name will be this plus an optional suffix * to ensure uniqueness//from w w w. j a v a 2 s .co m * @param initializer An expression to initialize the field. */ FieldRef addStaticField(String proposedName, Expression initializer) { String name = fieldNames.generateName(proposedName); FieldRef ref = new AutoValue_FieldRef(owner, name, initializer.resultType(), Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE, !initializer.isNonNullable()); staticFields.add(new AutoValue_TemplateVariableManager_StaticFieldVariable(ref, initializer)); return ref; }
From source file:com.google.template.soy.jbcsrc.VariableSet.java
License:Apache License
/** * Adds a private static final field and returns a reference to it. * * @param proposedName The proposed name, the actual name will be this plus an optional suffix * to ensure uniqueness/*ww w . j a v a 2 s. co m*/ * @param initializer An expression to initialize the field. */ FieldRef addStaticField(String proposedName, Expression initializer) { String name = fieldNames.generateName(proposedName); FieldRef ref = new AutoValue_FieldRef(owner, name, initializer.resultType(), Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE, !initializer.isNonNullable()); staticFields.add(new AutoValue_VariableSet_StaticFieldVariable(ref, initializer)); return ref; }