8301462: Convert Permission files to use lambda after JDK-8076596
Reviewed-by: jpai, dfuchs, mullan
This commit is contained in:
parent
8d4c76ddce
commit
10dd98d0dd
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
@ -1156,25 +1156,19 @@ final class FilePermissionCollection extends PermissionCollection
|
||||
|
||||
// Add permission to map if it is absent, or replace with new
|
||||
// permission if applicable.
|
||||
perms.merge(fp.getName(), fp,
|
||||
new java.util.function.BiFunction<>() {
|
||||
@Override
|
||||
public Permission apply(Permission existingVal,
|
||||
Permission newVal) {
|
||||
int oldMask = ((FilePermission)existingVal).getMask();
|
||||
int newMask = ((FilePermission)newVal).getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return ((FilePermission)newVal)
|
||||
.withNewActions(effective);
|
||||
}
|
||||
perms.merge(fp.getName(), fp, (existingVal, newVal) -> {
|
||||
int oldMask = ((FilePermission)existingVal).getMask();
|
||||
int newMask = ((FilePermission)newVal).getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return ((FilePermission)newVal).withNewActions(effective);
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -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
|
||||
@ -1383,27 +1383,20 @@ final class SocketPermissionCollection extends PermissionCollection
|
||||
"attempt to add a Permission to a readonly PermissionCollection");
|
||||
|
||||
// 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.
|
||||
perms.merge(sp.getName(), sp,
|
||||
new java.util.function.BiFunction<>() {
|
||||
@Override
|
||||
public SocketPermission apply(SocketPermission existingVal,
|
||||
SocketPermission newVal) {
|
||||
int oldMask = existingVal.getMask();
|
||||
int newMask = newVal.getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return new SocketPermission(sp.getName(),
|
||||
effective);
|
||||
}
|
||||
// permission if applicable.
|
||||
perms.merge(sp.getName(), sp, (existingVal, newVal) -> {
|
||||
int oldMask = existingVal.getMask();
|
||||
int newMask = newVal.getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return new SocketPermission(sp.getName(), effective);
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -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
|
||||
@ -79,22 +79,15 @@ implements java.io.Serializable
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
|
||||
// Add permission to map. NOTE: cannot use lambda for
|
||||
// remappingFunction parameter until JDK-8076596 is fixed.
|
||||
perms.compute(unresolvedPermission.getName(),
|
||||
new java.util.function.BiFunction<>() {
|
||||
@Override
|
||||
public List<UnresolvedPermission> apply(String key,
|
||||
List<UnresolvedPermission> oldValue) {
|
||||
if (oldValue == null) {
|
||||
List<UnresolvedPermission> v =
|
||||
new CopyOnWriteArrayList<>();
|
||||
v.add(unresolvedPermission);
|
||||
return v;
|
||||
} else {
|
||||
oldValue.add(unresolvedPermission);
|
||||
return oldValue;
|
||||
}
|
||||
// Add permission to map.
|
||||
perms.compute(unresolvedPermission.getName(), (key, oldValue) -> {
|
||||
if (oldValue == null) {
|
||||
List<UnresolvedPermission> v = new CopyOnWriteArrayList<>();
|
||||
v.add(unresolvedPermission);
|
||||
return v;
|
||||
} else {
|
||||
oldValue.add(unresolvedPermission);
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
@ -469,27 +469,20 @@ final class PropertyPermissionCollection extends PermissionCollection
|
||||
String propName = pp.getName();
|
||||
|
||||
// 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.
|
||||
perms.merge(propName, pp,
|
||||
new java.util.function.BiFunction<>() {
|
||||
@Override
|
||||
public PropertyPermission apply(PropertyPermission existingVal,
|
||||
PropertyPermission newVal) {
|
||||
|
||||
int oldMask = existingVal.getMask();
|
||||
int newMask = newVal.getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return new PropertyPermission(propName, effective);
|
||||
}
|
||||
// permission if applicable.
|
||||
perms.merge(propName, pp, (existingVal, newVal) -> {
|
||||
int oldMask = existingVal.getMask();
|
||||
int newMask = newVal.getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return new PropertyPermission(propName, effective);
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -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
|
||||
@ -567,26 +567,20 @@ final class KrbServicePermissionCollection extends PermissionCollection
|
||||
String princName = sp.getName();
|
||||
|
||||
// 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.
|
||||
perms.merge(princName, sp,
|
||||
new java.util.function.BiFunction<>() {
|
||||
@Override
|
||||
public Permission apply(Permission existingVal,
|
||||
Permission newVal) {
|
||||
int oldMask = ((ServicePermission) existingVal).getMask();
|
||||
int newMask = ((ServicePermission) newVal).getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return new ServicePermission(princName, effective);
|
||||
}
|
||||
// permission if applicable.
|
||||
perms.merge(princName, sp, (existingVal, newVal) -> {
|
||||
int oldMask = ((ServicePermission) existingVal).getMask();
|
||||
int newMask = ((ServicePermission) newVal).getMask();
|
||||
if (oldMask != newMask) {
|
||||
int effective = oldMask | newMask;
|
||||
if (effective == newMask) {
|
||||
return newVal;
|
||||
}
|
||||
if (effective != oldMask) {
|
||||
return new ServicePermission(princName, effective);
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
return existingVal;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user