View Javadoc

1   // Interface.java, created Wed Feb  4 12:10:06 PST 2004
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.pa;
5   
6   import java.util.Iterator;
7   import joeq.Class.jq_InstanceField;
8   import joeq.Class.jq_StaticField;
9   import joeq.ClassLib.ClassLibInterface;
10  import joeq.Runtime.ObjectTraverser;
11  import jwutil.util.Assert;
12  
13  /*
14   * Classes we replace for pointer analysis purposes ('pa')
15   * If we can model the effect of a native method from the java.* hierarchy
16   * in Java code, we can add an implementation whose bytecode is then
17   * analyzed.
18   *
19   * @author  Godmar Back <gback@stanford.edu>
20   * @version $Id: Interface.java 1941 2004-09-30 03:37:06Z joewhaley $
21   */
22  public final class Interface extends joeq.ClassLib.Common.InterfaceImpl {
23  
24      /*** Creates new Interface */
25      public Interface() {}
26  
27      public Iterator getImplementationClassDescs(joeq.UTF.Utf8 desc) {
28          if (ClassLibInterface.USE_JOEQ_CLASSLIB && desc.toString().startsWith("Ljava/")) {
29              joeq.UTF.Utf8 u = joeq.UTF.Utf8.get("Ljoeq/ClassLib/pa/"+desc.toString().substring(1));
30              return java.util.Collections.singleton(u).iterator();
31          }
32          return java.util.Collections.EMPTY_SET.iterator();
33      }
34  
35      public ObjectTraverser getObjectTraverser() {
36          return new ObjectTraverser() {
37              public void initialize() { }
38              public Object mapStaticField(jq_StaticField f) { Assert.UNREACHABLE(); return null; }
39              public Object mapInstanceField(Object o, jq_InstanceField f) { Assert.UNREACHABLE(); return null; }
40              public Object mapValue(Object o) { Assert.UNREACHABLE(); return null; }
41          };
42      }
43  }