1 |
/* Class.java -- Reference implementation of access to object metadata |
/* Class.java -- Reference implementation of access to object metadata |
2 |
Copyright (C) 1998, 2002 Free Software Foundation |
Copyright (C) 1998, 2002, 2003 Free Software Foundation |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
258 |
} |
} |
259 |
if (constructor == null) |
if (constructor == null) |
260 |
throw new InstantiationException(getName()); |
throw new InstantiationException(getName()); |
261 |
} |
if (!Modifier.isPublic(constructor.getModifiers())) |
|
int modifiers = constructor.getModifiers(); |
|
|
if (!Modifier.isPublic(modifiers)) |
|
|
{ |
|
|
Class caller = VMSecurityManager.getClassContext()[1]; |
|
|
if (caller != this && |
|
|
(Modifier.isPrivate(modifiers) || getClassLoader() != caller.getClassLoader() || |
|
|
!ClassHelper.getPackagePortion(getName()).equals(ClassHelper.getPackagePortion(caller.getName())))) |
|
|
throw new IllegalAccessException(getName() + " has an inaccessible constructor"); |
|
|
if (!constructor.isAccessible()) |
|
262 |
{ |
{ |
263 |
final Constructor finalConstructor = constructor; |
final Constructor finalConstructor = constructor; |
264 |
AccessController.doPrivileged(new PrivilegedAction() { |
AccessController.doPrivileged(new PrivilegedAction() { |
267 |
return null; |
return null; |
268 |
} |
} |
269 |
}); |
}); |
|
synchronized(this) |
|
|
{ |
|
|
if (this.constructor == null) |
|
|
this.constructor = constructor; |
|
|
} |
|
270 |
} |
} |
271 |
|
synchronized(this) |
272 |
|
{ |
273 |
|
if (this.constructor == null) |
274 |
|
this.constructor = constructor; |
275 |
|
} |
276 |
|
} |
277 |
|
int modifiers = constructor.getModifiers(); |
278 |
|
if (!Modifier.isPublic(modifiers)) |
279 |
|
{ |
280 |
|
Class caller = VMSecurityManager.getClassContext()[1]; |
281 |
|
if (caller != this && |
282 |
|
(Modifier.isPrivate(modifiers) |
283 |
|
|| getClassLoader() != caller.getClassLoader() |
284 |
|
|| !ClassHelper.getPackagePortion(getName()) |
285 |
|
.equals(ClassHelper.getPackagePortion(caller.getName())))) |
286 |
|
throw new IllegalAccessException(getName() |
287 |
|
+ " has an inaccessible constructor"); |
288 |
} |
} |
289 |
try |
try |
290 |
{ |
{ |
293 |
catch (InvocationTargetException e) |
catch (InvocationTargetException e) |
294 |
{ |
{ |
295 |
VMClass.throwException(e.getTargetException()); |
VMClass.throwException(e.getTargetException()); |
296 |
throw (InternalError) new InternalError("VMClass.throwException returned").initCause(e); |
throw (InternalError) new InternalError |
297 |
|
("VMClass.throwException returned").initCause(e); |
298 |
} |
} |
299 |
} |
} |
300 |
|
|