8301462: Convert Permission files to use lambda after JDK-8076596

Reviewed-by: jpai, dfuchs, mullan
This commit is contained in:
Mandy Chung 2023-02-08 19:06:41 +00:00
parent 8d4c76ddce
commit 10dd98d0dd
5 changed files with 61 additions and 94 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
@ -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;
}
);
}