mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8311170: Simplify and modernize equals and hashCode in security area
Reviewed-by: djelinski, rriggs, valeriep
This commit is contained in:
parent
e9f751ab16
commit
19ae62ae2c
96 changed files with 567 additions and 951 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -177,19 +177,20 @@ public abstract class CertPath implements Serializable {
|
|||
* @return true if the specified object is equal to this certification path,
|
||||
* false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
|
||||
return other instanceof CertPath that
|
||||
&& that.getType().equals(this.type)
|
||||
&& this.type.equals(that.getType())
|
||||
&& this.getCertificates().equals(that.getCertificates());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hashcode for this certification path. The hash code of
|
||||
* a certification path is defined to be the result of the following
|
||||
* calculation:
|
||||
* {@return the hashcode value for this certification path}
|
||||
* The hash code of a certification path is defined to be the result of
|
||||
* the following calculation:
|
||||
* <pre>{@code
|
||||
* hashCode = path.getType().hashCode();
|
||||
* hashCode = 31*hashCode + path.getCertificates().hashCode();
|
||||
|
@ -198,9 +199,8 @@ public abstract class CertPath implements Serializable {
|
|||
* {@code path1.hashCode()==path2.hashCode()} for any two certification
|
||||
* paths, {@code path1} and {@code path2}, as required by the
|
||||
* general contract of {@code Object.hashCode}.
|
||||
*
|
||||
* @return the hashcode value for this certification path
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = type.hashCode();
|
||||
hashCode = 31*hashCode + getCertificates().hashCode();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue