Examples of ClassFile


Examples of alt.jiapi.file.ClassFile

     *            be found
     * @exception IOException, if the loading of class failed.
     * @see #loadClass(String, URL)
     */
    public JiapiClass loadClass(InputStream is) throws ClassNotFoundException, IOException {
        ClassFile clazz = ClassFile.parse(is);

        JiapiClass jiapiClass = new JiapiClass(clazz);
        jiapiClass.setLoader(this);
           
        return jiapiClass;
View Full Code Here

Examples of com.claritysys.jvm.classfile.ClassFile

        return c.writeToArray();
    }

    static byte[] csgBytecodeHelloWorld() {
        ClassFile cf = new ClassFile("HelloWorld",
                "java/lang/Object",
                "HelloWorld.java");
        ConstantPool cp = cf.getConstantPool();

        CfMethod method = cf.addMethod(JVM.ACC_PUBLIC, "<init>", "()V");
        CodeBuilder code = new CodeBuilder(method);
        code.add(JVM.ALOAD_0);
        code.add(JVM.INVOKESPECIAL, cp.addMethodRef(false,
                "java/lang/Object",
                "<init>",
                "()V"));
        code.add(JVM.RETURN);
        code.flush();

        method = cf.addMethod(JVM.ACC_PUBLIC + JVM.ACC_STATIC,
                "main",
                "([Ljava/lang/String;)V");
        code = new CodeBuilder(method);
        code.add(JVM.GETSTATIC, cp.addFieldRef("java/lang/System",
                "out",
                "Ljava/io/PrintStream;"));
        code.add(JVM.LDC, "Hello world!");
        code.add(JVM.INVOKEVIRTUAL, cp.addMethodRef(false,
                "java/io/PrintStream",
                "println",
                "(Ljava/lang/String;)V"));
        code.add(JVM.RETURN);
        code.flush();

        return cf.writeToArray();
    }
View Full Code Here

Examples of com.sun.enterprise.deployment.annotation.introspection.ClassFile

    /**
     * The component has been injected with any dependency and
     * will be placed into commission by the subsystem.
     */
    public void postConstruct() {
        classFile = new ClassFile(new ConstantPoolInfo(defaultScanner));
    }
View Full Code Here

Examples of com.sun.enterprise.tools.verifier.apiscan.classfile.ClassFile

        final String classExt = ".class";
        for (Enumeration<JarEntry> entries = moduleJar.entries(); entries.hasMoreElements();) {
            JarEntry je = entries.nextElement();
            if (je.getName().endsWith(classExt)) {
                String className = Util.convertToExternalClassName(je.getName().substring(0, je.getName().length() - classExt.length()));
                ClassFile cf = null;
                try {
                    cf = cfl.load(className);
                    for (String c : cf.getAllReferencedClassNames()) {
                        requiredPkgs.add(Util.getPackageName(c));
                    }
                } catch (IOException e) {
                    logger.logp(Level.FINE, "PackageAnalyser", "computeRequiredPackages", "Skipping analysis of {0} as the following exception was thrown:\n {1}", new Object[]{className, e});
                }
View Full Code Here

Examples of com.sun.jdo.api.persistence.enhancer.classfile.ClassFile

        affirm(inByteCode, "Illegal argument: inByteCode == null.");//NOI18N
        affirm(outByteCode, "Illegal argument: outByteCode == null.");//NOI18N

        // parse class
        final ClassFileSource cfs;
        final ClassFile cf;
        final ClassControl cc;
        try {
            // create class file source
            cfs = new ClassFileSource(null, inByteCode);

            // create class file
            final DataInputStream dis = cfs.classFileContents();
            cf = new ClassFile(dis);
//@lars: do not close the input stream
//            dis.close();

            // create class control
            cc = new ClassControl(cfs, cf, env);
            env.addClass(cc);

            // get real class name
            final String className = cc.className();
            cfs.setExpectedClassName(className);
        } catch (IOException ex) {
            //@olsen: support for I18N
            throw new UserException(
                getI18N("enhancer.io_error_while_reading_stream"),//NOI18N
                ex);
        } catch (ClassFormatError ex) {
            //@olsen: support for I18N
            throw new UserException(
                getI18N("enhancer.class_format_error"),//NOI18N
                ex);
        }

        // enhance class
        econtrol.modifyClasses();
        if (env.errorCount() > 0) {
            // retrieve error messages
            env.getErrorWriter ().flush ();
            /*
            final String str = errString.getBuffer().toString();

            // reset env's error writer
            errString = new StringWriter();
            err = new PrintWriter(errString, true);
            env.setErrorWriter(err);
            */

            //@olsen: support for I18N
            throw new UserException(env.getLastErrorMessage ());
        }

        // write class
        boolean changed = (cc.updated() && cc.filterRequired());
        try {
            if (changed)
            {
                env.message("writing enhanced class " + cc.userClassName()//NOI18N
                            + " to output stream");//NOI18N
            }
            else
            {
                env.message("no changes on class " + cc.userClassName());
            }
            outByteCode.setClassName (cc.userClassName ());
            final DataOutputStream dos = new DataOutputStream(outByteCode.getStream ());
            cf.write(dos);
            dos.flush();
        } catch (IOException ex) {
            //@olsen: support for I18N
            throw new UserException(
                getI18N("enhancer.io_error_while_writing_stream"),//NOI18N
View Full Code Here

Examples of com.sun.tools.classfile.ClassFile

    void verifyBytecode(VarargsMethod selected) {
        bytecodeCheckCount++;
        File compiledTest = new File("Test.class");
        try {
            ClassFile cf = ClassFile.read(compiledTest);
            Method testMethod = null;
            for (Method m : cf.methods) {
                if (m.getName(cf.constant_pool).equals("test")) {
                    testMethod = m;
                    break;
View Full Code Here

Examples of de.berndsteindorff.junittca.model.ClassFile

    try {
      ProjectFileHandler pfh = new ProjectFileHandler();
      pfh.loadFile(new File("test666.yap"));
      pfh.newProject("Bla Projekt 1");
      pfh.getProject().addTestClass(
          new ClassFile(Const.NAME_DUMMYTEST, Const.CLASSPATH));
      pfh.runTests();
      pfh.runTests();
      pfh.closeDatabase();

    } catch (Exception e) {
View Full Code Here

Examples of gov.nasa.jpf.classfile.ClassFile

      JarEntry entry = jar.getJarEntry(fileName);
      if (entry != null) {
        try {
          logger.fine("Loaded " + className + " from jar file " + jar.getName());
          byte[] classBytes = Util.getClassBytes(jar.getInputStream(entry));
          ClassFile cf = new ClassFile(className, classBytes);
          return new UnregisteredClassInfo(cf);
        } catch (IOException e) {
          logger.warning(e.getMessage());
          return null;
        } catch (ClassFileException e) {
View Full Code Here

Examples of jasmin.ClassFile

                new Attribute[] { new Comment(), new CodeComment() },
                ClassReader.EXPAND_FRAMES);
        pw.close();
        String jasmin = sw.toString();

        ClassFile cf = new ClassFile();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        cf.readJasmin(new StringReader(jasmin), "test", false);
        if (cf.errorCount() != 0) {
            throw new jasError();
        }
        cf.write(bos);
        bos.close();

        assertEquals(cr,
                new ClassReader(bos.toByteArray()),
                new ClassFilter() {
View Full Code Here

Examples of javassist.bytecode.ClassFile

    }

    private void addAnnotation(Annotation annotation)
    {
       
        final ClassFile classFile = getClassFile();
       
        AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
       
        if (attribute == null)
        {
            attribute = new AnnotationsAttribute(getConstPool(), AnnotationsAttribute.visibleTag);
        }
       
        final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);
       
       
        attribute.addAnnotation(copy);
       
        classFile.addAttribute(attribute);
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.