View Javadoc

1   // Interface.java, created Fri Apr  5 18:36:41 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.ClassLib.sun142_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 jwutil.collections.AppendIterator;
13  
14  /*
15   * @author  John Whaley <jwhaley@alum.mit.edu>
16   * @version $Id: Interface.java 1941 2004-09-30 03:37:06Z joewhaley $
17   */
18  public class Interface extends joeq.ClassLib.sun14_win32.Interface {
19  
20      /*** Creates new Interface */
21      public Interface() {}
22  
23      public Iterator getImplementationClassDescs(joeq.UTF.Utf8 desc) {
24          if (ClassLibInterface.USE_JOEQ_CLASSLIB && desc.toString().startsWith("Ljava/")) {
25              joeq.UTF.Utf8 u = joeq.UTF.Utf8.get("Ljoeq/ClassLib/sun142_win32/"+desc.toString().substring(1));
26              return new AppendIterator(super.getImplementationClassDescs(desc),
27                                        Collections.singleton(u).iterator());
28          }
29          return super.getImplementationClassDescs(desc);
30      }
31      
32      public ObjectTraverser getObjectTraverser() {
33          return sun142_win32ObjectTraverser.INSTANCE;
34      }
35      
36      public static class sun142_win32ObjectTraverser extends sun14_win32ObjectTraverser {
37          public static sun142_win32ObjectTraverser INSTANCE = new sun142_win32ObjectTraverser();
38          protected sun142_win32ObjectTraverser() {}
39          public void initialize() {
40              super.initialize();
41              
42              jq_Class k;
43              try {
44                  k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/ClassLib/Common/java/util/zip/DeflaterHuffman;");
45                  k.load();
46              } catch (NoClassDefFoundError _) {
47                  System.err.println("Error preloading DeflaterHuffman class");
48              }
49              
50              // used during bootstrapping.
51              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/ObjectInputStream$GetFieldImpl;");
52              k.load();
53              
54              // jdk1.4.2_05 caches name string.
55              k = (jq_Class) PrimordialClassLoader.getJavaLangClass();
56              nullInstanceFields.add(k.getOrCreateInstanceField("name", "Ljava/lang/String;"));
57              
58              // 1.4.2 adds caches to Win32FileSystem, which we should not reflectively inspect.
59              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/Win32FileSystem;");
60              nullInstanceFields.add(k.getOrCreateInstanceField("cache", "Ljava/io/ExpiringCache;"));
61              nullInstanceFields.add(k.getOrCreateInstanceField("prefixCache", "Ljava/io/ExpiringCache;"));
62              
63              // reference these now, so that they are not added during bootimage write.
64              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/ExpiringCache;");
65              k.load();
66              k = (jq_Class) PrimordialClassLoader.loader.getOrCreateBSType("Ljava/io/ExpiringCache$Entry;");
67          }
68      }
69  }