39 |
|
|
40 |
package java.io; |
package java.io; |
41 |
|
|
42 |
import gnu.classpath.Configuration; |
import gnu.classpath.VMStackWalker; |
|
import gnu.java.io.ObjectIdentityWrapper; |
|
|
|
|
|
import java.lang.reflect.Array; |
|
43 |
import java.lang.reflect.Constructor; |
import java.lang.reflect.Constructor; |
|
import java.lang.reflect.Field; |
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
import java.lang.reflect.Method; |
|
|
import java.lang.reflect.Modifier; |
|
|
import java.lang.reflect.Proxy; |
|
44 |
import java.security.AccessController; |
import java.security.AccessController; |
45 |
import java.security.PrivilegedAction; |
import java.security.PrivilegedAction; |
|
import java.util.Arrays; |
|
|
import java.util.Hashtable; |
|
|
import java.util.Vector; |
|
46 |
|
|
47 |
final class VMObjectInputStream |
final class VMObjectInputStream |
48 |
{ |
{ |
49 |
static native ClassLoader currentClassLoader(SecurityManager sm); |
private static Class oisClass = ObjectInputStream.class; |
50 |
|
private static Class vmoisClass = VMObjectInputStream.class; |
51 |
|
|
52 |
static native Object allocateObject(Class clazz, Class constr_clazz, Constructor constructor) |
// PrivilegedAction needed for Class.getClassLoader() |
53 |
|
private static PrivilegedAction loaderAction = new PrivilegedAction() |
54 |
|
{ |
55 |
|
public Object run() |
56 |
|
{ |
57 |
|
Class[] ctx = VMStackWalker.getClassContext(); |
58 |
|
for (int i = 0; i < ctx.length; i++) |
59 |
|
{ |
60 |
|
ClassLoader cl = ctx[i].getClassLoader(); |
61 |
|
if (cl != null) |
62 |
|
return cl; |
63 |
|
} |
64 |
|
return null; |
65 |
|
} |
66 |
|
}; |
67 |
|
|
68 |
|
/** |
69 |
|
* Returns the first user defined class loader on the call stack, or |
70 |
|
* null when no non-null class loader was found. |
71 |
|
*/ |
72 |
|
static ClassLoader currentClassLoader() |
73 |
|
{ |
74 |
|
return (ClassLoader) AccessController.doPrivileged(loaderAction); |
75 |
|
} |
76 |
|
|
77 |
|
/** |
78 |
|
* Allocates a new Object of type clazz but without running the |
79 |
|
* default constructor on it. It then calls the given constructor on |
80 |
|
* it. The given constructor method comes from the constr_clazz |
81 |
|
* which is a super class of the given clazz. |
82 |
|
*/ |
83 |
|
static native Object allocateObject(Class clazz, Class constr_clazz, |
84 |
|
Constructor constructor) |
85 |
throws InstantiationException; |
throws InstantiationException; |
86 |
} |
} |
|
|
|