Skip to content

Commit

Permalink
Annotate TrustAnchor for nullness. (typetools#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpovirk authored Jul 13, 2024
1 parent 96290b8 commit 6bdbb4f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/java.base/share/classes/java/security/cert/TrustAnchor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package java.security.cert;

import org.checkerframework.checker.interning.qual.UsesObjectEquals;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.io.IOException;
Expand Down Expand Up @@ -64,7 +65,7 @@
* @since 1.4
* @author Sean Mullan
*/
@AnnotatedFor({"interning"})
@AnnotatedFor({"interning", "nullness"})
public @UsesObjectEquals class TrustAnchor {

private final PublicKey pubKey;
Expand Down Expand Up @@ -131,7 +132,7 @@
* @throws NullPointerException if the specified
* {@code X509Certificate} is {@code null}
*/
public TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints)
public TrustAnchor(X509Certificate trustedCert, byte @Nullable [] nameConstraints)
{
if (trustedCert == null)
throw new NullPointerException("the trustedCert parameter must " +
Expand Down Expand Up @@ -171,7 +172,7 @@ public TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints)
* @since 1.5
*/
public TrustAnchor(X500Principal caPrincipal, PublicKey pubKey,
byte[] nameConstraints) {
byte @Nullable [] nameConstraints) {
if ((caPrincipal == null) || (pubKey == null)) {
throw new NullPointerException();
}
Expand Down Expand Up @@ -213,7 +214,7 @@ public TrustAnchor(X500Principal caPrincipal, PublicKey pubKey,
* @throws NullPointerException if the specified {@code caName} or
* {@code pubKey} parameter is {@code null}
*/
public TrustAnchor(String caName, PublicKey pubKey, byte[] nameConstraints)
public TrustAnchor(String caName, PublicKey pubKey, byte @Nullable [] nameConstraints)
{
if (pubKey == null)
throw new NullPointerException("the pubKey parameter must be " +
Expand All @@ -238,7 +239,7 @@ public TrustAnchor(String caName, PublicKey pubKey, byte[] nameConstraints)
* @return a trusted {@code X509Certificate} or {@code null}
* if the trust anchor was not specified as a trusted certificate
*/
public final X509Certificate getTrustedCert() {
public final @Nullable X509Certificate getTrustedCert() {
return this.trustedCert;
}

Expand All @@ -250,7 +251,7 @@ public final X509Certificate getTrustedCert() {
* public key and name or X500Principal pair
* @since 1.5
*/
public final X500Principal getCA() {
public final @Nullable X500Principal getCA() {
return this.caPrincipal;
}

Expand All @@ -262,7 +263,7 @@ public final X500Principal getCA() {
* {@code null} if the trust anchor was not specified as a trusted
* public key and name or X500Principal pair
*/
public final String getCAName() {
public final @Nullable String getCAName() {
return this.caName;
}

Expand All @@ -273,7 +274,7 @@ public final String getCAName() {
* if the trust anchor was not specified as a trusted public key and name
* or X500Principal pair
*/
public final PublicKey getCAPublicKey() {
public final @Nullable PublicKey getCAPublicKey() {
return this.pubKey;
}

Expand Down Expand Up @@ -318,7 +319,7 @@ private void setNameConstraints(byte[] bytes) {
* a NameConstraints extension used for checking name constraints,
* or {@code null} if not set.
*/
public final byte [] getNameConstraints() {
public final byte @Nullable [] getNameConstraints() {
return ncBytes == null ? null : ncBytes.clone();
}

Expand Down

0 comments on commit 6bdbb4f

Please sign in to comment.