Package com.sun.org.apache.bcel.internal.generic

Examples of com.sun.org.apache.bcel.internal.generic.ClassGen


  private GenJavaClass(ClassDef classDef) {
    String class_name = classDef.name.toString() ;
    String super_class_name = classDef.superClass.toString();
    String[] interfaces = getInterfaceArray(classDef);
    int access_flags = getClassAccessFlags(classDef);
    ClassGen classGen = new ClassGen(class_name,super_class_name,classDef.fileName,
        access_flags, interfaces);
    instructionFactory = new InstructionFactory(classGen) ;
    classGen.setMajor(50) ;
    classGen.setMinor(0) ;
  }
View Full Code Here


        String classFileName = classFile.getName();
        className = classFileName.substring(0,
                classFileName.length() - CLASS_FILENAME_SUFFIX.length());

        // Create an empty class.
        ClassGen cg = new ClassGen(className, "java.lang.Object",
                "<generated>", ACC_PUBLIC, null);
        cg.addEmptyConstructor(ACC_PUBLIC);

        // Create a class file from the empty class.
        try {
            cg.getJavaClass().dump(classFile);
        } catch (IOException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }

        // Create a JAR containing the empty class.
        JarOutputStream jar;
        try {
            jarFile = File.createTempFile(FILENAME_PREFIX, JAR_FILENAME_SUFFIX);
            jarFile.deleteOnExit();
            String jarFileName = jarFile.getName();
            jarClassName = jarFileName.substring(0,
                    jarFileName.length() - JAR_FILENAME_SUFFIX.length());

            cg = new ClassGen(jarClassName, "java.lang.Object",
                "<generated>", ACC_PUBLIC, null);
            cg.addEmptyConstructor(ACC_PUBLIC);

            jar = new JarOutputStream(new FileOutputStream(jarFile));
            JarEntry entry = new JarEntry(jarClassName + ".class");
            jar.putNextEntry(entry);
            jar.write(cg.getJavaClass().getBytes());
            jar.close();
        } catch (IOException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
View Full Code Here

TOP

Related Classes of com.sun.org.apache.bcel.internal.generic.ClassGen

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.