Merge pull request #14274 from rmuir/broken_code
Add workaround for JDK-8014008
This commit is contained in:
commit
fffafbfd4d
|
@ -25,6 +25,7 @@ import java.net.URL;
|
|||
import java.security.CodeSource;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.Permissions;
|
||||
import java.security.Policy;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.Map;
|
||||
|
@ -89,6 +90,21 @@ final class ESPolicy extends Policy {
|
|||
return template.implies(domain, permission) || dynamic.implies(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionCollection getPermissions(CodeSource codesource) {
|
||||
// code should not rely on this method, or at least use it correctly:
|
||||
// https://bugs.openjdk.java.net/browse/JDK-8014008
|
||||
// return them a new empty permissions object so jvisualvm etc work
|
||||
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
|
||||
if ("sun.rmi.server.LoaderHandler".equals(element.getClassName()) &&
|
||||
"loadClass".equals(element.getMethodName())) {
|
||||
return new Permissions();
|
||||
}
|
||||
}
|
||||
// return UNSUPPORTED_EMPTY_COLLECTION since it is safe.
|
||||
return super.getPermissions(codesource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Classy puzzler to rethrow any checked exception as an unchecked one.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue