[ACCEPTED]-AccessController.doPrivileged-jakarta-ee
Accepted answer
It is just getting a system property. Retrieving 9 system properties requires permissions which 8 the calling code may not have. The doPrivileged
asserts 7 the privileges of the calling class irrespective 6 of how it was called. Clearly, doPrivileged
is something 5 you need to be careful with.
The code quoted 4 is the equivalent of:
String lineSeparator = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<String>() {
public String run() {
return System.getProperty("line.separator");
}
}
);
(Don't you just love 3 the conciseness of Java's syntax?)
Without 2 asserting privileges, this can be rewritten 1 as:
String lineSeparator = System.getProperty("line.separator");
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.