35 |
35 |
36 static ClassLoader getContextClassLoader() { |
36 static ClassLoader getContextClassLoader() { |
37 if (System.getSecurityManager() == null) { |
37 if (System.getSecurityManager() == null) { |
38 return Thread.currentThread().getContextClassLoader(); |
38 return Thread.currentThread().getContextClassLoader(); |
39 } else { |
39 } else { |
40 return (ClassLoader) java.security.AccessController.doPrivileged( |
40 return java.security.AccessController.doPrivileged( |
41 new java.security.PrivilegedAction() { |
41 new java.security.PrivilegedAction<ClassLoader>() { |
42 public java.lang.Object run() { |
42 public ClassLoader run() { |
43 return Thread.currentThread().getContextClassLoader(); |
43 return Thread.currentThread().getContextClassLoader(); |
44 } |
44 } |
45 }); |
45 }); |
46 } |
46 } |
47 } |
47 } |
48 |
48 |
49 static ClassLoader getClassClassLoader(final Class c) { |
49 static ClassLoader getClassClassLoader(final Class c) { |
50 if (System.getSecurityManager() == null) { |
50 if (System.getSecurityManager() == null) { |
51 return c.getClassLoader(); |
51 return c.getClassLoader(); |
52 } else { |
52 } else { |
53 return (ClassLoader) java.security.AccessController.doPrivileged( |
53 return java.security.AccessController.doPrivileged( |
54 new java.security.PrivilegedAction() { |
54 new java.security.PrivilegedAction<ClassLoader>() { |
55 public java.lang.Object run() { |
55 public ClassLoader run() { |
56 return c.getClassLoader(); |
56 return c.getClassLoader(); |
57 } |
57 } |
58 }); |
58 }); |
59 } |
59 } |
60 } |
60 } |
61 |
61 |
62 static ClassLoader getSystemClassLoader() { |
62 static ClassLoader getSystemClassLoader() { |
63 if (System.getSecurityManager() == null) { |
63 if (System.getSecurityManager() == null) { |
64 return ClassLoader.getSystemClassLoader(); |
64 return ClassLoader.getSystemClassLoader(); |
65 } else { |
65 } else { |
66 return (ClassLoader) java.security.AccessController.doPrivileged( |
66 return java.security.AccessController.doPrivileged( |
67 new java.security.PrivilegedAction() { |
67 new java.security.PrivilegedAction<ClassLoader>() { |
68 public java.lang.Object run() { |
68 public ClassLoader run() { |
69 return ClassLoader.getSystemClassLoader(); |
69 return ClassLoader.getSystemClassLoader(); |
70 } |
70 } |
71 }); |
71 }); |
72 } |
72 } |
73 } |
73 } |