Package edu.umd.cs.findbugs.classfile

Examples of edu.umd.cs.findbugs.classfile.ICodeBaseEntry


     */
    @Override
    public ClassNode analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
        ClassReader classReader = analysisCache.getClassAnalysis(ClassReader.class, descriptor);

        ICodeBaseEntry entry = analysisCache.getClassPath().lookupResource(descriptor.toResourceName());

        // One of the less-than-ideal features of ASM is that
        // invalid classfile format is indicated by a
        // random runtime exception rather than something
        // indicative of the real problem.
View Full Code Here


        // Compute the resource name
        String resourceName = descriptor.toResourceName();

        // Look up the codebase entry for the resource
        ICodeBaseEntry codeBaseEntry;
        try {
            codeBaseEntry = analysisCache.getClassPath().lookupResource(resourceName);
        } catch (ResourceNotFoundException e) {
            // Allow loading javax.annotation's from our own classpath - in case we analyze projects
            // using 3rd party nullness annotations (which do not have jsr305 classes on classpath)
            if(resourceName.startsWith("javax/annotation/")){
                codeBaseEntry = new VirtualCodeBaseEntry(descriptor);
            } else {
                throw new MissingClassException(descriptor, e);
            }
        }

        byte[] data;
        if (codeBaseEntry instanceof ZipInputStreamCodeBaseEntry) {
            data = ((ZipInputStreamCodeBaseEntry) codeBaseEntry).getBytes();
        } else {
            try {
                // Create a ByteArrayOutputStream to capture the class data
                int length = codeBaseEntry.getNumBytes();
                InputStream in = codeBaseEntry.openResource();
                if (length >= 0) {
                    data = IO.readAll(in, length);
                } else {
                    data = IO.readAll(in);
                }
View Full Code Here

            // codebase is closed

            // Copy nested zipfile to the temporary file
            // FIXME: potentially long blocking operation - should be
            // interruptible
            ICodeBaseEntry resource = parentCodeBase.lookupResource(resourceName);
            if (resource == null) {
                throw new ResourceNotFoundException(resourceName);
            }
            inputStream = resource.openResource();
            outputStream = new BufferedOutputStream(new FileOutputStream(tempFile));
            IO.copy(inputStream, outputStream);
            outputStream.flush();

            // Create the delegate to read from the temporary file
View Full Code Here

     * @see
     * edu.umd.cs.findbugs.classfile.ICodeBase#lookupResource(java.lang.String)
     */
    @Override
    public ICodeBaseEntry lookupResource(String resourceName) {
        ICodeBaseEntry delegateCodeBaseEntry = delegateCodeBase.lookupResource(resourceName);
        if (delegateCodeBaseEntry == null) {
            return null;
        }
        return new DelegatingCodeBaseEntry(this, delegateCodeBaseEntry);
    }
View Full Code Here

    public Map<String, ICodeBaseEntry> getApplicationCodebaseEntries() {
        Map<String, ICodeBaseEntry> appEntries = new HashMap<String, ICodeBaseEntry>();
        Iterator<Entry<String, ICodeBaseEntry>> iterator = codeBaseEntryMap.entrySet().iterator();
        while(iterator.hasNext()) {
            Entry<String, ICodeBaseEntry> entry = iterator.next();
            ICodeBaseEntry codeBaseEntry = entry.getValue();
            if(codeBaseEntry.getCodeBase().isApplicationCodeBase()) {
                appEntries.put(entry.getKey(), codeBaseEntry);
            }
        }
        return appEntries;
    }
View Full Code Here

     * edu.umd.cs.findbugs.classfile.IClassPath#lookupResource(java.lang.String)
     */
    @Override
    public ICodeBaseEntry lookupResource(String resourceName) throws ResourceNotFoundException {
        // See if we have cached the codebase entry for this resource
        ICodeBaseEntry result = codeBaseEntryMap.get(resourceName);

        if (result == null) {
            // No previously resolved entry - look up the resources in the
            // codebases

View Full Code Here

     * @return codebase entry for the named resource, or null if the named
     *         resource cannot be found
     */
    private ICodeBaseEntry search(List<? extends ICodeBase> codeBaseList, String resourceName) {
        for (ICodeBase codeBase : codeBaseList) {
            ICodeBaseEntry resource = codeBase.lookupResource(resourceName);
            if (resource != null) {
                return resource;
            }
            // Ignore, continue trying other codebases
        }
View Full Code Here

     *
     * @see edu.umd.cs.findbugs.classfile.ICodeBaseIterator#next()
     */
    @Override
    public ICodeBaseEntry next() throws InterruptedException {
        ICodeBaseEntry delegateCodeBaseEntry = delegateCodeBaseIterator.next();
        return new DelegatingCodeBaseEntry(frontEndCodeBase, delegateCodeBaseEntry);
    }
View Full Code Here

            if (!discoveredCodeBase.getCodeBase().isApplicationCodeBase()) {
                continue;
            }

            codeBaseEntryLoop: for (ICodeBaseIterator i = discoveredCodeBase.iterator(); i.hasNext();) {
                ICodeBaseEntry entry = i.next();
                if (!DescriptorFactory.isClassResource(entry.getResourceName())) {
                    continue;
                }

                ClassDescriptor classDescriptor = entry.getClassDescriptor();
                if (classDescriptor == null) {
                    throw new IllegalStateException();
                }

                if (appClassSet.contains(classDescriptor)) {
                    // An earlier entry takes precedence over this class
                    continue codeBaseEntryLoop;
                }
                appClassSet.add(classDescriptor);
                appClassList.add(classDescriptor);

                classPath.mapResourceNameToCodeBaseEntry(entry.getResourceName(), entry);
            }
        }

        if (DEBUG) {
            System.out.println("Classpath:");
View Full Code Here

     * @param resourceName
     *            name of a resource
     * @return true if the resource exists in the codebase, false if not
     */
    private boolean probeCodeBaseForResource(DiscoveredCodeBase discoveredCodeBase, String resourceName) {
        ICodeBaseEntry resource = discoveredCodeBase.getCodeBase().lookupResource(resourceName);
        return resource != null;
    }
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.classfile.ICodeBaseEntry

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.