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

SignatureChecker ignores annotation of enclosing class when checking field type #131

Closed
Marcono1234 opened this issue Nov 4, 2020 · 3 comments · Fixed by #212
Closed

Comments

@Marcono1234
Copy link
Contributor

It looks like SignatureChecker ignores whether the enclosing class is annotated (and errors should be ignored) when processing field types:

This should probably be checkType(Type.getType(descriptor), ignoreError);.

@cpovirk
Copy link

cpovirk commented Dec 17, 2020

I think I hit this, as well. I attempted to work around it by putting @IgnoreJRERequirement on the field itself, but that turns out not to be a valid target:

@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})

(At first, I was using our own custom @IgnoreJRERequirement annotation (background). That annotation is defined to allow us to place it on fields, but presumably Animal Sniffer doesn't look there for it, since it's not normally valid.)

copybara-service bot pushed a commit to google/guava that referenced this issue Dec 17, 2020
Values:
https://www.mojohaus.org/animal-sniffer/animal-sniffer-annotations/apidocs/org/codehaus/mojo/animal_sniffer/IgnoreJRERequirement.html

Context:
This doesn't "fix" anything, but it prevents us from replicating an error I just made in the future:
mojohaus/animal-sniffer#131 (comment)
RELNOTES=n/a
PiperOrigin-RevId: 348053776
copybara-service bot pushed a commit to google/guava that referenced this issue Dec 17, 2020
Values:
https://www.mojohaus.org/animal-sniffer/animal-sniffer-annotations/apidocs/org/codehaus/mojo/animal_sniffer/IgnoreJRERequirement.html

Context:
This doesn't "fix" anything, but it prevents us from replicating an error I just made in the future:
mojohaus/animal-sniffer#131 (comment)
RELNOTES=n/a
PiperOrigin-RevId: 348062753
@olamy olamy closed this as completed Aug 16, 2022
@Marcono1234
Copy link
Contributor Author

This is not fixed in 1.22; the comment on PR #139 erroneously referred to this issue (if I see that correctly). This can still be seen with the following simple example (using Java 5 signatures):

import java.util.Optional;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

@IgnoreJRERequirement
class MyClass {
    // BUG: This is not ignored
    Optional<String> f;
    
    // This is ignored due to @IgnoreJRERequirement, as desired
    Optional<String> test() {
        return null;
    }
}

@TimvdLippe
Copy link

Can confirm that this issue has not been fixed yet: mockito/mockito#2735

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.

5 participants