So we have been writing
x = AccessController.doPrivileged(
new PrivilegedAction<Object>() {
public Object run() {
return some();
}
}
);
Using jdk8 lambda, it seems we can write
x = AccessController.doPrivileged(() -> some());
But it does not compile, because () -> some() matches both
PrivilegedAction and PrivilegedExceptionAction. So it has to be
x = AccessController.doPrivileged(
(PrivilegedAction<Object>)(() -> some()));
which is cumbersome again.
I'm not requesting for any new API at the moment, just talking about my
frustration.
-Max