Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert-annoations-to-source issues type analysis failed; skipping (incomplete CLASSPATH?) #232

Open
the1derer opened this issue Jul 28, 2019 · 3 comments

Comments

@the1derer
Copy link
Member

the1derer commented Jul 28, 2019

ResourceBundle.zip
Commands run:

unzip ResourceBundle.zip
cd ResourceBundle
export CLASSPATH=checker-qual.jar:
extract-annotations ResourceBundle.class
insert-annotations-to-source  ResourceBundle.jaif ResourceBundle.java

Result:

WARNING: ResourceBundle.java: type analysis failed; skipping
(incomplete CLASSPATH?)
@the1derer
Copy link
Member Author

@mernst I am sure the problem is with insert-annotations-to-source. I am not able to figure out what the problem is or how to reduce the test-case.

@mernst
Copy link
Member

mernst commented Jul 28, 2019

The problem is the @SuppressWarnings("unchecked") annotation on line 1920.
If you comment it out, the warning is not issued.

I agree this is undesirable, but it is just a warning. Does it cause any problems? That is, is the output of insert-annotations-to-source different than it should be?

Here is the context:

    /**
     * Returns the service type of the given baseName that is visible
     * to the given class loader
     */
    private static Class<ResourceBundleProvider>
            getResourceBundleProviderType(String baseName, ClassLoader loader)
    {
        // Look up <packagename> + ".spi." + <name>"Provider"
        int i = baseName.lastIndexOf('.');
        if (i <= 0) {
            return null;
        }

        String name = baseName.substring(i+1, baseName.length()) + "Provider";
        String providerName = baseName.substring(0, i) + ".spi." + name;

        // Use the class loader of the getBundle caller so that the caller's
        // visibility of the provider type is checked.
        return AccessController.doPrivileged(
            new PrivilegedAction<>() {
                @Override
                public Class<ResourceBundleProvider> run() {
                    try {
                        Class<?> c = Class.forName(providerName, false, loader);
                        if (ResourceBundleProvider.class.isAssignableFrom(c)) {
                            @SuppressWarnings("unchecked")
                            Class<ResourceBundleProvider> s = (Class<ResourceBundleProvider>) c;
                            return s;
                        }
                    } catch (ClassNotFoundException e) {}
                    return null;
                }
            });
    }

@the1derer
Copy link
Member Author

the1derer commented Jul 29, 2019

Without commenting out, line 1920 i.e. @SuppressWarnings("unchecked") insert-annotations-to-source gives the stated warning and doesn't insert annotations at all. But with line 1920 commented out annotations are added successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants