JDK-8019851 : Add new AccessController.callPrivileged methods for easy use with lambda
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 8
  • Priority: P2
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2013-07-03
  • Updated: 2018-08-06
  • Resolved: 2018-08-06
Related Reports
Relates :  
Relates :  
Description
The overloads make it cumbersome to use this feature with lambda expressions:

http://mail.openjdk.java.net/pipermail/security-dev/2013-May/007434.html

Suggest to rename the variant which take a PrivilegedExceptionAction argument to make this possible:
   AccessController.doPrivileged(() -> some());

This bug is filed to follow up some review comments:

[1] http://mail.openjdk.java.net/pipermail/security-dev/2013-May/007593.html
[2] http://mail.openjdk.java.net/pipermail/security-dev/2013-June/007673.html
Comments
Closing as "Won't Fix" as this enhancement is no longer considered a priority and the current API is adequate.
06-08-2018

Changing to RFE.
13-07-2016

Excuse me, any progress on re-examine in 9? It has been over half a year since last update.
25-12-2014

Peter - this bug was created before Java SE 8 was finalized and there was an opportunity for API changes then. AFAIK, it was eventually decided to just leave it as is and re-examine in 9 (which of course means that existing methods can be changed).
07-03-2014

AccessController is public API so I doubt its methods could simply be renamed. That would not be backwards-compatible. But I think that retrofitting PrivilegedAction interface like this is backwards-compatible: public interface PrivilegedExceptionAction<T> { T run() throws Exception; } public interface PrivilegedAction<T> extends PrivilegedExceptionAction<T> { @Override T run(); } Whith this change, PrivilegedAction would be more specific than PrivilegedExceptionAction and for the majority of cases where lambda body did not throw checked exceptions, the most-specific rule for overloaded method resolution would choose the doPrivileged(PrivilegedAction) variants automatically without casting. To choose the doPrivileged(PrivilegedExceptionAction) variants the cast would still be needed. Another possibility is to simply add new methods with different name as the title of this issue already suggests: AccessController.callPrivileged(PrivilegedAction[, ...]) which would not be overloaded with variants for PrivilegedExceptionAction.
07-03-2014

Release team: Approved for deferral.
11-12-2013

Changed the fixVersion to 8 per the deferral process rules.
06-12-2013

SQE: we need specs for these changes. Due to product certification constraints, the latest SQE can accept this feature, including specs, is 2013-12-05.
21-11-2013