38 |
|
|
39 |
package java.lang; |
package java.lang; |
40 |
|
|
41 |
|
import gnu.classpath.VMStackWalker; |
42 |
|
|
43 |
import java.io.InputStream; |
import java.io.InputStream; |
44 |
import java.io.Serializable; |
import java.io.Serializable; |
45 |
import java.lang.reflect.Constructor; |
import java.lang.reflect.Constructor; |
132 |
Class(Object vmdata, ProtectionDomain pd) |
Class(Object vmdata, ProtectionDomain pd) |
133 |
{ |
{ |
134 |
this.vmdata = vmdata; |
this.vmdata = vmdata; |
135 |
this.pd = pd; |
// If the VM didn't supply a protection domain and the class is an array, |
136 |
|
// we "inherit" the protection domain from the component type class. This |
137 |
|
// saves the VM from having to worry about protection domains for array |
138 |
|
// classes. |
139 |
|
if (pd == null && isArray()) |
140 |
|
this.pd = getComponentType().pd; |
141 |
|
else |
142 |
|
this.pd = pd; |
143 |
} |
} |
144 |
|
|
145 |
/** |
/** |
160 |
Class<?> result = VMClass.forName (name); |
Class<?> result = VMClass.forName (name); |
161 |
if (result == null) |
if (result == null) |
162 |
result = Class.forName(name, true, |
result = Class.forName(name, true, |
163 |
VMSecurityManager.getClassContext()[1].getClassLoader()); |
VMStackWalker.getCallingClassLoader()); |
164 |
return result; |
return result; |
165 |
} |
} |
166 |
|
|
198 |
if (classloader == null) |
if (classloader == null) |
199 |
{ |
{ |
200 |
// Check if we may access the bootstrap classloader |
// Check if we may access the bootstrap classloader |
201 |
SecurityManager sm = System.getSecurityManager(); |
SecurityManager sm = SecurityManager.current; |
202 |
if (sm != null) |
if (sm != null) |
203 |
{ |
{ |
204 |
// Get the calling class and classloader |
// Get the calling classloader |
205 |
Class<?> c = VMSecurityManager.getClassContext()[1]; |
ClassLoader cl = VMStackWalker.getCallingClassLoader(); |
|
ClassLoader cl = c.getClassLoader(); |
|
206 |
if (cl != null) |
if (cl != null) |
207 |
sm.checkPermission(new RuntimePermission("getClassLoader")); |
sm.checkPermission(new RuntimePermission("getClassLoader")); |
208 |
} |
} |
277 |
|
|
278 |
ClassLoader loader = VMClass.getClassLoader(this); |
ClassLoader loader = VMClass.getClassLoader(this); |
279 |
// Check if we may get the classloader |
// Check if we may get the classloader |
280 |
SecurityManager sm = System.getSecurityManager(); |
SecurityManager sm = SecurityManager.current; |
281 |
if (sm != null) |
if (sm != null) |
282 |
{ |
{ |
283 |
// Get the calling class and classloader |
// Get the calling classloader |
284 |
Class c = VMSecurityManager.getClassContext()[1]; |
ClassLoader cl = VMStackWalker.getCallingClassLoader(); |
|
ClassLoader cl = VMClass.getClassLoader(c); |
|
285 |
if (cl != null && !cl.isAncestorOf(loader)) |
if (cl != null && !cl.isAncestorOf(loader)) |
286 |
sm.checkPermission(new RuntimePermission("getClassLoader")); |
sm.checkPermission(new RuntimePermission("getClassLoader")); |
287 |
} |
} |
1133 |
int modifiers = constructor.getModifiers(); |
int modifiers = constructor.getModifiers(); |
1134 |
if (!Modifier.isPublic(modifiers)) |
if (!Modifier.isPublic(modifiers)) |
1135 |
{ |
{ |
1136 |
Class caller = VMSecurityManager.getClassContext()[1]; |
Class caller = VMStackWalker.getCallingClass(); |
1137 |
if (caller != this && |
if (caller != null && |
1138 |
|
caller != this && |
1139 |
(Modifier.isPrivate(modifiers) |
(Modifier.isPrivate(modifiers) |
1140 |
|| getClassLoader() != caller.getClassLoader() |
|| getClassLoader() != caller.getClassLoader() |
1141 |
|| !getPackagePortion(getName()) |
|| !getPackagePortion(getName()) |
1170 |
*/ |
*/ |
1171 |
public ProtectionDomain getProtectionDomain() |
public ProtectionDomain getProtectionDomain() |
1172 |
{ |
{ |
1173 |
SecurityManager sm = System.getSecurityManager(); |
SecurityManager sm = SecurityManager.current; |
1174 |
if (sm != null) |
if (sm != null) |
1175 |
sm.checkPermission(new RuntimePermission("getProtectionDomain")); |
sm.checkPermission(new RuntimePermission("getProtectionDomain")); |
1176 |
|
|
1222 |
} |
} |
1223 |
else |
else |
1224 |
{ |
{ |
1225 |
status = ClassLoader.systemClassAssertionStatus.get(getName()); |
status = ClassLoader.StaticData. |
1226 |
|
systemClassAssertionStatus.get(getName()); |
1227 |
if (status != null) |
if (status != null) |
1228 |
return status.equals(Boolean.TRUE); |
return status.equals(Boolean.TRUE); |
1229 |
} |
} |
1247 |
{ |
{ |
1248 |
String name = getPackagePortion(getName()); |
String name = getPackagePortion(getName()); |
1249 |
if ("".equals(name)) |
if ("".equals(name)) |
1250 |
status = ClassLoader.systemPackageAssertionStatus.get(null); |
status = ClassLoader.StaticData. |
1251 |
|
systemPackageAssertionStatus.get(null); |
1252 |
else |
else |
1253 |
do |
do |
1254 |
{ |
{ |
1255 |
status = ClassLoader.systemPackageAssertionStatus.get(name); |
status = ClassLoader.StaticData. |
1256 |
|
systemPackageAssertionStatus.get(name); |
1257 |
name = getPackagePortion(name); |
name = getPackagePortion(name); |
1258 |
} |
} |
1259 |
while (! "".equals(name) && status == null); |
while (! "".equals(name) && status == null); |
1332 |
*/ |
*/ |
1333 |
private void memberAccessCheck(int which) |
private void memberAccessCheck(int which) |
1334 |
{ |
{ |
1335 |
SecurityManager sm = System.getSecurityManager(); |
SecurityManager sm = SecurityManager.current; |
1336 |
if (sm != null) |
if (sm != null) |
1337 |
{ |
{ |
1338 |
sm.checkMemberAccess(this, which); |
sm.checkMemberAccess(this, which); |