mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8263233: Update java.net and java.nio to use instanceof pattern variable
Reviewed-by: dfuchs, bpb, chegar, michaelm
This commit is contained in:
parent
3fe8a4661c
commit
fdd3941121
17 changed files with 39 additions and 73 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
|
@ -860,14 +860,12 @@ public final class SocketPermission extends Permission
|
|||
public boolean implies(Permission p) {
|
||||
int i,j;
|
||||
|
||||
if (!(p instanceof SocketPermission))
|
||||
if (!(p instanceof SocketPermission that))
|
||||
return false;
|
||||
|
||||
if (p == this)
|
||||
return true;
|
||||
|
||||
SocketPermission that = (SocketPermission) p;
|
||||
|
||||
return ((this.mask & that.mask) == that.mask) &&
|
||||
impliesIgnoreMask(that);
|
||||
}
|
||||
|
@ -1040,11 +1038,9 @@ public final class SocketPermission extends Permission
|
|||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (! (obj instanceof SocketPermission))
|
||||
if (! (obj instanceof SocketPermission that))
|
||||
return false;
|
||||
|
||||
SocketPermission that = (SocketPermission) obj;
|
||||
|
||||
//this is (overly?) complex!!!
|
||||
|
||||
// check the mask first
|
||||
|
@ -1379,15 +1375,13 @@ final class SocketPermissionCollection extends PermissionCollection
|
|||
*/
|
||||
@Override
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof SocketPermission))
|
||||
if (! (permission instanceof SocketPermission sp))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
if (isReadOnly())
|
||||
throw new SecurityException(
|
||||
"attempt to add a Permission to a readonly PermissionCollection");
|
||||
|
||||
SocketPermission sp = (SocketPermission)permission;
|
||||
|
||||
// Add permission to map if it is absent, or replace with new
|
||||
// permission if applicable. NOTE: cannot use lambda for
|
||||
// remappingFunction parameter until JDK-8076596 is fixed.
|
||||
|
@ -1426,11 +1420,9 @@ final class SocketPermissionCollection extends PermissionCollection
|
|||
@Override
|
||||
public boolean implies(Permission permission)
|
||||
{
|
||||
if (! (permission instanceof SocketPermission))
|
||||
if (! (permission instanceof SocketPermission np))
|
||||
return false;
|
||||
|
||||
SocketPermission np = (SocketPermission) permission;
|
||||
|
||||
int desired = np.getMask();
|
||||
int effective = 0;
|
||||
int needed = desired;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue