8311170: Simplify and modernize equals and hashCode in security area

Reviewed-by: djelinski, rriggs, valeriep
This commit is contained in:
Pavel Rappo 2023-08-09 12:34:40 +00:00
parent e9f751ab16
commit 19ae62ae2c
96 changed files with 567 additions and 951 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -764,6 +764,7 @@ public final class AccessControlContext {
* and has the same set of {@code ProtectionDomain} objects as this context,
* {@code false} otherwise.
*/
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
@ -940,22 +941,20 @@ public final class AccessControlContext {
/**
* Returns the hash code value for this context. The hash code
* is computed by exclusive or-ing the hash code of all the protection
* domains in the context together.
*
* @return a hash code value for this context.
* {@return the hash code value for this context}
* The hash code is computed by exclusive or-ing the hash code of all the
* protection domains in the context together.
*/
@Override
public int hashCode() {
int hashCode = 0;
if (context == null)
return hashCode;
for (int i =0; i < context.length; i++) {
if (context[i] != null)
hashCode ^= context[i].hashCode();
for (ProtectionDomain protectionDomain : context) {
if (protectionDomain != null)
hashCode ^= protectionDomain.hashCode();
}
return hashCode;