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:net.fabricmc.base.transformer.AccessTransformer.java
License:Apache License
@Override public byte[] transform(String name, String transformedName, byte[] bytes) { if (!name.startsWith("net.minecraft")) { return bytes; }/* w w w . java 2 s .c o m*/ ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); boolean isClassProtected = classNode.access == Opcodes.ACC_PROTECTED; boolean isClassPrivate = classNode.access == Opcodes.ACC_PRIVATE; if (isClassProtected || isClassPrivate) { classNode.access = Opcodes.ACC_PUBLIC; } for (MethodNode method : classNode.methods) { boolean isProtected = method.access == Opcodes.ACC_PROTECTED; boolean isPrivate = method.access == Opcodes.ACC_PRIVATE; if (isProtected || isPrivate) { method.access = Opcodes.ACC_PUBLIC; } } for (FieldNode field : classNode.fields) { boolean isProtected = field.access == Opcodes.ACC_PROTECTED; boolean isPrivate = field.access == Opcodes.ACC_PRIVATE; if (isProtected || isPrivate) { field.access = Opcodes.ACC_PUBLIC; } } ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(writer); return writer.toByteArray(); }
From source file:net.sf.clirr.core.internal.asm.AbstractAsmScoped.java
License:Open Source License
public Scope getDeclaredScope() { if (checkFlag(Opcodes.ACC_PRIVATE)) { return Scope.PRIVATE; } else if (checkFlag(Opcodes.ACC_PROTECTED)) { return Scope.PROTECTED; } else if (checkFlag(Opcodes.ACC_PUBLIC)) { return Scope.PUBLIC; }// ww w .j ava2 s .co m return Scope.PACKAGE; }
From source file:net.sourceforge.cobertura.instrument.ClassInstrumenter.java
License:Open Source License
public void visitEnd() { if (instrument) { FieldVisitor visitor = super.visitField(Opcodes.ACC_PRIVATE & Opcodes.ACC_STATIC & Opcodes.ACC_FINAL, HAS_BEEN_INSTRUMENTED_FIELD_NAME, Type.BOOLEAN_TYPE.toString(), null, true); visitor.visitEnd();/* w ww .j a v a2 s. co m*/ } if (instrument && classData.getNumberOfValidLines() == 0) logger.warning("No line number information found for class " + this.myName + ". Perhaps you need to compile with debug=true?"); }
From source file:org.actorsguildframework.internal.codegenerator.ActorProxyCreator.java
License:Apache License
/** * Creates and loads the actor's proxy class. * @param actorClass the Actor class/*w w w. j a va 2 s .com*/ * @param acd the actor's class descriptor * @throws ConfigurationException if the agent is not configured correctly */ @SuppressWarnings("unchecked") private static Class<?> generateProxyClass(Class<?> actorClass, final ActorClassDescriptor acd) throws NoSuchMethodException { BeanClassDescriptor bcd = acd.getBeanClassDescriptor(); String className = String.format("%s__ACTORPROXY", actorClass.getName()); final String classNameInternal = className.replace('.', '/'); String classNameDescriptor = "L" + classNameInternal + ";"; final Type actorState = Type .getType(acd.getConcurrencyModel().isMultiThreadingCapable() ? MultiThreadedActorState.class : SingleThreadedActorState.class); ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); MethodVisitor mv; cw.visit(codeVersion, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER + Opcodes.ACC_SYNTHETIC, classNameInternal, null, Type.getInternalName(actorClass), new String[] { "org/actorsguildframework/internal/ActorProxy" }); cw.visitSource(null, null); { for (int i = 0; i < acd.getMessageCount(); i++) cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, String.format(MESSAGE_CALLER_NAME_FORMAT, i), "Lorg/actorsguildframework/internal/MessageCaller;", "Lorg/actorsguildframework/internal/MessageCaller<*>;", null).visitEnd(); cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, "actorState__ACTORPROXY", actorState.getDescriptor(), null, null).visitEnd(); } BeanCreator.writePropFields(bcd, cw); { mv = cw.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode(); for (int i = 0; i < acd.getMessageCount(); i++) { Class<?> caller = createMessageCaller(acd.getMessage(i).getOwnerClass(), acd.getMessage(i).getMethod()); String mcName = Type.getInternalName(caller); mv.visitTypeInsn(Opcodes.NEW, mcName); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, mcName, "<init>", "()V"); mv.visitFieldInsn(Opcodes.PUTSTATIC, classNameInternal, String.format(MESSAGE_CALLER_NAME_FORMAT, i), "Lorg/actorsguildframework/internal/MessageCaller;"); } mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } BeanCreator.writeConstructor(actorClass, bcd, classNameInternal, cw, new BeanCreator.SnippetWriter() { @Override public void write(MethodVisitor mv) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitTypeInsn(Opcodes.NEW, actorState.getInternalName()); mv.visitInsn(Opcodes.DUP); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, actorState.getInternalName(), "<init>", "(Lorg/actorsguildframework/internal/Controller;Lorg/actorsguildframework/Actor;)V"); mv.visitFieldInsn(Opcodes.PUTFIELD, classNameInternal, "actorState__ACTORPROXY", actorState.getDescriptor()); } }); BeanCreator.writePropAccessors(bcd, classNameInternal, cw); { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getState__ACTORPROXYMETHOD", "()Lorg/actorsguildframework/internal/ActorState;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, classNameInternal, "actorState__ACTORPROXY", actorState.getDescriptor()); mv.visitInsn(Opcodes.ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", classNameDescriptor, null, l0, l1, 0); mv.visitMaxs(0, 0); mv.visitEnd(); } for (int i = 0; i < acd.getMessageCount(); i++) { MessageImplDescriptor mid = acd.getMessage(i); Method method = mid.getMethod(); String simpleDescriptor = Type.getMethodDescriptor(method); String genericSignature = GenericTypeHelper.getSignature(method); writeProxyMethod(classNameInternal, classNameDescriptor, cw, i, actorState, acd.getConcurrencyModel(), mid, method, simpleDescriptor, genericSignature); writeSuperProxyMethod(actorClass, classNameDescriptor, cw, method, simpleDescriptor, genericSignature, !acd.getConcurrencyModel().isMultiThreadingCapable()); } { mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_SYNCHRONIZED, "toString", "()Ljava/lang/String;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "toString", "()Ljava/lang/String;"); mv.visitInsn(Opcodes.ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", classNameDescriptor, null, l0, l1, 0); mv.visitMaxs(0, 0); mv.visitEnd(); } cw.visitEnd(); try { return (Class<? extends ActorProxy>) GenerationUtils.loadClass(className, cw.toByteArray()); } catch (Exception e) { throw new ConfigurationException("Failure loading ActorProxy", e); } }
From source file:org.actorsguildframework.internal.codegenerator.BeanCreator.java
License:Apache License
/** * Write the fields of @Prop properties. * @param bcd the class descriptor/*from w w w. j ava 2 s . c o m*/ * @param cw the ClassWriter to write to */ public static void writePropFields(BeanClassDescriptor bcd, ClassWriter cw) { for (int i = 0; i < bcd.getPropertyCount(); i++) { PropertyDescriptor pd = bcd.getProperty(i); if (pd.getPropertySource() != PropertySource.ABSTRACT_METHOD) continue; cw.visitField(Opcodes.ACC_PRIVATE + (pd.getAccess().isWritable() ? 0 : Opcodes.ACC_FINAL), String.format(PROP_FIELD_NAME_TEMPLATE, pd.getName()), Type.getDescriptor(pd.getPropertyClass()), GenericTypeHelper.getSignature(pd.getPropertyType()), null).visitEnd(); } }
From source file:org.anon.smart.base.stt.asm.MethodEncloser.java
License:Open Source License
private void bcicall(MethodDet mthd) { if (_context.shouldBCI(mthd)) { super.visitVarInsn(ALOAD, 0); if (mthd.hasClazzParam()) super.visitLdcInsn(_context.descriptor().clazzName()); if (mthd.hasMthdParam()) super.visitLdcInsn(_context.name()); if ((mthd.access() & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) super.visitMethodInsn(INVOKESPECIAL, _context.descriptor().clazzName(), mthd.name(), mthd.signature());/*from w w w . j ava 2 s . com*/ else super.visitMethodInsn(INVOKEVIRTUAL, _context.descriptor().clazzName(), mthd.name(), mthd.signature()); } }
From source file:org.apache.asterix.runtime.evaluators.staticcodegen.EvaluatorMissingCheckVisitor.java
License:Apache License
@Override public void visitEnd() { if (cv != null) { cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, TYPE_CHECKER_NAME, TYPE_CHECKER_DESC, null, null);//from w ww.j a v a 2s . c o m cv.visitEnd(); } }
From source file:org.apache.commons.javaflow.providers.asm3.ContinuableClassVisitor.java
License:Apache License
@Override public void visitEnd() { if (!skipEnchancing) { super.visitField( (isInterface ? Opcodes.ACC_PUBLIC : Opcodes.ACC_PRIVATE) + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, MaybeContinuableClassVisitor.MARKER_FIELD_NAME, "Ljava/lang/String;", null, "A").visitEnd(); }/*from ww w .ja v a 2 s .c o m*/ super.visitEnd(); }
From source file:org.apache.commons.weaver.privilizer.ActionGenerator.java
License:Apache License
@SuppressWarnings("PMD.UseVarargs") //not needed private static Field[] fields(final Type[] args) { final Field[] result = new Field[args.length]; for (int i = 0; i < args.length; i++) { final String name = new StringBuilder("f").append(i + 1).toString(); result[i] = new Field(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, name, args[i]); }/*from w ww. ja va 2s. c om*/ return result; }
From source file:org.apache.commons.weaver.privilizer.ActionGenerator.java
License:Apache License
private void begin() { owner.visitInnerClass(action.getInternalName(), owner.className, simpleName, Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC); final SignatureWriter type = new SignatureWriter(); final SignatureVisitor actionImplemented = type.visitInterface(); actionImplemented.visitClassType(actionInterface.getInternalName()); final SignatureVisitor visitTypeArgument = actionImplemented.visitTypeArgument('='); new SignatureReader(Privilizer.wrap(methd.getReturnType()).getDescriptor()).accept(visitTypeArgument); actionImplemented.visitEnd();/*from w w w. j a va2s.c o m*/ final String signature = type.toString(); visit(Opcodes.V1_5, Opcodes.ACC_SUPER | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_FINAL, action.getInternalName(), signature, Type.getType(Object.class).getInternalName(), new String[] { actionInterface.getInternalName() }); }