Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ClassParser


                if (!entry.getName().endsWith(".class")) {
                    continue;
                }

                ClassParser parser = new ClassParser(zipFile.getInputStream(entry), entry.getName());
                JavaClass javaClass = parser.parse();

                Repository.addClass(javaClass);
                classList.add(javaClass);
            }
        }
View Full Code Here


     */
    public static void main( String[] argv ) throws Exception {
        JavaClass java_class;
        String name = argv[0];
        if ((java_class = Repository.lookupClass(name)) == null) {
            java_class = new ClassParser(name).parse(); // May throw IOException
        }
        BCELifier bcelifier = new BCELifier(java_class, System.out);
        bcelifier.start();
    }
View Full Code Here

        int index = class_name.indexOf("$$BCEL$$");
        String real_name = class_name.substring(index + 8);
        JavaClass clazz = null;
        try {
            byte[] bytes = Utility.decode(real_name, true);
            ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes), "foo");
            clazz = parser.parse();
        } catch (Throwable e) {
            e.printStackTrace();
            return null;
        }
        // Adapt the class name to the passed value
View Full Code Here


    private JavaClass loadClass( InputStream is, String className ) throws ClassNotFoundException {
        try {
            if (is != null) {
                ClassParser parser = new ClassParser(is, className);
                JavaClass clazz = parser.parse();
                storeClass(clazz);
                return clazz;
            }
        } catch (IOException e) {
            throw new ClassNotFoundException("Exception while looking for class " + className
View Full Code Here

        try {
            InputStream is = loader.getResourceAsStream(classFile + ".class");
            if (is == null) {
                throw new ClassNotFoundException(className + " not found.");
            }
            ClassParser parser = new ClassParser(is, className);
            RC = parser.parse();
            storeClass(RC);
            return RC;
        } catch (IOException e) {
            throw new ClassNotFoundException(e.toString());
        }
View Full Code Here


    public static void main( String argv[] ) {
        String[] file_name = new String[argv.length];
        int files = 0;
        ClassParser parser = null;
        JavaClass java_class = null;
        String zip_file = null;
        char sep = System.getProperty("file.separator").toCharArray()[0];
        String dir = "." + sep; // Where to store HTML files
        try {
            /* Parse command line arguments.
             */
            for (int i = 0; i < argv.length; i++) {
                if (argv[i].charAt(0) == '-') { // command line switch
                    if (argv[i].equals("-d")) { // Specify target directory, default `.�
                        dir = argv[++i];
                        if (!dir.endsWith("" + sep)) {
                            dir = dir + sep;
                        }
                        new File(dir).mkdirs(); // Create target directory if necessary
                    } else if (argv[i].equals("-zip")) {
                        zip_file = argv[++i];
                    } else {
                        System.out.println("Unknown option " + argv[i]);
                    }
                } else {
                    file_name[files++] = argv[i];
                }
            }
            if (files == 0) {
                System.err.println("Class2HTML: No input files specified.");
            } else { // Loop through files ...
                for (int i = 0; i < files; i++) {
                    System.out.print("Processing " + file_name[i] + "...");
                    if (zip_file == null) {
                        parser = new ClassParser(file_name[i]); // Create parser object from file
                    } else {
                        parser = new ClassParser(zip_file, file_name[i]); // Create parser object from zip file
                    }
                    java_class = parser.parse();
                    new Class2HTML(java_class, dir);
                    System.out.println("Done.");
                }
            }
        } catch (Exception e) {
View Full Code Here

            if (in == null) {
                classesThatCantBeFound.add(className);
                throw new ClassNotFoundException("Error while looking for class " + className + ": class not found");
            }

            ClassParser classParser = new ClassParser(in, resourceName);
            JavaClass javaClass = classParser.parse();
            parsedClass = true;

            return javaClass;
        } catch (IOException e) {
            classesThatCantBeFound.add(className);
View Full Code Here

            System.exit(1);
        }

        String methodName = SystemProperties.getProperty("cfgbuilder.method");

        JavaClass jclass = new ClassParser(argv[0]).parse();
        ClassGen classGen = new ClassGen(jclass);

        Method[] methodList = jclass.getMethods();
        for (Method method : methodList) {
            if (method.isAbstract() || method.isNative()) {
View Full Code Here

                                break checkMatch;
                            }
                        }
                        continue;
                    }
                    printClass(new ClassParser(z.getInputStream(ze), name));

                }
            }
        } else {
            for (int i = 0; i < files; i++) {
                if (file_name[i].endsWith(".class")) {
                    printClass(new ClassParser(file_name[i]));
                }
            }
        }
    }
View Full Code Here

      String clName = args[i];
      if(clName.endsWith(".class")) {
  clName = clName.substring(0,clName.length()-6);
      }
      clName = clName.replace('.','/');
      clazz = new ClassParser(classPath.getInputStream(clName),clName).parse();
      // here we create the root set of classes to process
      addDependents(clazz);
      System.out.println("Packaging for class: " + clName );
    }
    if( dependents.isEmpty() ){
       usage();
       return ;
    }
    System.out.println("Creating jar file: " + defaultJar );
    // starting processing: Grab from the dependents list an add back to it
    // and the allClasses list. see addDependents
    while(!dependents.isEmpty() ){
      String name = (String)dependents.firstKey();
      String from = (String) dependents.remove(name);
      if(allClasses.get(name) == null){
  try{
    InputStream is = classPath.getInputStream(name);
    clazz = new ClassParser(is, name).parse();
    addDependents(clazz);
  }catch( IOException e){
    //System.err.println("Error, class not found " + name );
    notFound.put(name,from);
  }
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.