-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b40
-
x86
-
linux_oracle_5.4, windows_7
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175473 | openjdk7u | David Holmes | P4 | Resolved | Fixed | master |
FULL PRODUCT VERSION :
java version "1.7.0_02-ea"
Java(TM) SE Runtime Environment (build 1.7.0_02-ea-b08)
Java HotSpot(TM) Client VM (build 22.0-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The AtomicIntegerFieldUpdater and AtomicReferenceFieldUpdater classes cannot be constructed when a SecurityManager is installed. It fails with:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Call AtomicIntegerFieldUpdater.newUpdater when launching java with the -Djava.security.manager argument.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result is a new AtomicIntegerFieldUpdater.
ACTUAL -
Actual result is a SecurityException, wrapped by a RuntimeException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.<init>(AtomicIntegerFieldUpdater.java:283)
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdater.java:73)
at dirmi.SecurityBug.<clinit>(SecurityBug.java:10)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:555)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1679)
at java.lang.Class.checkMemberAccess(Class.java:2174)
at java.lang.Class.getDeclaredField(Class.java:1896)
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.<init>(AtomicIntegerFieldUpdater.java:276)
... 2 more
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
// Tests bug in AtomicIntegerFieldUpdater.
public class SecurityBug {
private static final AtomicIntegerFieldUpdater<SecurityBug> updater;
static {
updater = AtomicIntegerFieldUpdater.newUpdater(SecurityBug.class, "theField");
}
private volatile int theField;
public static void main(String[] args) throws Exception {
new SecurityBug();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use the AtomicInteger class or relax the security policy.
java version "1.7.0_02-ea"
Java(TM) SE Runtime Environment (build 1.7.0_02-ea-b08)
Java HotSpot(TM) Client VM (build 22.0-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The AtomicIntegerFieldUpdater and AtomicReferenceFieldUpdater classes cannot be constructed when a SecurityManager is installed. It fails with:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Call AtomicIntegerFieldUpdater.newUpdater when launching java with the -Djava.security.manager argument.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result is a new AtomicIntegerFieldUpdater.
ACTUAL -
Actual result is a SecurityException, wrapped by a RuntimeException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.<init>(AtomicIntegerFieldUpdater.java:283)
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater.newUpdater(AtomicIntegerFieldUpdater.java:73)
at dirmi.SecurityBug.<clinit>(SecurityBug.java:10)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:555)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1679)
at java.lang.Class.checkMemberAccess(Class.java:2174)
at java.lang.Class.getDeclaredField(Class.java:1896)
at java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.<init>(AtomicIntegerFieldUpdater.java:276)
... 2 more
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
// Tests bug in AtomicIntegerFieldUpdater.
public class SecurityBug {
private static final AtomicIntegerFieldUpdater<SecurityBug> updater;
static {
updater = AtomicIntegerFieldUpdater.newUpdater(SecurityBug.class, "theField");
}
private volatile int theField;
public static void main(String[] args) throws Exception {
new SecurityBug();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use the AtomicInteger class or relax the security policy.
- backported by
-
JDK-8175473 AtomicIntegerFieldUpdater does not work when SecurityManager is installed
- Resolved
- duplicates
-
JDK-7131655 Atomic*FieldUpdater security permissions too strict
- Closed