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

Allow nulls for Method.invoke(null) and Field.get(null) #63

Closed
wants to merge 1 commit into from

Conversation

vlsi
Copy link

@vlsi vlsi commented Jul 4, 2020

The nulls are permitted there to access static fields and methods

The nulls are permitted there to access static fields and methods
@vlsi
Copy link
Author

vlsi commented Jul 5, 2020

test_plume_lib build fails because it has @SuppressWarnings(nullness:argument.type.incompatible) to suppress field.get(null): https://github.com/plume-lib/options/blob/24be095f55cd9f521b25f5409738e48dd4370481/src/main/java/org/plumelib/options/Options.java#L425

So plume_lib should be adjusted (excessive suppression should be removed) after this PR is merged.

@cpovirk
Copy link

cpovirk commented Jul 6, 2020

This is requested occasionally, as in typetools/checker-framework#1534. The Checker Framework policy is to declare the parameters as non-null to avoid any chance of NullPointerException. There was a comment about this in the old nullness stub. Perhaps it should be carried over to the new file that you're editing here. Additionally, you could consider a PR to provide a separate astub file, as proposed in typetools/checker-framework#3258

@vlsi
Copy link
Author

vlsi commented Jul 6, 2020

@cpovirk , thanks for looking into this, however, it looks like you are confused.

The PR allows null inputs for instance parameter.
Currently, checkerframework forbids to call static methods via reflection, and it does not really help to track nullability issues :(

That is why I believe it should be generally possible to call field.get(null) to get the value of a static field.

Of course, I can add a stub to my project, however, it is sad that the default mode is "you can't use reflection" :-/

@vlsi
Copy link
Author

vlsi commented Jul 6, 2020

The comment you mention says "warning", however, in practice the code like field.get(null) raises an error rather than a warning.

@vlsi
Copy link
Author

vlsi commented Jul 6, 2020

Ah, you want to have non-standard stub. Ok, then I would put that stub into pgjdbc for a while.

@vlsi vlsi closed this Jul 6, 2020
Ao-senXiong pushed a commit to Ao-senXiong/jdkopprop that referenced this pull request Sep 8, 2023
Co-authored-by: Mattias Ulbrich <ulbrich@kit.edu>
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 this pull request may close these issues.

2 participants