Examples of ClassContext


Examples of edu.umd.cs.findbugs.ba.ClassContext

    }

    @Override
    public <E> E getMethodAnalysis(Class<E> analysisClass, @Nonnull MethodDescriptor methodDescriptor) throws CheckedAnalysisException {
        requireNonNull(methodDescriptor, "methodDescriptor is null");
        ClassContext classContext = getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor());
        Object object = classContext.getMethodAnalysis(analysisClass, methodDescriptor);

        if (object == null) {
            try {
                object = analyzeMethod(classContext, analysisClass, methodDescriptor);
                if (object == null) {
                    object = NULL_ANALYSIS_RESULT;
                }
            } catch (RuntimeException e) {
                object = new AbnormalAnalysisResult(e);
            } catch (CheckedAnalysisException e) {
                object = new AbnormalAnalysisResult(e);
            }

            classContext.putMethodAnalysis(analysisClass, methodDescriptor, object);

        }
        if (Debug.VERIFY_INTEGRITY && object == null) {
            throw new IllegalStateException("AnalysisFactory failed to produce a result object");
        }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.ClassContext

    }

    @Override
    public <E> void eagerlyPutMethodAnalysis(Class<E> analysisClass, @Nonnull MethodDescriptor methodDescriptor, E analysisObject) {
        try {
            ClassContext classContext = getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor());
            assert analysisClass.isInstance(analysisObject);
            classContext.putMethodAnalysis(analysisClass, methodDescriptor, analysisObject);
        } catch (CheckedAnalysisException e) {
            IllegalStateException ise = new IllegalStateException("Unexpected exception adding method analysis to cache");
            ise.initCause(e);
            throw ise;
        }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.ClassContext

    @Override
    public void purgeMethodAnalyses(@Nonnull MethodDescriptor methodDescriptor) {
        try {

            ClassContext classContext = getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor());
            classContext.purgeMethodAnalyses(methodDescriptor);
        } catch (CheckedAnalysisException e) {
            IllegalStateException ise = new IllegalStateException("Unexpected exception purging method analyses from cache");
            ise.initCause(e);
            throw ise;
        }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.ClassContext

                try {
                    IAnalysisCache analysisCache = Global.getAnalysisCache();

                    ClassDescriptor c = DescriptorFactory.createClassDescriptor(obj);

                    ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, c);
                    didInCallOrder = true;
                    for (Method m : classContext.getMethodsInCallOrder()) {
                        doVisitMethod(m);
                    }

                } catch (CheckedAnalysisException e) {
                    AnalysisContext.logError("Error trying to visit methods in order", e);
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.ClassContext

        // Just get the ClassContext from the analysis cache
        // and apply the detector to it.

        IAnalysisCache analysisCache = Global.getAnalysisCache();
        ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, classDescriptor);
        Profiler profiler = analysisCache.getProfiler();
        profiler.start(detector.getClass());
        try {
            detector.visitClassContext(classContext);
        } finally {
View Full Code Here

Examples of net.sourceforge.javautil.classloader.impl.ClassContext

 
  /**
   * @return The class context for this unit, including any specified transformers
   */
  protected ClassContext createClassContext () {
    return new ClassContext(new StandardClassLoaderHeiarchy(), this.createClassSource())
      .setTransformer(new PersistenceClassTransformer(this.transformers.toArray(new ClassTransformer[this.transformers.size()])));
  }
View Full Code Here

Examples of net.sourceforge.javautil.classloader.impl.ClassContext

 
  /**
   * @return A special internal classloader for loading the MXJ classes
   */
  protected static ClassLoader createMysqlMXJClassLoader (IVirtualFile mxjJar, IVirtualFile mxjDbFileJar) {
    return new ClassContext(new StandardClassLoaderHeiarchy(),
      new ZipClassSource(mxjJar.getURL()),
      new ZipClassSource(mxjDbFileJar.getURL())
    );
  }
View Full Code Here

Examples of net.sourceforge.javautil.classloader.impl.ClassContext

  public void main (EntryPointConfiguration config) throws Throwable {
    URL boot = EntryPoint.class.getClassLoader()
      .getResource("META-INF/net/sf/javautil/boot.jar");
   
    ClassContext context = null;
    CompositeClassSource mainSource = new CompositeClassSource();
    ClassSource additional = this.getAdditionalClassSources();
    if (additional != null) mainSource.add(additional);
   
    if (boot != null) {
      mainSource.add( VirtualDirectoryClassSource.createInMemoryJar("boot", "main", boot.openStream()) );
      context = new ClassContext(new StandardClassLoaderHeiarchy(Thread.currentThread().getContextClassLoader()), mainSource);
    } else {
     
      String main = this.getSetting(MAIN_JAR_PROPERTY);
      if (main == null)
        printHelp("No internal uber jar and no main jar specified -D" + MAIN_JAR_PROPERTY + "=''");
     
      File mainFile = new File(main);
      if (!mainFile.exists())
        printHelp("Specified main jar does not exist: " + mainFile);
     
      mainSource.add( new ZipClassSource(mainFile) );
      context = new ClassContext(new StandardClassLoaderHeiarchy(Thread.currentThread().getContextClassLoader()), mainSource);
    }
   
    Thread.currentThread().setContextClassLoader(context);
    this.setupDefaultURLStreamHandlerFactory(context);
   
    String mainClassName = null;
   
    if (mainClassName == null) {
      Manifest manifest = mainSource.getManifest();
      if (manifest == null)
        printHelp("No main jar manifest found in " + mainSource);
     
      mainClassName = manifest.getMainAttributes().getValue("Main-Class");
    }
    Thread.currentThread().setContextClassLoader(context);
   
    if (config.getMainClass() != null)
      this.boot(ClassCache.getFor(context.loadClass(mainClassName)), this);
  }
View Full Code Here

Examples of net.sourceforge.javautil.classloader.impl.ClassContext

  /**
   * Will detect pom.xml specified by {@link #getPackageDescriptor()}, and load {@link EntryPoint#getAdditionalClassSources()}.
   * It will also load all maven project directories specified by {@link #getProjectDirectory()}.
   */
  public void main(EntryPointConfiguration config) throws Throwable {
    ClassContext context = null;
    ClassSource cs = config.getPoint().getAdditionalClassSources();

    // Load project directories
    String mp = this.getProjectDirectory();
    if (mp == null) mp = "../";

    this.resolver = MavenRepositoryUtil.createStandardResolver();
   
    String[] mps = mp.split(";");
   
    for (String mpd : mps) {
      ((ClassPackageResolverImpl)this.resolver).addLocalRepository(new MavenRepositoryLocalProject( new SystemDirectory(mpd) ));
    }
   
    ((ClassPackageResolverImpl)this.resolver).addLocalRepository(new MavenRepositoryClassLoader());
   
    context = cs != null ?
      new ClassContext(new StandardClassLoaderHeiarchy(), cs) :
      new ClassContext(new StandardClassLoaderHeiarchy());
   
    Thread.currentThread().setContextClassLoader(context);
   
    // Check for a specified or default pom.xml file
    IVirtualFile pomFile = this.locatePOMDescriptor();
   
    if (pomFile != null && pomFile.isExists()) {
     
      ProjectObjectModel pom = ProjectObjectModel.parse(resolver, pomFile);
     
      ProjectObjectModel resolved = (ProjectObjectModel) resolver.getDescriptor(pom);
      if (resolved != null) {
        pom = resolved;
      } else {
        log.info("Unresolvable pom.xml used for bootstrapping: " + pom);
      }
     
      MavenRepositoryUtil.addProjectMainTarget(context.getNonPackageSources(), pom, pomFile.getOwner());
     
      context.setPool(pool = MavenRepositoryUtil.createFrom(resolver, pom, pom.getDependencies()));
     
      Thread.currentThread().setContextClassLoader(context);
     
    } else {

      log.warn("Could not find: " + pomFile.getPath().toString("/"));

    }
   
    new ClassPackageContext(resolver, context.getPool()).setGlobal();
   
    config.getPoint().setupDefaultURLStreamHandlerFactory(context);
   
    if (log.isDebug()) {
      log.debug("Non Package Sources");
      for (ClassSource src : context.getNonPackageSources().getAllNonCompositeSources()) {
        log.debug(" --> " + src);
      }
     
      log.debug("Package Sources");
      for (IClassPackage pkg : context.getPool().getPackages(true)) {
        log.debug(" --> " + pkg.getDescriptor());
      }
     
      this.log.debug("BOOTING MAVEN: " + config.getMainClass() + ": " + System.currentTimeMillis());
    }
   
    config.registerExecuted(this);
   
    // Load the main class and invoke it
    this.settings.refresh();
    if (config.getMainClass() != null)
      config.getPoint().boot(ClassCache.getFor(context.loadClass(config.getMainClass())), this);
  }
View Full Code Here

Examples of net.sourceforge.javautil.classloader.impl.ClassContext

  /**
   * This will create a linked context and set the internal class loader to use it instead. By default
   * this will also make sure that the current class loader is the parent of the created linked context.
   */
  protected void createLinkedContext (ClassLoader parent) {
    this.linkedContext = new ClassContext(new VirtualDeploymentLinkedClassLoaderHeiarchy(this, parent, this.classLoader));
    this.classLoader = this.linkedContext;
  }
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.