Package org.mvel2.asm

Examples of org.mvel2.asm.ClassWriter


                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getReaderSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        //        buildConstructor( superClass,
        //                          className,
        //                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildGetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here


                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getWriterSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildSetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        fieldType,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

            throw new RuntimeException( "FATAL : Trying to create an enum out of a bean class definition  " + classDef );
        }

        EnumClassDefinition edef = (EnumClassDefinition) classDef;

        ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );

        this.buildClassHeader( cw,
                edef );

        this.buildLiterals(cw,
                edef);

        this.buildFields( cw,
                edef );


        this.buildConstructors( cw,
                edef );

        this.buildGettersAndSetters( cw,
                edef );

        this.buildEqualityMethods( cw,
                edef );

        this.buildToString( cw,
                edef );

        cw.visitEnd();

        byte[] serializedClass = cw.toByteArray();

        return serializedClass;
    }
View Full Code Here

    public byte[] buildClass( ClassDefinition classDef ) {

        init( classDef );

        ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );


        try {
            String cName = BuildUtils.getInternalType(classDef.getClassName());
            String genericTypes = BuildUtils.getGenericTypes( classDef.getInterfaces() );
            String superType = Type.getInternalName( Object.class );
            String[] intfaces = null;
           
            if ( Object.class.getName().equals( classDef.getSuperClass() ) ) {
                String[] tmp = BuildUtils.getInternalTypes( classDef.getInterfaces() );
                intfaces = new String[ tmp.length + 2 ];
                System.arraycopy( tmp, 0, intfaces, 0, tmp.length );
                intfaces[ tmp.length ] = Type.getInternalName( Serializable.class );
                intfaces[ tmp.length + 1 ] = Type.getInternalName( GeneratedFact.class );
            } else {
                String[] tmp = BuildUtils.getInternalTypes( classDef.getInterfaces() );
                intfaces = new String[ tmp.length + 3 ];
                System.arraycopy( tmp, 0, intfaces, 0, tmp.length );
                intfaces[ tmp.length ] = BuildUtils.getInternalType( classDef.getSuperClass() );
                intfaces[ tmp.length + 1 ] = Type.getInternalName( Serializable.class );
                intfaces[ tmp.length + 2 ] = Type.getInternalName( GeneratedFact.class );
            }

            cw.visit( V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE,
                    cName,
                    genericTypes,
                    superType,
                    intfaces );

            {
                if ( classDef.getDefinedClass() == null || classDef.getDefinedClass().getAnnotation( Trait.class ) == null ) {
                    AnnotationVisitor av0 = cw.visitAnnotation( Type.getDescriptor( Trait.class ), true);
                    av0.visitEnd();
                }
            }

            for ( FieldDefinition field : classDef.getFieldsDefinitions() ) {
                buildField( cw, field );
            }

            finalizeCreation( classDef );

            cw.visitEnd();
        } catch ( Exception e ) {
            e.printStackTrace();
        }

        return cw.toByteArray();
    }
View Full Code Here

                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getReaderSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        //        buildConstructor( superClass,
        //                          className,
        //                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildGetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getWriterSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildSetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        fieldType,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getReaderSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        //        buildConstructor( superClass,
        //                          className,
        //                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildGetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getWriterSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildSetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        fieldType,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getReaderSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        //        buildConstructor( superClass,
        //                          className,
        //                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildGetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

                              final String className,
                              final Method getterMethod,
                              final Class< ? > fieldType,
                              final boolean isInterface) throws Exception {

        final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS );

        final Class< ? > superClass = getWriterSuperClassFor( fieldType );
        buildClassHeader( superClass,
                          className,
                          cw );

        build3ArgConstructor( superClass,
                              className,
                              cw );

        buildSetMethod( originalClass,
                        className,
                        superClass,
                        getterMethod,
                        fieldType,
                        cw );

        cw.visitEnd();

        return cw.toByteArray();
    }
View Full Code Here

TOP

Related Classes of org.mvel2.asm.ClassWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.