Package org.apache.bcel.util

Examples of org.apache.bcel.util.Repository


        JavaClass previous = nameToClassMap.put(javaClass.getClassName(), javaClass);
        if (DEBUG && previous != null) {
            System.out.println("\t==> A previous class was evicted!");
            dumpStack();
        }
        Repository tmp = org.apache.bcel.Repository.getRepository();
        if (tmp != null && tmp != this) {
            throw new IllegalStateException("Wrong/multiple BCEL repository");
        }
        if (tmp == null) {
            org.apache.bcel.Repository.setRepository(this);
View Full Code Here


        }
      }

      long t0 = System.nanoTime();
      final URL[] urls = classLoader.getURLs();
      final Repository repo = new ClassLoaderRepository(classLoader);
      ExecutorService service = Executors.newFixedThreadPool(10);
      try {
        List<Future<String>> tasks = new ArrayList<Future<String>>();
        for (final URL url : urls) {
          Callable<String> task = new Callable<String>() {
            // @Override
            public String call() throws Exception {
              String urlFile = url.getFile();
              Set<String> allClassNames = ClassUtils
                  .findAllClassNames(new File(urlFile));
              Set<String> skipNamesToProcess = new HashSet<String>();
              for (String className : allClassNames) {
                if (!mustProcessClass(className, filters)) {
                  skipNamesToProcess.add(className);
                }
              }
              allClassNames.removeAll(skipNamesToProcess);
              sLog.info("Processing " + allClassNames.size()
                  + " classes in " + urlFile);
              for (String className : allClassNames) {
                final Map<MethodInfo, Code> codeMap = new HashMap<MethodInfo, Code>();
                final JavaClass javaClass = repo
                    .loadClass(className);
                for (Method method : javaClass.getMethods()) {
                  codeMap.put(JavaClassProcessor.toMethod(
                      className, method), method
                      .getCode());
View Full Code Here

    return new BeanClassEnumerator(ignorePackages)
        .getAllCustomClassBytes(klass);
  }

  private byte[] getClassBytes(Class<?> klass) throws ClassNotFoundException {
    Repository rep = new ClassLoaderRepository(klass.getClassLoader());
    return rep.loadClass(klass.getName()).getBytes();
  }
View Full Code Here

            + ".execute. classpathElements - " + classpathElements);
        final URLClassLoader urlClassLoader = ClassUtils
            .newURLClassLoader(classpathElements, null);
        final ClassHierarchyProcessor finder = new ClassHierarchyProcessor(
            urlClassLoader);
        @SuppressWarnings("unused")
        final Repository repository = new ClassLoaderRepository(
            urlClassLoader);
        final ClassRenderingStrategy strategy = DefaultClassRenderingStrategy.SHOW_ALL_DECLARED_METHODS;
        CallGraphGeneratorUtils
            .draw(
                new GraphTranscoder<ClassMetaData, String[]>()
                    .transcode(
                        finder.computeGraph(className),
                        new NodeConversionStrategy<ClassMetaData, String[]>() {
                          public String[] convert(
                              ClassMetaData input) {
                            try {
                              Graph<String[]> temp = new Graph<String[]>();
                              strategy
                                  .convert(
                                      temp,
                                      urlClassLoader,
                                      input
                                          .getClassName());
                              return temp
                                  .getUserData();
                            } catch (RuntimeException exc) {
                              throw new TranscodingException(
                                  exc);
                            }
                          }
                        }), new File(output));
      } else if (digest != null) {
        File digestFile = new File(digest);
        if (!digestFile.isAbsolute()) {
          digestFile = new File(getProject().getBaseDir(), digest);
        }
        if (!digestFile.exists()) {
          throw new IllegalArgumentException(
              "Cannot continue, since digest file not found - "
                  + digestFile.getAbsolutePath());
        }
        @SuppressWarnings("unchecked")
        Map<String, ClassMetaData> map = (Map<String, ClassMetaData>) FileUtils
            .loadSerializableObjectFromFile(digestFile);
        System.out.println(getClass().getName()
            + ".execute. classpathElements - " + classpathElements);
        final URLClassLoader urlClassLoader = ClassUtils
            .newURLClassLoader(classpathElements, null);
        final ClassHierarchyProcessor finder = new ClassHierarchyProcessor(
            urlClassLoader, map);
        @SuppressWarnings("unused")
        final Repository repository = new ClassLoaderRepository(
            urlClassLoader);
        final ClassRenderingStrategy strategy = DefaultClassRenderingStrategy.SHOW_ALL_DECLARED_METHODS;
        CallGraphGeneratorUtils
            .draw(
View Full Code Here

  public static void renderGraphToFile(final URLClassLoader classLoader,
      final ClassRenderingStrategy strategy,
      final Graph<ClassMetaData> classMetaDataGraph,
      final String imageFileName) throws IOException,
      InterruptedException {
    @SuppressWarnings("unused")
    final Repository repository = new ClassLoaderRepository(classLoader);
    CallGraphGeneratorUtils.draw(
        new GraphTranscoder<ClassMetaData, String[]>().transcode(
            classMetaDataGraph,
            new NodeConversionStrategy<ClassMetaData, String[]>() {
View Full Code Here

TOP

Related Classes of org.apache.bcel.util.Repository

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.