|
1 | 1 | /* |
2 | | - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -860,14 +860,12 @@ void getIP() |
860 | 860 | public boolean implies(Permission p) { |
861 | 861 | int i,j; |
862 | 862 |
|
863 | | - if (!(p instanceof SocketPermission)) |
| 863 | + if (!(p instanceof SocketPermission that)) |
864 | 864 | return false; |
865 | 865 |
|
866 | 866 | if (p == this) |
867 | 867 | return true; |
868 | 868 |
|
869 | | - SocketPermission that = (SocketPermission) p; |
870 | | - |
871 | 869 | return ((this.mask & that.mask) == that.mask) && |
872 | 870 | impliesIgnoreMask(that); |
873 | 871 | } |
@@ -1040,11 +1038,9 @@ public boolean equals(Object obj) { |
1040 | 1038 | if (obj == this) |
1041 | 1039 | return true; |
1042 | 1040 |
|
1043 | | - if (! (obj instanceof SocketPermission)) |
| 1041 | + if (! (obj instanceof SocketPermission that)) |
1044 | 1042 | return false; |
1045 | 1043 |
|
1046 | | - SocketPermission that = (SocketPermission) obj; |
1047 | | - |
1048 | 1044 | //this is (overly?) complex!!! |
1049 | 1045 |
|
1050 | 1046 | // check the mask first |
@@ -1379,15 +1375,13 @@ public SocketPermissionCollection() { |
1379 | 1375 | */ |
1380 | 1376 | @Override |
1381 | 1377 | public void add(Permission permission) { |
1382 | | - if (! (permission instanceof SocketPermission)) |
| 1378 | + if (! (permission instanceof SocketPermission sp)) |
1383 | 1379 | throw new IllegalArgumentException("invalid permission: "+ |
1384 | 1380 | permission); |
1385 | 1381 | if (isReadOnly()) |
1386 | 1382 | throw new SecurityException( |
1387 | 1383 | "attempt to add a Permission to a readonly PermissionCollection"); |
1388 | 1384 |
|
1389 | | - SocketPermission sp = (SocketPermission)permission; |
1390 | | - |
1391 | 1385 | // Add permission to map if it is absent, or replace with new |
1392 | 1386 | // permission if applicable. NOTE: cannot use lambda for |
1393 | 1387 | // remappingFunction parameter until JDK-8076596 is fixed. |
@@ -1426,11 +1420,9 @@ public SocketPermission apply(SocketPermission existingVal, |
1426 | 1420 | @Override |
1427 | 1421 | public boolean implies(Permission permission) |
1428 | 1422 | { |
1429 | | - if (! (permission instanceof SocketPermission)) |
| 1423 | + if (! (permission instanceof SocketPermission np)) |
1430 | 1424 | return false; |
1431 | 1425 |
|
1432 | | - SocketPermission np = (SocketPermission) permission; |
1433 | | - |
1434 | 1426 | int desired = np.getMask(); |
1435 | 1427 | int effective = 0; |
1436 | 1428 | int needed = desired; |
|
0 commit comments