mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8301462: Convert Permission files to use lambda after JDK-8076596
Reviewed-by: jpai, dfuchs, mullan
This commit is contained in:
parent
8d4c76ddce
commit
10dd98d0dd
5 changed files with 61 additions and 94 deletions
|
@ -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;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue