[libbluray-devel] BJSecurityManager: re-implement deprecated classDepth()
hpi1
git at videolan.org
Thu Sep 13 14:12:25 CEST 2018
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Sep 13 15:06:46 2018 +0300| [de3028113507c76ec97cacb4de82599b58dd38ec] | committer: hpi1
BJSecurityManager: re-implement deprecated classDepth()
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=de3028113507c76ec97cacb4de82599b58dd38ec
---
.../bdj/java/org/videolan/BDJSecurityManager.java | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java b/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java
index 76755602..9a5a3793 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java
@@ -68,6 +68,18 @@ final class BDJSecurityManager extends SecurityManager {
*
*/
+ private int classDepth0(String name) {
+ StackTraceElement e[] = new Exception("Stack trace").getStackTrace();
+ if (e != null && e.length > 1) {
+ for (int i = 1; i < e.length; i++) {
+ if (e[i].getClassName().equals(name)) {
+ return i - 1;
+ }
+ }
+ }
+ return -1;
+ }
+
private void deny(Permission perm) {
logger.error("denied " + perm + "\n" + Logger.dumpStack());
throw new SecurityException("denied " + perm);
@@ -78,14 +90,14 @@ final class BDJSecurityManager extends SecurityManager {
if (perm.implies(new RuntimePermission("createSecurityManager"))) {
// allow initializing of javax.crypto.JceSecurityManager
- if (classDepth("javax.crypto.JceSecurityManager") < 3) {
+ if (classDepth0("javax.crypto.JceSecurityManager") < 3) {
return;
}
deny(perm);
}
if (perm.implies(new RuntimePermission("setSecurityManager"))) {
- if (classDepth("org.videolan.Libbluray") == 3) {
+ if (classDepth0("org.videolan.Libbluray") == 3) {
return;
}
deny(perm);
@@ -94,7 +106,7 @@ final class BDJSecurityManager extends SecurityManager {
// work around bug in openjdk 7 / 8
// sun.awt.AWTAutoShutdown.notifyThreadBusy is missing doPrivileged()
// (fixed in jdk9 / http://hg.openjdk.java.net/jdk9/client/jdk/rev/5b613a3c04be )
- if (classDepth("sun.awt.AWTAutoShutdown") > 0) {
+ if (classDepth0("sun.awt.AWTAutoShutdown") > 0) {
return;
}
More information about the libbluray-devel
mailing list