Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ClassParser


                String className = c.getName();
                String classFile = className.replace('.', '/');
                InputStream is =
                        c.getClassLoader().getResourceAsStream(classFile + ".class");

                ClassParser parser = new ClassParser(is, className);
                bclass = parser.parse();

                clazzCache.put(c, bclass);
            } catch (IOException e) {
                // what now?
            }
View Full Code Here


     * @throws IOException
     */
    public static JavaClass getBcelClass( String filename )
        throws IOException
    {
        ClassParser parser = new ClassParser( filename );
        return parser.parse();
    }
View Full Code Here

            InputStream classAsStream = m_loader.getResourceAsStream(classFileName);

            if (classAsStream == null) {
                return false;
            }
            ClassParser classParser = new ClassParser(classAsStream, className);
            m_javaClass = classParser.parse();

            m_constantPoolGen = new ConstantPoolGen(m_javaClass.getConstantPool());
            m_classGen = new ClassGen(m_javaClass);
        }
        catch (Exception e) {
View Full Code Here

     */
    public void initialize(final String className, final ClassLoader loader) {
        String classFileName = className.replace('.', '/') + ".class";
        try {
            InputStream classStream = loader.getResourceAsStream(classFileName);
            ClassParser classParser = new ClassParser(classStream, classFileName);
            m_javaClass = classParser.parse();
        }
        catch (IOException e) {
            throw new WrappedRuntimeException(e);
        }
    }
View Full Code Here

            // then turn on BCELifier to learn more about BCEL
            //org.apache.bcel.util.BCELifier bc = new org.apache.bcel.util.BCELifier(repository.loadClass("java.lang.ClassLoader"), System.out);
            //bc.start();

            final ClassGen cg = new ClassGen(
                    (new ClassParser(new ByteArrayInputStream(b), "<generated>")).parse());
            final String className = cg.getClassName();
            final Method[] methods = cg.getMethods();
            final ConstantPoolGen cpg = cg.getConstantPool();
            final InstructionFactory factory = new InstructionFactory(cg);
View Full Code Here

            // If cache doesn't contain such a class load it from a class path.
            if (result == null) {
                // Get a file and parse its contents.
                ClassPath.ClassFile cf = classpath.getClassFile(name);
                InputStream is = cf.getInputStream();
                ClassParser parser = new ClassParser(is, cf.getPath());
                result = parser.parse();
                // Put the parsed class file into the cache.
                cache.put(name, result);

                if (verbose) {
                    StringBuffer s = new StringBuffer();
View Full Code Here

    void analyze(Document doc, InputStream in, Writer xrefOut) throws IOException {
        List<String> defs = new ArrayList<>();
        List<String> refs = new ArrayList<>();
        List<String> full = new ArrayList<>();

        ClassParser classparser = new ClassParser(in, doc.get("path"));
        StringWriter out = new StringWriter();
        StringWriter fout = new StringWriter();
        getContent(out, fout, classparser.parse(), defs, refs, full);
        String fullt = fout.toString();
        String xref = out.toString();

        if (xrefOut != null) {
            xrefOut.append(xref);
View Full Code Here

                final ZipEntry entry = (ZipEntry) entries.nextElement();
                final String entryName = entry.getName();
                if (entryName.endsWith(".class")) {
                    final InputStream in = zipFile.getInputStream(entry);
                    final JavaClass javaClass =
                        new ClassParser(in, entryName).parse();
                    result.add(javaClass);
                }
            }
        }
        else {
            final JavaClass javaClass = new ClassParser(fileName).parse();
            result.add(javaClass);
        }
        return result;
    }
View Full Code Here

     */
    public static StringBuffer getConstants(byte[] bytes)
        throws IOException {
        final StringBuffer sb = new StringBuffer();
        final ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
        final ClassParser parser = new ClassParser(bis, "");
        final JavaClass javaClass = parser.parse();
        final Field[] fields = javaClass.getFields();
        for (int i = 0; i < fields.length; i++) {
            final Field field = fields[i];
            if (field != null) {
                final ConstantValue cv = field.getConstantValue();
View Full Code Here

     * be satisfied
     */
    public FullAnalyzer() {
        // force BCEL classes to load now
        try {
            new ClassParser("force");
        } catch (Exception e) {
            // all released versions of BCEL may throw an IOException
            // here, but BCEL's trunk does no longer declare to do so
            if (!(e instanceof IOException)) {
                throw new BuildException(e);
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.ClassParser

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.