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

False positive with ParameterPackage #1177

Closed
Stephan202 opened this issue Nov 13, 2018 · 0 comments · Fixed by #2076
Closed

False positive with ParameterPackage #1177

Stephan202 opened this issue Nov 13, 2018 · 0 comments · Fixed by #2076

Comments

@Stephan202
Copy link
Contributor

Consider this following code:

import java.util.concurrent.Callable;
import java.util.concurrent.RunnableScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;

class Executor extends ScheduledThreadPoolExecutor {
    Executor() {
        super(1);
    }

    @Override
    protected <V> RunnableScheduledFuture<V> decorateTask(
            Runnable runnable, RunnableScheduledFuture<V> task) {
        return task;
    }

    @Override
    protected <V> RunnableScheduledFuture<V> decorateTask(
            Callable<V> callable, RunnableScheduledFuture<V> task) {
        return task;
    }
}

Compile this code as follows:

javac \
  -XDcompilePolicy=simple \
  -processorpath error_prone_core-2.3.2-with-dependencies.jar \
  '-Xplugin:ErrorProne -XepDisableAllChecks -Xep:ParameterPackage:WARN' \
  Executor.java

The following false positive results:

Executor.java:11: warning: [ParameterPackage] Method parameter has wrong package
    protected <V> RunnableScheduledFuture<V> decorateTask(
                                             ^
    (see https://errorprone.info/bugpattern/ParameterPackage)
  Did you mean 'Runnable runnable, java.util.concurrent.RunnableScheduledFuture task) {'?
1 warning

Interestingly the code complains only about the Runnable overload; not the Callable overload.

copybara-service bot pushed a commit that referenced this issue Jan 8, 2021
which was never productionized, and is buggy.

Consistently using `@Override` seems to provide most of the value
of this check, in terms of preventing accidentally overriding
(or accidentally failing to override) a method.

Fixes #1177

PiperOrigin-RevId: 350704198
stevie400 pushed a commit to HubSpot/error-prone that referenced this issue Jan 15, 2021
which was never productionized, and is buggy.

Consistently using `@Override` seems to provide most of the value
of this check, in terms of preventing accidentally overriding
(or accidentally failing to override) a method.

Fixes google#1177

PiperOrigin-RevId: 350714077
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

Successfully merging a pull request may close this issue.

1 participant