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

One version of Parameter lacks the getAnnotatedType() method #5630

Closed
mernst opened this issue Jun 28, 2021 · 4 comments
Closed

One version of Parameter lacks the getAnnotatedType() method #5630

mernst opened this issue Jun 28, 2021 · 4 comments

Comments

@mernst
Copy link
Contributor

mernst commented Jun 28, 2021

The variant of class com.google.common.reflect.Parameter that is defined in file android/guava/src/com/google/common/reflect/Parameter.java lacks the getAnnotatedType() method that appears in
file guava/src/com/google/common/reflect/Parameter.java. I think this method should appear in the Android version too, since (according to my reading of https://developer.android.com/studio/write/java8-support) Android does support type annotations.

@netdpb
Copy link
Member

netdpb commented Jun 28, 2021

The note I see there about type annotations says: "Type annotation information is only available at compile time, and not at runtime." That suggests that the reflection API doesn't have access to type annotations. Does that sound correct?

@mernst
Copy link
Contributor Author

mernst commented Jun 29, 2021

Oh, is Parameter only used at run time, never at compile time? It's not documented either way. (It is in a package named reflect..., which is a strong hint, but I've seen such inconsistencies in some projects and didn't want to assume.)

Thanks for the correction to my (lack of) assumption; I appreciate your help!

When @Nullable is a type annotation, how will tests like nullPointerTester and testNullPointers and testNullPointerExceptions work? I was actually trying to make those tests pass when @Nullable is a type annotation.

@cpovirk
Copy link
Member

cpovirk commented Jun 29, 2021

There are probably half a dozen unfortunate things that are intersecting here.

Among them:

The long-term plan will likely be:

  • drop Java 7 support
  • use type annotations everywhere
  • make Parameter use getAnnotatedParameterTypes when running in a JRE (but skip it when running under an Android VM)
  • run NullPointerTester tests only under a JRE

I'm not sure if any of that helps with the immediate NullPointerTester issue you're encountering, though.

@mernst
Copy link
Contributor Author

mernst commented Jun 29, 2021

Chris, the long-term plan you laid out is actually very helpful. Thanks!

I think I will just disable the NullPointerTests under Android for now, extricating myself from the rat's nest I have wandered into.

@mernst mernst closed this as completed Jun 29, 2021
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

3 participants