Skip to content

Commit

Permalink
Give the Provider constructor parameter of KeyStore unspecified n…
Browse files Browse the repository at this point in the history
…ullness.

As discussed in
#29 (comment), I can't
tell whether it should be `@Nullable` or not.

The way to give it unspecified nullness is to use `@NullUnmarked`. To at
least keep non-null types for the _other_ two parameters, I've added
`@NonNull` on them.

This would be slightly simpler with [a type-use annotation for
unspecified nullness](jspecify/jspecify#137).
But the approach described above works fine (if somewhat verbosely),
since there this API doesn't use parametric nullness.
  • Loading branch information
cpovirk committed Nov 21, 2024
1 parent 457b292 commit 53f1725
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/java.base/share/classes/java/security/KeyStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

package java.security;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.io.*;
Expand Down Expand Up @@ -814,7 +816,8 @@ public String toString() {
* @param provider the provider.
* @param type the keystore type.
*/
protected KeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type)
@NullUnmarked // https://github.com/jspecify/jdk/pull/29#issuecomment-1653637366
protected KeyStore(@NonNull KeyStoreSpi keyStoreSpi, Provider provider, @NonNull String type)
{
this.keyStoreSpi = keyStoreSpi;
this.provider = provider;
Expand Down

0 comments on commit 53f1725

Please sign in to comment.