1
2
3
4 package joeq.ClassLib.sun14_linux;
5
6 import java.util.Collections;
7 import java.util.Iterator;
8 import joeq.Class.PrimordialClassLoader;
9 import joeq.Class.jq_Class;
10 import joeq.ClassLib.ClassLibInterface;
11 import joeq.Runtime.ObjectTraverser;
12 import joeq.Scheduler.jq_NativeThread;
13 import jwutil.collections.AppendIterator;
14
15 /***
16 * Interface
17 *
18 * @author John Whaley <jwhaley@alum.mit.edu>
19 * @version $Id: Interface.java 1941 2004-09-30 03:37:06Z joewhaley $
20 */
21 public class Interface extends joeq.ClassLib.Common.InterfaceImpl {
22
23 /*** Creates new Interface */
24 public Interface() {}
25
26 public Iterator getImplementationClassDescs(joeq.UTF.Utf8 desc) {
27 if (ClassLibInterface.USE_JOEQ_CLASSLIB && desc.toString().startsWith("Ljava/")) {
28 joeq.UTF.Utf8 u = joeq.UTF.Utf8.get("Ljoeq/ClassLib/sun14_linux/"+desc.toString().substring(1));
29 return new AppendIterator(super.getImplementationClassDescs(desc),
30 Collections.singleton(u).iterator());
31 }
32 return super.getImplementationClassDescs(desc);
33 }
34
35 public ObjectTraverser getObjectTraverser() {
36 return sun14_linuxObjectTraverser.INSTANCE;
37 }
38
39 public static class sun14_linuxObjectTraverser extends CommonObjectTraverser {
40 public static sun14_linuxObjectTraverser INSTANCE = new sun14_linuxObjectTraverser();
41 protected sun14_linuxObjectTraverser() {}
42 public void initialize() {
43 super.initialize();
44
45 jq_Class k = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Lsun/misc/Unsafe;");
46 nullStaticFields.add(k.getOrCreateStaticField("theUnsafe", "Lsun/misc/Unsafe;"));
47 k = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Lsun/reflect/UnsafeFieldAccessorImpl;");
48 nullStaticFields.add(k.getOrCreateStaticField("unsafe", "Lsun/misc/Unsafe;"));
49 k = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/nio/charset/Charset;");
50 nullStaticFields.add(k.getOrCreateStaticField("cache", "[Ljava/lang/Object;"));
51
52 k = PrimordialClassLoader.getJavaLangClass();
53 nullInstanceFields.add(k.getOrCreateInstanceField("declaredFields", "Ljava/lang/ref/SoftReference;"));
54 nullInstanceFields.add(k.getOrCreateInstanceField("publicFields", "Ljava/lang/ref/SoftReference;"));
55 nullInstanceFields.add(k.getOrCreateInstanceField("declaredMethods", "Ljava/lang/ref/SoftReference;"));
56 nullInstanceFields.add(k.getOrCreateInstanceField("publicMethods", "Ljava/lang/ref/SoftReference;"));
57 nullInstanceFields.add(k.getOrCreateInstanceField("declaredConstructors", "Ljava/lang/ref/SoftReference;"));
58 nullInstanceFields.add(k.getOrCreateInstanceField("publicConstructors", "Ljava/lang/ref/SoftReference;"));
59 nullInstanceFields.add(k.getOrCreateInstanceField("declaredPublicFields", "Ljava/lang/ref/SoftReference;"));
60 nullInstanceFields.add(k.getOrCreateInstanceField("declaredPublicMethods", "Ljava/lang/ref/SoftReference;"));
61 k = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/lang/reflect/Field;");
62 nullInstanceFields.add(k.getOrCreateInstanceField("fieldAccessor", "Lsun/reflect/FieldAccessor;"));
63 k = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/lang/reflect/Method;");
64 nullInstanceFields.add(k.getOrCreateInstanceField("methodAccessor", "Lsun/reflect/MethodAccessor;"));
65 k = (joeq.Class.jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/lang/reflect/Constructor;");
66 nullInstanceFields.add(k.getOrCreateInstanceField("constructorAccessor", "Lsun/reflect/ConstructorAccessor;"));
67
68 if (IGNORE_THREAD_LOCALS) {
69
70
71 k = (joeq.Class.jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljava/lang/Thread;");
72 nullInstanceFields.add(k.getOrCreateInstanceField("threadLocals", "Ljava/lang/ThreadLocal$ThreadLocalMap;"));
73 nullInstanceFields.add(k.getOrCreateInstanceField("inheritableThreadLocals", "Ljava/lang/ThreadLocal$ThreadLocalMap;"));
74 }
75
76 jq_NativeThread.USE_INTERRUPTER_THREAD = false;
77
78
79
80 }
81
82 public java.lang.Object mapInstanceField(java.lang.Object o, joeq.Class.jq_InstanceField f) {
83 jq_Class c = f.getDeclaringClass();
84 if (c == PrimordialClassLoader.loader.getBSType("Lsun/nio/cs/AbstractCharsetProvider;")) {
85 String fieldName = f.getName().toString();
86 if (fieldName.equals("cache")) {
87 Object o2 = mappedObjects.get(o);
88 if (o2 != null)
89 return o2;
90 o2 = new java.util.TreeMap(java.lang.String.CASE_INSENSITIVE_ORDER);
91 mappedObjects.put(o, o2);
92 return o2;
93 }
94 }
95 return super.mapInstanceField(o, f);
96 }
97 }
98
99 }