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, 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;
}
);
}