90 } catch (PrivilegedActionException e) { |
90 } catch (PrivilegedActionException e) { |
91 throw (IOException)e.getException(); |
91 throw (IOException)e.getException(); |
92 } |
92 } |
93 } |
93 } |
94 |
94 |
95 URL getResourceAsURL(final ClassLoader cl, |
95 // Used for debugging purposes |
96 final String name) |
96 String getClassSource(Class<?> cls) { |
97 { |
97 return AccessController.doPrivileged(new PrivilegedAction<String>() { |
98 return (URL) |
98 public String run() { |
99 AccessController.doPrivileged(new PrivilegedAction() { |
99 CodeSource cs = cls.getProtectionDomain().getCodeSource(); |
100 public Object run() { |
100 if (cs != null) { |
101 URL url; |
101 return cs.getLocation().toString(); |
102 if (cl == null) { |
102 } else { |
103 url = Object.class.getResource(name); |
103 return "(no code source)"; |
104 } else { |
104 } |
105 url = cl.getResource(name); |
105 } |
106 } |
106 }); |
107 return url; |
|
108 } |
|
109 }); |
|
110 } |
|
111 |
|
112 Enumeration getResources(final ClassLoader cl, |
|
113 final String name) throws IOException |
|
114 { |
|
115 try{ |
|
116 return (Enumeration) |
|
117 AccessController.doPrivileged(new PrivilegedExceptionAction() { |
|
118 public Object run() throws IOException{ |
|
119 Enumeration enumeration; |
|
120 if (cl == null) { |
|
121 enumeration = ClassLoader.getSystemResources(name); |
|
122 } else { |
|
123 enumeration = cl.getResources(name); |
|
124 } |
|
125 return enumeration; |
|
126 } |
|
127 }); |
|
128 }catch(PrivilegedActionException e){ |
|
129 throw (IOException)e.getException(); |
|
130 } |
|
131 } |
107 } |
132 |
108 |
133 boolean doesFileExist(final File f) { |
109 boolean doesFileExist(final File f) { |
134 return ((Boolean) |
110 return ((Boolean) |
135 AccessController.doPrivileged(new PrivilegedAction() { |
111 AccessController.doPrivileged(new PrivilegedAction() { |
136 public Object run() { |
112 public Object run() { |
137 return new Boolean(f.exists()); |
113 return new Boolean(f.exists()); |
138 } |
114 } |
139 })).booleanValue(); |
115 })).booleanValue(); |