Example usage for org.objectweb.asm Opcodes ACC_PUBLIC

List of usage examples for org.objectweb.asm Opcodes ACC_PUBLIC

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ACC_PUBLIC.

Prototype

int ACC_PUBLIC

To view the source code for org.objectweb.asm Opcodes ACC_PUBLIC.

Click Source Link

Usage

From source file:org.actorsguildframework.internal.codegenerator.BeanCreator.java

License:Apache License

/**
 * Writes the bean constructor to the given ClassWriter.
 * @param beanClass the original bean class to extend
 * @param bcd the descriptor of the bean
 * @param classNameInternal the internal name of the new class
 * @param cw the ClassWriter to write to
 * @param snippetWriter if not null, this will be invoked to add a snippet
 *                      after the invocation of the super constructor
 *//*from   ww w. j  a v  a 2  s .  c  o  m*/
public static void writeConstructor(Class<?> beanClass, BeanClassDescriptor bcd, String classNameInternal,
        ClassWriter cw, SnippetWriter snippetWriter) {
    String classNameDescriptor = "L" + classNameInternal + ";";

    int localPropertySize = 0;
    ArrayList<PropertyDescriptor> localVarProperties = new ArrayList<PropertyDescriptor>();
    for (int i = 0; i < bcd.getPropertyCount(); i++) {
        PropertyDescriptor pd = bcd.getProperty(i);
        if (pd.getPropertySource().isGenerating() || (pd.getDefaultValue() != null)) {
            localVarProperties.add(pd);
            localPropertySize += Type.getType(pd.getPropertyClass()).getSize();
        }
    }

    final int locVarThis = 0;
    final int locVarController = 1;
    final int locVarProps = 2;
    final int locVarPropertiesOffset = 3;
    final int locVarP = 3 + localPropertySize;
    final int locVarK = 4 + localPropertySize;
    final int locVarV = 5 + localPropertySize;

    MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>",
            "(Lorg/actorsguildframework/internal/Controller;Lorg/actorsguildframework/Props;)V", null, null);
    mv.visitCode();
    Label lTry = new Label();
    Label lCatch = new Label();
    mv.visitTryCatchBlock(lTry, lCatch, lCatch, "java/lang/ClassCastException");

    Label lBegin = new Label();
    mv.visitLabel(lBegin);
    mv.visitVarInsn(Opcodes.ALOAD, locVarThis);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(beanClass), "<init>", "()V");

    if (snippetWriter != null)
        snippetWriter.write(mv);

    Label lPropertyInit = new Label();
    mv.visitLabel(lPropertyInit);
    // load default values into the local variables for each property that must be set
    int varCount = 0;
    for (PropertyDescriptor pd : localVarProperties) {
        Type pt = Type.getType(pd.getPropertyClass());
        if (pd.getDefaultValue() != null)
            mv.visitFieldInsn(Opcodes.GETSTATIC, Type.getInternalName(pd.getDefaultValue().getDeclaringClass()),
                    pd.getDefaultValue().getName(), Type.getDescriptor(pd.getDefaultValue().getType()));
        else
            GenerationUtils.generateLoadDefault(mv, pd.getPropertyClass());
        mv.visitVarInsn(pt.getOpcode(Opcodes.ISTORE), locVarPropertiesOffset + varCount);
        varCount += pt.getSize();
    }

    // loop through the props argument's list
    mv.visitVarInsn(Opcodes.ALOAD, locVarProps);
    mv.visitVarInsn(Opcodes.ASTORE, locVarP);
    Label lWhile = new Label();
    Label lEndWhile = new Label();
    Label lWhileBody = new Label();
    mv.visitLabel(lWhile);
    mv.visitJumpInsn(Opcodes.GOTO, lEndWhile);
    mv.visitLabel(lWhileBody);

    mv.visitVarInsn(Opcodes.ALOAD, locVarP);
    mv.visitInsn(Opcodes.DUP);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "org/actorsguildframework/Props", "getKey",
            "()Ljava/lang/String;");
    mv.visitVarInsn(Opcodes.ASTORE, locVarK);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "org/actorsguildframework/Props", "getValue",
            "()Ljava/lang/Object;");
    mv.visitVarInsn(Opcodes.ASTORE, locVarV);

    mv.visitLabel(lTry);
    // write an if for each property
    Label lEndIf = new Label();
    varCount = 0;
    int ifCount = 0;
    for (int i = 0; i < bcd.getPropertyCount(); i++) {
        PropertyDescriptor pd = bcd.getProperty(i);
        boolean usesLocal = pd.getPropertySource().isGenerating() || (pd.getDefaultValue() != null);
        Class<?> propClass = pd.getPropertyClass();
        Type pt = Type.getType(propClass);
        mv.visitVarInsn(Opcodes.ALOAD, locVarK);
        mv.visitLdcInsn(pd.getName());
        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z");
        Label lElse = new Label();
        mv.visitJumpInsn(Opcodes.IFEQ, lElse);

        if (!usesLocal)
            mv.visitVarInsn(Opcodes.ALOAD, locVarThis); // for setter invocation, load 'this'

        if (propClass.isPrimitive()) {
            mv.visitLdcInsn(pd.getName());
            mv.visitVarInsn(Opcodes.ALOAD, locVarV);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(BeanHelper.class),
                    String.format("get%s%sFromPropValue",
                            propClass.getName().substring(0, 1).toUpperCase(Locale.US),
                            propClass.getName().substring(1)),
                    "(Ljava/lang/String;Ljava/lang/Object;)" + pt.getDescriptor());
        } else if (!propClass.equals(Object.class)) {
            mv.visitVarInsn(Opcodes.ALOAD, locVarV);
            mv.visitTypeInsn(Opcodes.CHECKCAST, pt.getInternalName());
        } else
            mv.visitVarInsn(Opcodes.ALOAD, locVarV);

        if (!usesLocal)
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classNameInternal, pd.getSetter().getName(),
                    Type.getMethodDescriptor(pd.getSetter()));
        else
            mv.visitVarInsn(pt.getOpcode(Opcodes.ISTORE), varCount + locVarPropertiesOffset);

        mv.visitJumpInsn(Opcodes.GOTO, lEndIf);
        mv.visitLabel(lElse);

        ifCount++;
        if (usesLocal)
            varCount += pt.getSize();
    }

    // else (==> if not prop matched) throw IllegalArgumentException
    mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(IllegalArgumentException.class));
    mv.visitInsn(Opcodes.DUP);
    mv.visitLdcInsn("Unknown property \"%s\".");
    mv.visitInsn(Opcodes.ICONST_1);
    mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
    mv.visitInsn(Opcodes.DUP);
    mv.visitInsn(Opcodes.ICONST_0);
    mv.visitVarInsn(Opcodes.ALOAD, locVarK);
    mv.visitInsn(Opcodes.AASTORE);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/String", "format",
            "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(IllegalArgumentException.class), "<init>",
            "(Ljava/lang/String;)V");
    mv.visitInsn(Opcodes.ATHROW);

    mv.visitLabel(lCatch);
    mv.visitInsn(Opcodes.POP); // pop the exception object (not needed)
    mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(IllegalArgumentException.class));
    mv.visitInsn(Opcodes.DUP);
    mv.visitLdcInsn("Incompatible type for property \"%s\". Got %s.");
    mv.visitInsn(Opcodes.ICONST_2);
    mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
    mv.visitInsn(Opcodes.DUP);
    mv.visitInsn(Opcodes.ICONST_0);
    mv.visitVarInsn(Opcodes.ALOAD, locVarK);
    mv.visitInsn(Opcodes.AASTORE);
    mv.visitInsn(Opcodes.DUP);
    mv.visitInsn(Opcodes.ICONST_1);
    mv.visitVarInsn(Opcodes.ALOAD, locVarV);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;");
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Class", "getName", "()Ljava/lang/String;");
    mv.visitInsn(Opcodes.AASTORE);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/String", "format",
            "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(IllegalArgumentException.class), "<init>",
            "(Ljava/lang/String;)V");
    mv.visitInsn(Opcodes.ATHROW);

    mv.visitLabel(lEndIf);
    mv.visitVarInsn(Opcodes.ALOAD, locVarP);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "org/actorsguildframework/Props", "tail",
            "()Lorg/actorsguildframework/Props;");
    mv.visitVarInsn(Opcodes.ASTORE, locVarP);

    mv.visitLabel(lEndWhile);
    mv.visitVarInsn(Opcodes.ALOAD, locVarP);
    mv.visitJumpInsn(Opcodes.IFNONNULL, lWhileBody);

    // write local variables back into properties 
    varCount = 0;
    for (PropertyDescriptor pd : localVarProperties) {
        Type pt = Type.getType(pd.getPropertyClass());
        mv.visitVarInsn(Opcodes.ALOAD, locVarThis);
        if (pd.getPropertySource() == PropertySource.ABSTRACT_METHOD) {
            mv.visitVarInsn(pt.getOpcode(Opcodes.ILOAD), locVarPropertiesOffset + varCount);
            mv.visitFieldInsn(Opcodes.PUTFIELD, classNameInternal,
                    String.format(PROP_FIELD_NAME_TEMPLATE, pd.getName()), pt.getDescriptor());
        } else if (pd.getPropertySource() == PropertySource.USER_WRITTEN) {
            mv.visitVarInsn(pt.getOpcode(Opcodes.ILOAD), locVarPropertiesOffset + varCount);
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classNameInternal, pd.getSetter().getName(),
                    Type.getMethodDescriptor(pd.getSetter()));
        } else
            throw new RuntimeException("Internal error");
        varCount += pt.getSize();
    }

    // if bean is thread-safe, publish all writes now
    if (bcd.isThreadSafe()) {
        mv.visitVarInsn(Opcodes.ALOAD, locVarThis);
        mv.visitInsn(Opcodes.DUP);
        mv.visitInsn(Opcodes.MONITORENTER);
        mv.visitInsn(Opcodes.MONITOREXIT);
    }

    mv.visitInsn(Opcodes.RETURN);
    Label lEnd = new Label();
    mv.visitLabel(lEnd);

    mv.visitLocalVariable("this", classNameDescriptor, null, lBegin, lEnd, locVarThis);
    mv.visitLocalVariable("controller", "Lorg/actorsguildframework/internal/Controller;", null, lBegin, lEnd,
            locVarController);
    mv.visitLocalVariable("props", "Lorg/actorsguildframework/Props;", null, lBegin, lEnd, locVarProps);
    varCount = 0;
    for (PropertyDescriptor pd : localVarProperties) {
        Type pt = Type.getType(pd.getPropertyClass());
        mv.visitLocalVariable("__" + pd.getName(), pt.getDescriptor(),
                GenericTypeHelper.getSignature(pd.getPropertyType()), lPropertyInit, lEnd,
                locVarPropertiesOffset + varCount);
        varCount += pt.getSize();
    }
    mv.visitLocalVariable("p", "Lorg/actorsguildframework/Props;", null, lPropertyInit, lEnd, locVarP);
    mv.visitLocalVariable("k", "Ljava/lang/String;", null, lWhile, lEndWhile, locVarK);
    mv.visitLocalVariable("v", "Ljava/lang/Object;", null, lWhile, lEndWhile, locVarV);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}

From source file:org.apache.asterix.runtime.evaluators.staticcodegen.GatherInnerClassVisitor.java

License:Apache License

@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
    if ((className == null || !name.equals(className))
            && ((access & Opcodes.ACC_PUBLIC) == 0 || (access & Opcodes.ACC_STATIC) == 0)) {
        innerClassNames.add(name);//  ww  w  .  jav  a 2 s . c  om
    }
}

From source file:org.apache.asterix.runtime.evaluators.staticcodegen.RenameClassVisitor.java

License:Apache License

@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
    if ((access & Opcodes.ACC_PUBLIC) != 0 && (access & Opcodes.ACC_STATIC) != 0) {
        super.visitInnerClass(name, outerName, innerName, access);
    }/* w ww.  jav  a  2  s  .  c o m*/
}

From source file:org.apache.cassandra.cql3.functions.UDFByteCodeVerifier.java

License:Apache License

public Set<String> verify(byte[] bytes) {
    Set<String> errors = new TreeSet<>(); // it's a TreeSet for unit tests
    ClassVisitor classVisitor = new ClassVisitor(Opcodes.ASM5) {
        public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
            errors.add("field declared: " + name);
            return null;
        }/*from ww w.  j  a v a 2  s  .  co m*/

        public MethodVisitor visitMethod(int access, String name, String desc, String signature,
                String[] exceptions) {
            if ("<init>".equals(name) && CTOR_SIG.equals(desc)) {
                if (Opcodes.ACC_PUBLIC != access)
                    errors.add("constructor not public");
                // allowed constructor - JavaUDF(TypeCodec returnCodec, TypeCodec[] argCodecs)
                return new ConstructorVisitor(errors);
            }
            if ("executeImpl".equals(name) && "(ILjava/util/List;)Ljava/nio/ByteBuffer;".equals(desc)) {
                if (Opcodes.ACC_PROTECTED != access)
                    errors.add("executeImpl not protected");
                // the executeImpl method - ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params)
                return new ExecuteImplVisitor(errors);
            }
            if ("<clinit>".equals(name)) {
                errors.add("static initializer declared");
            } else {
                errors.add("not allowed method declared: " + name + desc);
                return new ExecuteImplVisitor(errors);
            }
            return null;
        }

        public void visit(int version, int access, String name, String signature, String superName,
                String[] interfaces) {
            if (!JAVA_UDF_NAME.equals(superName)) {
                errors.add("class does not extend " + JavaUDF.class.getName());
            }
            if (access != (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER)) {
                errors.add("class not public final");
            }
            super.visit(version, access, name, signature, superName, interfaces);
        }

        public void visitInnerClass(String name, String outerName, String innerName, int access) {
            errors.add("class declared as inner class");
            super.visitInnerClass(name, outerName, innerName, access);
        }
    };

    ClassReader classReader = new ClassReader(bytes);
    classReader.accept(classVisitor, ClassReader.SKIP_DEBUG);

    return errors;
}

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  va 2s . c om
    super.visitEnd();
}

From source file:org.apache.commons.weaver.normalizer.Normalizer.java

License:Apache License

/**
 * Create the normalized version of a given class in the configured target package. The {@link Normalizer} will
 * gladly do so in a package from which the normalized class will not actually be able to reference any types upon
 * which it relies; in such a situation you must specify the target package as the package of the supertype.
 * @param key used to generate the normalized classname.
 * @param classWrapper/*w  w w.j a  va 2 s.c o  m*/
 * @return the generated classname.
 * @throws IOException
 */
private String copy(final Pair<String, String> key, final ClassWrapper classWrapper) throws IOException {
    env.debug("Copying %s to %s", key, targetPackage);
    final MessageDigest md5;
    try {
        md5 = MessageDigest.getInstance("MD5");
    } catch (final NoSuchAlgorithmException e) {
        throw new IllegalStateException(e);
    }
    md5.update(key.getLeft().getBytes(StandardCharsets.UTF_8));
    md5.update(key.getRight().getBytes(StandardCharsets.UTF_8));

    final long digest = Conversion.byteArrayToLong(md5.digest(), 0, 0L, 0, Long.SIZE / Byte.SIZE);

    final String result = MessageFormat.format("{0}/$normalized{1,number,0;_0}", targetPackage, digest);

    env.debug("Copying class %s to %s", classWrapper.wrapped.getName(), result);

    try (InputStream bytecode = env.getClassfile(classWrapper.wrapped).getInputStream()) {
        final ClassReader reader = new ClassReader(bytecode);
        final ClassVisitor writeClass = new WriteClass();

        // we're doing most of this by hand; we only read the original class to hijack signature, ctor exceptions,
        // etc.:

        reader.accept(new ClassVisitor(ASM_VERSION) {
            Type supertype;

            @Override
            @SuppressWarnings("PMD.UseVarargs") //overridden method
            public void visit(final int version, final int access, final String name, final String signature,
                    final String superName, final String[] interfaces) {
                supertype = Type.getObjectType(superName);
                writeClass.visit(version, Opcodes.ACC_PUBLIC, result, signature, superName, interfaces);
                visitAnnotation(Type.getType(Marker.class).getDescriptor(), false);
            }

            @Override
            @SuppressWarnings("PMD.UseVarargs") //overridden method
            public MethodVisitor visitMethod(final int access, final String name, final String desc,
                    final String signature, final String[] exceptions) {
                if (INIT.equals(name)) {
                    final Method staticCtor = new Method(INIT, key.getRight());
                    final Type[] argumentTypes = staticCtor.getArgumentTypes();
                    final Type[] exceptionTypes = toObjectTypes(exceptions);

                    {
                        final GeneratorAdapter mgen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, staticCtor,
                                signature, exceptionTypes, writeClass);
                        mgen.visitCode();
                        mgen.loadThis();
                        for (int i = 0; i < argumentTypes.length; i++) {
                            mgen.loadArg(i);
                        }
                        mgen.invokeConstructor(supertype, staticCtor);
                        mgen.returnValue();
                        mgen.endMethod();
                    }
                    /*
                     * now declare a dummy constructor that will match, and discard,
                     * any originally inner-class bound constructor i.e. that set up a this$0 field.
                     * By doing this we can avoid playing with the stack that originally
                     * invoked such a constructor and simply rewrite the method
                     */
                    {
                        final Method instanceCtor = new Method(INIT, Type.VOID_TYPE,
                                ArrayUtils.insert(0, argumentTypes, OBJECT_TYPE));
                        final GeneratorAdapter mgen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, instanceCtor,
                                signature, exceptionTypes, writeClass);
                        mgen.visitCode();
                        mgen.loadThis();
                        for (int i = 0; i < argumentTypes.length; i++) {
                            mgen.loadArg(i + 1);
                        }
                        mgen.invokeConstructor(supertype, staticCtor);
                        mgen.returnValue();
                        mgen.endMethod();
                    }
                    return null;
                }
                return null;
            }

            @Override
            public void visitEnd() {
                writeClass.visitEnd();
            }
        }, 0);
    }
    return result;
}

From source file:org.apache.commons.weaver.privilizer.ActionGenerator.java

License:Apache License

/**
 * Generate impl method.//from  ww w. ja va  2s .c  o  m
 */
private void impl() {
    final Method run = Method.getMethod("Object run()");

    final GeneratorAdapter mgen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, run, null, exceptions, this);

    for (final Field field : fields) {
        mgen.loadThis();
        mgen.getField(action, field.name, field.type);
    }
    mgen.invokeStatic(owner.target, helper);

    if (methd.getReturnType().getSort() < Type.ARRAY) {
        mgen.valueOf(methd.getReturnType());
    }
    mgen.returnValue();
    mgen.endMethod();
}

From source file:org.apache.cxf.binding.corba.utils.CorbaAnyHelper.java

License:Apache License

private static synchronized void createFixedAnyConstructor() {
    if (fixedAnyConstructor != null) {
        return;/*from   www  .j  a  v a 2 s  .com*/
    }

    ASMHelper helper = new ASMHelper();
    ClassWriter cw = helper.createClassWriter();
    FieldVisitor fv;

    cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER,
            "org/apache/cxf/binding/corba/utils/FixedAnyImpl", null, "com/sun/corba/se/impl/corba/AnyImpl",
            null);

    cw.visitSource("FixedAnyImpl.java", null);

    fv = cw.visitField(0, "obj", "Lorg/omg/CORBA/portable/Streamable;", null, null);
    fv.visitEnd();
    addFixedAnyConstructor(cw);
    addInsertOverride(cw);
    addExtractOverride(cw);
    addReadOverride(cw);
    addWriteOverride(cw);

    cw.visitEnd();

    byte[] b = cw.toByteArray();
    Class<?> c = helper.loadClass("org.apache.cxf.binding.corba.utils.FixedAnyImpl", CorbaAnyHelper.class, b);
    try {
        fixedAnyConstructor = c.getConstructor(ORB.class, Any.class);
    } catch (Exception e) {
        //shouldn't happen since we generated that constructor
    }
}

From source file:org.apache.cxf.binding.corba.utils.CorbaAnyHelper.java

License:Apache License

private static void addReadOverride(ClassWriter cw) {
    MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "read_value",
            "(Lorg/omg/CORBA/portable/InputStream;Lorg/omg/CORBA/TypeCode;)V", null, null);
    mv.visitCode();/*from  www.j a v  a 2  s.  co  m*/
    Label l0 = new Label();
    mv.visitLabel(l0);
    mv.visitLineNumber(54, l0);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitFieldInsn(Opcodes.GETFIELD, "org/apache/cxf/binding/corba/utils/FixedAnyImpl", "obj",
            "Lorg/omg/CORBA/portable/Streamable;");
    Label l1 = new Label();
    mv.visitJumpInsn(Opcodes.IFNULL, l1);
    Label l2 = new Label();
    mv.visitLabel(l2);
    mv.visitLineNumber(55, l2);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitFieldInsn(Opcodes.GETFIELD, "org/apache/cxf/binding/corba/utils/FixedAnyImpl", "obj",
            "Lorg/omg/CORBA/portable/Streamable;");
    mv.visitVarInsn(Opcodes.ALOAD, 1);
    mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "org/omg/CORBA/portable/Streamable", "_read",
            "(Lorg/omg/CORBA/portable/InputStream;)V");
    Label l3 = new Label();
    mv.visitJumpInsn(Opcodes.GOTO, l3);
    mv.visitLabel(l1);
    mv.visitLineNumber(57, l1);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitVarInsn(Opcodes.ALOAD, 1);
    mv.visitVarInsn(Opcodes.ALOAD, 2);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "com/sun/corba/se/impl/corba/AnyImpl", "read_value",
            "(Lorg/omg/CORBA/portable/InputStream;Lorg/omg/CORBA/TypeCode;)V");
    mv.visitLabel(l3);
    mv.visitLineNumber(59, l3);
    mv.visitInsn(Opcodes.RETURN);
    Label l4 = new Label();
    mv.visitLabel(l4);
    mv.visitLocalVariable("this", "Lorg/apache/cxf/binding/corba/utils/FixedAnyImpl;", null, l0, l4, 0);
    mv.visitLocalVariable("is", "Lorg/omg/CORBA/portable/InputStream;", null, l0, l4, 1);
    mv.visitLocalVariable("t", "Lorg/omg/CORBA/TypeCode;", null, l0, l4, 2);
    mv.visitMaxs(3, 3);
    mv.visitEnd();
}

From source file:org.apache.cxf.binding.corba.utils.CorbaAnyHelper.java

License:Apache License

private static void addWriteOverride(ClassWriter cw) {
    MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "write_value",
            "(Lorg/omg/CORBA/portable/OutputStream;)V", null, null);
    mv.visitCode();//from  w  w  w .  j  a v  a  2 s . c  om
    Label l0 = new Label();
    mv.visitLabel(l0);
    mv.visitLineNumber(61, l0);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitFieldInsn(Opcodes.GETFIELD, "org/apache/cxf/binding/corba/utils/FixedAnyImpl", "obj",
            "Lorg/omg/CORBA/portable/Streamable;");
    Label l1 = new Label();
    mv.visitJumpInsn(Opcodes.IFNULL, l1);
    Label l2 = new Label();
    mv.visitLabel(l2);
    mv.visitLineNumber(62, l2);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitFieldInsn(Opcodes.GETFIELD, "org/apache/cxf/binding/corba/utils/FixedAnyImpl", "obj",
            "Lorg/omg/CORBA/portable/Streamable;");
    mv.visitVarInsn(Opcodes.ALOAD, 1);
    mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "org/omg/CORBA/portable/Streamable", "_write",
            "(Lorg/omg/CORBA/portable/OutputStream;)V");
    Label l3 = new Label();
    mv.visitJumpInsn(Opcodes.GOTO, l3);
    mv.visitLabel(l1);
    mv.visitLineNumber(64, l1);
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitVarInsn(Opcodes.ALOAD, 1);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "com/sun/corba/se/impl/corba/AnyImpl", "write_value",
            "(Lorg/omg/CORBA/portable/OutputStream;)V");
    mv.visitLabel(l3);
    mv.visitLineNumber(66, l3);
    mv.visitInsn(Opcodes.RETURN);
    Label l4 = new Label();
    mv.visitLabel(l4);
    mv.visitLocalVariable("this", "Lorg/apache/cxf/binding/corba/utils/FixedAnyImpl;", null, l0, l4, 0);
    mv.visitLocalVariable("os", "Lorg/omg/CORBA/portable/OutputStream;", null, l0, l4, 1);
    mv.visitMaxs(2, 2);
    mv.visitEnd();

}