1
2
3
4 package joeq.ClassLib.sun13_win32;
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.Runtime.SystemInterface;
13 import joeq.Scheduler.jq_NativeThread;
14 import joeq.UTF.Utf8;
15 import jwutil.collections.AppendIterator;
16
17 /***
18 * Interface
19 *
20 * @author John Whaley <jwhaley@alum.mit.edu>
21 * @version $Id: Interface.java 1941 2004-09-30 03:37:06Z joewhaley $
22 */
23 public final class Interface extends joeq.ClassLib.Common.InterfaceImpl {
24
25 /*** Creates new Interface */
26 public Interface() {}
27
28 public Iterator getImplementationClassDescs(joeq.UTF.Utf8 desc) {
29 if (ClassLibInterface.USE_JOEQ_CLASSLIB && desc.toString().startsWith("Ljava/")) {
30 joeq.UTF.Utf8 u = joeq.UTF.Utf8.get("Ljoeq/ClassLib/sun13_win32/"+desc.toString().substring(1));
31 return new AppendIterator(super.getImplementationClassDescs(desc),
32 Collections.singleton(u).iterator());
33 }
34 return super.getImplementationClassDescs(desc);
35 }
36
37 public ObjectTraverser getObjectTraverser() {
38 return sun13_win32ObjectTraverser.INSTANCE;
39 }
40
41 public static class sun13_win32ObjectTraverser extends CommonObjectTraverser {
42 public static sun13_win32ObjectTraverser INSTANCE = new sun13_win32ObjectTraverser();
43 protected sun13_win32ObjectTraverser() {}
44 public void initialize() {
45 super.initialize();
46 jq_NativeThread.USE_INTERRUPTER_THREAD = true;
47 }
48 public java.lang.Object mapInstanceField(java.lang.Object o, joeq.Class.jq_InstanceField f) {
49 if (IGNORE_THREAD_LOCALS) {
50 jq_Class c = f.getDeclaringClass();
51 if (c == PrimordialClassLoader.getJavaLangThread()) {
52 String fieldName = f.getName().toString();
53 if (fieldName.equals("threadLocals") || fieldName.equals("inheritableThreadLocals")) {
54
55
56
57 if (f.getType().getDesc() == Utf8.get("Ljava/util/Map;")) {
58 return java.util.Collections.EMPTY_MAP;
59 } else if (f.getType().getDesc() == Utf8.get("Ljava/lang/ThreadLocal$ThreadLocalMap;")) {
60 return null;
61 } else {
62 SystemInterface.debugwriteln("Unknown type for field "+f);
63 return null;
64 }
65 }
66 }
67 }
68 return super.mapInstanceField(o, f);
69 }
70 }
71
72 }