Package org.apache.jdo.impl.enhancer.classfile

Examples of org.apache.jdo.impl.enhancer.classfile.ClassFile


                dis = new DataInputStream(openClassInputStream(className));
            } else {
                dis = new DataInputStream(openFileInputStream(classFileName));
            }
            final boolean allowJDK12ClassFiles = true;
            classFile = new ClassFile(dis, allowJDK12ClassFiles);

            // check user class name from ClassFile
            final String userClassName
                = classFile.className().asString().replace('/', '.');
            //^olsen: better throw user exception or error
View Full Code Here


                dis = new DataInputStream(openClassInputStream(className));
            } else {
                dis = new DataInputStream(openFileInputStream(classFileName));
            }
            final boolean allowJDK12ClassFiles = true;
            final ClassFile classFile
                = new ClassFile(dis, allowJDK12ClassFiles);
            out.println("    +++ parsed class");

            final ByteArrayOutputStream b = new ByteArrayOutputStream();
            if (verbose) {
                classFile.print(new PrintStream(b), 0);
                out.println(b.toString());
            }
            out.println("Statistics:");
            classFile.summarize(new PrintStream(b), 4);
            out.println(b.toString());
        } catch (ClassFormatError ex) {
            out.println("    !!! ERROR: format error when parsing class: "
                        + name);
            out.println("        error: " + err);
View Full Code Here

        DataInputStream dis = null;
        try {
            // create class file
            dis = new DataInputStream(openFileInputStream(fileName));
            final boolean allowJDK12ClassFiles = true;
            classFiles[i] = new ClassFile(dis, allowJDK12ClassFiles);

            // get real class name
            classNames[i] = classFiles[i].className().asString();
            userClassNames[i] = classNames[i].replace('/', '.');
            out.println("    +++ parsed classfile");
View Full Code Here

        // check arguments
        affirm(inClassFile, "Illegal argument: inClassFile == null.");
        affirm(outClassFile, "Illegal argument: outClassFile == null.");

        // parse class
        final ClassFile cf;
        final Controller cc;
        try {
            // create class file
            final DataInputStream dis = new DataInputStream(inClassFile);
            final boolean allowJDK12ClassFiles = true;
            cf = new ClassFile(dis, allowJDK12ClassFiles);
            //@lars: do not close the input stream
            //dis.close();

            // create class control
            cc = new Controller(cf, env);

            // get real class name
            final String className = cf.classNameString();
        } catch (ClassFormatError ex) {
            throw new EnhancerUserException(
                getI18N("enhancer.class_format_error"),
                ex);
        }

        // enhance class
        cc.enhanceClass();
        if (env.errorCount() > 0) {
            // retrieve error messages
            env.getErrorWriter().flush();

            throw new EnhancerUserException(env.getLastErrorMessage());
        }
        affirm(env.errorCount() == 0);

        // write class
        boolean changed = cc.updated();
        try {
            if (changed) {
                env.message("writing enhanced class " + cf.userClassName()
                            + " to output stream");
            } else {
                env.message("no changes to class " + cf.userClassName());
            }
            outClassFile.setClassName(cf.userClassName());
            final DataOutputStream dos
                = new DataOutputStream(outClassFile.getStream());
            cf.write(dos);
            dos.flush();
        } catch (IOException ex) {
            throw new EnhancerUserException(
                getI18N("enhancer.io_error_while_writing_stream"),
                ex);
View Full Code Here

        DataInputStream dis = null;
        try {
            // create class file
            dis = new DataInputStream(openFileInputStream(fileName));
            final boolean allowJDK12ClassFiles = true;
            classFiles[i] = new ClassFile(dis, allowJDK12ClassFiles);

            // get real class name
            classNames[i] = classFiles[i].className().asString();
            userClassNames[i] = classNames[i].replace('/', '.');
            out.println("    +++ parsed classfile");
View Full Code Here

                dis = new DataInputStream(openClassInputStream(className));
            } else {
                dis = new DataInputStream(openFileInputStream(classFileName));
            }
            final boolean allowJDK12ClassFiles = true;
            classFile = new ClassFile(dis, allowJDK12ClassFiles);

            // check user class name from ClassFile
            final String userClassName
                = classFile.className().asString().replace('/', '.');
            //^olsen: better throw user exception or error
View Full Code Here

                dis = new DataInputStream(openClassInputStream(className));
            } else {
                dis = new DataInputStream(openFileInputStream(classFileName));
            }
            final boolean allowJDK12ClassFiles = true;
            final ClassFile classFile
                = new ClassFile(dis, allowJDK12ClassFiles);
            out.println("    +++ parsed class");

            final ByteArrayOutputStream b = new ByteArrayOutputStream();
            if (verbose) {
                classFile.print(new PrintStream(b), 0);
                out.println(b.toString());
            }
            out.println("Statistics:");
            classFile.summarize(new PrintStream(b), 4);
            out.println(b.toString());
        } catch (ClassFormatError ex) {
            out.println("    !!! ERROR: format error when parsing class: "
                        + name);
            out.println("        error: " + err);
View Full Code Here

        // check arguments
        affirm(inClassFile, "Illegal argument: inClassFile == null.");
        affirm(outClassFile, "Illegal argument: outClassFile == null.");

        // parse class
        final ClassFile cf;
        final Controller cc;
        try {
            // create class file
            final DataInputStream dis = new DataInputStream(inClassFile);
            final boolean allowJDK12ClassFiles = true;
            cf = new ClassFile(dis, allowJDK12ClassFiles);
            //@lars: do not close the input stream
            //dis.close();

            // create class control
            cc = new Controller(cf, env);

            // get real class name
            final String className = cf.classNameString();
        } catch (ClassFormatError ex) {
            throw new EnhancerUserException(
                getI18N("enhancer.class_format_error"),
                ex);
        }

        // enhance class
        cc.enhanceClass();
        if (env.errorCount() > 0) {
            // retrieve error messages
            env.getErrorWriter().flush();

            throw new EnhancerUserException(env.getLastErrorMessage());
        }
        affirm(env.errorCount() == 0);

        // write class
        boolean changed = cc.updated();
        try {
            if (changed) {
                env.message("writing enhanced class " + cf.userClassName()
                            + " to output stream");
            } else {
                env.message("no changes to class " + cf.userClassName());
            }
            outClassFile.setClassName(cf.userClassName());
            final DataOutputStream dos
                = new DataOutputStream(outClassFile.getStream());
            cf.write(dos);
            dos.flush();
        } catch (IOException ex) {
            throw new EnhancerUserException(
                getI18N("enhancer.io_error_while_writing_stream"),
                ex);
View Full Code Here

TOP

Related Classes of org.apache.jdo.impl.enhancer.classfile.ClassFile

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.