sa-jdi

fy failed:");
      printOn(System.err);
      
      throw new RuntimeException("Verify failed (4) (left black count = " + i + ", right black count = " + j + ")");
    }
    return i + (node.getColor() == RBColor.RED ? 0 : 1);
  }
  
  private void printFromNode(RBNode node, PrintStream tty, int indentDepth)
  {
    for (int i = 0; i < indentDepth; i++) {
      tty.print(" ");
    }
    tty.print("-");
    if (node == null)
    {
      tty.println();
      return;
    }
    tty.println(" " + getNodeValue(node) + (node.getColor() == RBColor.RED ? " (red)" : " (black)"));
    
    printFromNode(node.getLeft(), tty, indentDepth + 2);
    printFromNode(node.getRight(), tty, indentDepth + 2);
  }
  
  public static void main(String[] args)
  {
    int treeSize = 10000;
    int maxVal = treeSize;
    System.err.println("Building tree...");
    RBTree tree = new RBTree(new Comparator()
    {
      public int compare(Object o1, Object o2)
      {
        Integer i1 = (Integer)o1;
        Integer i2 = (Integer)o2;
        if (i1.intValue() < i2.intValue()) {
          return -1;
        }
        if (i1.intValue() == i2.intValue()) {
          return 0;
        }
        return 1;
      }
    });
    Random rand = new Random(System.currentTimeMillis());
    for (int i = 0; i < treeSize; i++)
    {
      Integer val = new Integer(rand.nextInt(maxVal) + 1);
      try
      {
        tree.insertNode(new RBNode(val));
        if ((i > 0) && (i % 100 == 0))
        {
          System.err.print(i + "...");
          System.err.flush();
        }
      }
      catch (Exception e)
      {
        e.printStackTrace();
        System.err.println("While inserting value " + val);
        tree.printOn(System.err);
        System.exit(1);
      }
    }
    System.err.println();
    System.err.println("Churning tree...");
    for (int i = 0; i < treeSize; i++)
    {
      System.err.println("Iteration " + i + ":");
      tree.printOn(System.err);
      
      RBNode xParent = null;
      RBNode x = tree.getRoot();
      int depth = 0;
      while (x != null)
      {
        xParent = x;
        if (rand.nextBoolean()) {
          x = x.getLeft();
        } else {
          x = x.getRight();
        }
        depth++;
      }
      int height = rand.nextInt(depth);
      if (height >= depth) {
        throw new RuntimeException("bug in java.util.Random");
      }
      while (height > 0)
      {
        xParent = xParent.getParent();
        height--;
      }
      System.err.println("(Removing value " + tree.getNodeValue(xParent) + ")");
      
      tree.deleteNode(xParent);
      
      Integer newVal = new Integer(rand.nextInt(maxVal) + 1);
      
      System.err.println("(Inserting value " + newVal + ")");
      
      tree.insertNode(new RBNode(newVal));
    }
    System.err.println("All tests passed.");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.RBTree
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.util.ArrayList;
import java.util.HashMap;
import sun.jvm.hotspot.oops.Oop;

public class ReversePtrs
{
  private HashMap rp;
  
  public ReversePtrs()
  {
    rp = new HashMap();
  }
  
  public void put(LivenessPathElement from, Oop to)
  {
    if (to == null) {
      return;
    }
    ArrayList al = (ArrayList)rp.get(to);
    if (al == null) {
      al = new ArrayList();
    }
    al.add(0, from);
    rp.put(to, al);
  }
  
  public ArrayList get(Oop obj)
  {
    return (ArrayList)rp.get(obj);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ReversePtrs
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.io.PrintStream;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.NamedFieldIdentifier;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.oops.UnknownOopException;

final class ReversePtrsAnalysis$1$1
  extends DefaultOopVisitor
{
  private final ReversePtrsAnalysis.1 this$1;
  
  ReversePtrsAnalysis$1$1(ReversePtrsAnalysis.1 param1, InstanceKlass paramInstanceKlass) {}
  
  public void doOop(OopField field, boolean isVMField)
  {
    Oop next = field.getValue(val$ik);
    LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier("Static field \"" + field.getID().getName() + "\" in class \"" + val$ik.getName().asString() + "\""));
    
    ReversePtrsAnalysis.access$100(ReversePtrsAnalysis.1.access$000(this$1)).put(lp, next);
    try
    {
      ReversePtrsAnalysis.access$200(ReversePtrsAnalysis.1.access$000(this$1), next);
    }
    catch (AddressException e)
    {
      System.err.print("RevPtrs analysis: WARNING: AddressException at 0x" + Long.toHexString(e.getAddress()) + " while traversing static fields of InstanceKlass ");
      
      val$ik.printValueOn(System.err);
      System.err.println();
    }
    catch (UnknownOopException e)
    {
      System.err.println("RevPtrs analysis: WARNING: UnknownOopException while traversing static fields of InstanceKlass ");
      
      val$ik.printValueOn(System.err);
      System.err.println();
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ReversePtrsAnalysis.1.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.io.PrintStream;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.NamedFieldIdentifier;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.oops.UnknownOopException;

final class ReversePtrsAnalysis$1
  extends DefaultHeapVisitor
{
  private final ReversePtrsAnalysis this$0;
  
  ReversePtrsAnalysis$1(ReversePtrsAnalysis paramReversePtrsAnalysis) {}
  
  public boolean doObj(Oop obj)
  {
    if ((obj instanceof InstanceKlass))
    {
      final InstanceKlass ik = (InstanceKlass)obj;
      ik.iterateFields(new DefaultOopVisitor()
      {
        public void doOop(OopField field, boolean isVMField)
        {
          Oop next = field.getValue(ik);
          LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier("Static field \"" + field.getID().getName() + "\" in class \"" + ik.getName().asString() + "\""));
          
          ReversePtrsAnalysis.access$100(this$0).put(lp, next);
          try
          {
            ReversePtrsAnalysis.access$200(this$0, next);
          }
          catch (AddressException e)
          {
            System.err.print("RevPtrs analysis: WARNING: AddressException at 0x" + Long.toHexString(e.getAddress()) + " while traversing static fields of InstanceKlass ");
            
            ik.printValueOn(System.err);
            System.err.println();
          }
          catch (UnknownOopException e)
          {
            System.err.println("RevPtrs analysis: WARNING: UnknownOopException while traversing static fields of InstanceKlass ");
            
            ik.printValueOn(System.err);
            System.err.println();
          }
        }
      }, false);
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ReversePtrsAnalysis.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.util.Stack;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;

final class ReversePtrsAnalysis$2
  extends DefaultOopVisitor
{
  private final ReversePtrsAnalysis this$0;
  
  ReversePtrsAnalysis$2(ReversePtrsAnalysis paramReversePtrsAnalysis, Oop paramOop, Stack paramStack) {}
  
  public void doOop(OopField field, boolean isVMField)
  {
    Oop next = field.getValue(val$currObj);
    ReversePtrsAnalysis.access$100(this$0).put(new LivenessPathElement(val$currObj, field.getID()), next);
    if ((next != null) && (ReversePtrsAnalysis.access$300(this$0).mark(next))) {
      val$workList.push(next);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ReversePtrsAnalysis.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.oops.NamedFieldIdentifier;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.AddressVisitor;

class ReversePtrsAnalysis$RootVisitor
  implements AddressVisitor
{
  private String baseRootDescription;
  private final ReversePtrsAnalysis this$0;
  
  ReversePtrsAnalysis$RootVisitor(ReversePtrsAnalysis paramReversePtrsAnalysis, String baseRootDescription)
  {
    this.baseRootDescription = baseRootDescription;
  }
  
  public void visitAddress(Address addr)
  {
    Oop next = ReversePtrsAnalysis.access$400(this$0).newOop(addr.getOopHandleAt(0L));
    LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier(baseRootDescription + " @ " + addr));
    
    ReversePtrsAnalysis.access$100(this$0).put(lp, next);
    ReversePtrsAnalysis.access$200(this$0, next);
  }
  
  public void visitCompOopAddress(Address addr)
  {
    Oop next = ReversePtrsAnalysis.access$400(this$0).newOop(addr.getCompOopHandleAt(0L));
    LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier(baseRootDescription + " @ " + addr));
    
    ReversePtrsAnalysis.access$100(this$0).put(lp, next);
    ReversePtrsAnalysis.access$200(this$0, next);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ReversePtrsAnalysis.RootVisitor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.EmptyStackException;
import java.util.Stack;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.gc_interface.CollectedHeap;
import sun.jvm.hotspot.memory.Universe;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.NamedFieldIdentifier;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.oops.UnknownOopException;
import sun.jvm.hotspot.runtime.AddressVisitor;
import sun.jvm.hotspot.runtime.Frame;
import sun.jvm.hotspot.runtime.JNIHandleBlock;
import sun.jvm.hotspot.runtime.JNIHandles;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.StackFrameStream;
import sun.jvm.hotspot.runtime.Threads;
import sun.jvm.hotspot.runtime.VM;

public class ReversePtrsAnalysis
{
  private static final boolean DEBUG = false;
  private HeapProgressThunk progressThunk;
  private long usedSize;
  private long visitedSize;
  private double lastNotificationFraction;
  private static final double MINIMUM_NOTIFICATION_FRACTION = 0.01D;
  private ObjectHeap heap;
  private MarkBits markBits;
  private int depth;
  private ReversePtrs rp;
  
  public void setHeapProgressThunk(HeapProgressThunk thunk)
  {
    progressThunk = thunk;
  }
  
  public void run()
  {
    if (VM.getVM().getRevPtrs() != null) {
      return;
    }
    VM vm = VM.getVM();
    rp = new ReversePtrs();
    vm.setRevPtrs(rp);
    Universe universe = vm.getUniverse();
    CollectedHeap collHeap = universe.heap();
    usedSize = collHeap.used();
    visitedSize = 0L;
    if (progressThunk != null) {
      progressThunk.heapIterationFractionUpdate(0.0D);
    }
    markBits = new MarkBits(collHeap);
    
    heap = vm.getObjectHeap();
    for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next())
    {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      thread.printThreadIDOn(new PrintStream(bos));
      String threadDesc = " in thread \"" + thread.getThreadName() + "\" (id " + bos.toString() + ")";
      
      doStack(thread, new RootVisitor("Stack root" + threadDesc));
      
      doJNIHandleBlock(thread.activeHandles(), new RootVisitor("JNI handle root" + threadDesc));
    }
    JNIHandles handles = VM.getVM().getJNIHandles();
    doJNIHandleBlock(handles.globalHandles(), new RootVisitor("Global JNI handle root"));
    
    doJNIHandleBlock(handles.weakGlobalHandles(), new RootVisitor("Weak global JNI handle root"));
    
    heap.iteratePerm(new DefaultHeapVisitor()
    {
      public boolean doObj(Oop obj)
      {
        if ((obj instanceof InstanceKlass))
        {
          final InstanceKlass ik = (InstanceKlass)obj;
          ik.iterateFields(new DefaultOopVisitor()
          {
            public void doOop(OopField field, boolean isVMField)
            {
              Oop next = field.getValue(ik);
              LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier("Static field \"" + field.getID().getName() + "\" in class \"" + ik.getName().asString() + "\""));
              
              rp.put(lp, next);
              try
              {
                ReversePtrsAnalysis.this.markAndTraverse(next);
              }
              catch (AddressException e)
              {
                System.err.print("RevPtrs analysis: WARNING: AddressException at 0x" + Long.toHexString(e.getAddress()) + " while traversing static fields of InstanceKlass ");
                
                ik.printValueOn(System.err);
                System.err.println();
              }
              catch (UnknownOopException e)
              {
                System.err.println("RevPtrs analysis: WARNING: UnknownOopException while traversing static fields of InstanceKlass ");
                
                ik.printValueOn(System.err);
                System.err.println();
              }
            }
          }, false);
        }
        return false;
      }
    });
    if (progressThunk != null) {
      progressThunk.heapIterationComplete();
    }
    markBits = null;
  }
  
  private void markAndTraverse(OopHandle handle)
  {
    try
    {
      markAndTraverse(heap.newOop(handle));
    }
    catch (AddressException e)
    {
      System.err.println("RevPtrs analysis: WARNING: AddressException at 0x" + Long.toHexString(e.getAddress()) + " while traversing oop at " + handle);
    }
    catch (UnknownOopException e)
    {
      System.err.println("RevPtrs analysis: WARNING: UnknownOopException for oop at " + handle);
    }
  }
  
  private void printHeader()
  {
    for (int i = 0; i < depth; i++) {
      System.err.print(" ");
    }
  }
  
  private void markAndTraverse(Oop obj)
  {
    if (obj == null) {
      return;
    }
    if (!markBits.mark(obj)) {
      return;
    }
    final Stack workList = new Stack();
    
    Oop next = obj;
    try
    {
      for (;;)
      {
        final Oop currObj = next;
        if (progressThunk != null)
        {
          visitedSize += currObj.getObjectSize();
          double curFrac = visitedSize / usedSize;
          if (curFrac > lastNotificationFraction + 0.01D)
          {
            progressThunk.heapIterationFractionUpdate(curFrac);
            lastNotificationFraction = curFrac;
          }
        }
        currObj.iterate(new DefaultOopVisitor()
        {
          public void doOop(OopField field, boolean isVMField)
          {
            Oop next = field.getValue(currObj);
            rp.put(new LivenessPathElement(currObj, field.getID()), next);
            if ((next != null) && (markBits.mark(next))) {
              workList.push(next);
            }
          }
        }, false);
        
        next = (Oop)workList.pop();
      }
    }
    catch (EmptyStackException e) {}catch (NullPointerException e)
    {
      System.err.println("ReversePtrs: WARNING: " + e + " during traversal");
    }
    catch (Exception e)
    {
      System.err.println("ReversePtrs: WARNING: " + e + " during traversal");
    }
  }
  
  class RootVisitor
    implements AddressVisitor
  {
    private String baseRootDescription;
    
    RootVisitor(String baseRootDescription)
    {
      this.baseRootDescription = baseRootDescription;
    }
    
    public void visitAddress(Address addr)
    {
      Oop next = heap.newOop(addr.getOopHandleAt(0L));
      LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier(baseRootDescription + " @ " + addr));
      
      rp.put(lp, next);
      ReversePtrsAnalysis.this.markAndTraverse(next);
    }
    
    public void visitCompOopAddress(Address addr)
    {
      Oop next = heap.newOop(addr.getCompOopHandleAt(0L));
      LivenessPathElement lp = new LivenessPathElement(null, new NamedFieldIdentifier(baseRootDescription + " @ " + addr));
      
      rp.put(lp, next);
      ReversePtrsAnalysis.this.markAndTraverse(next);
    }
  }
  
  private void doStack(JavaThread thread, AddressVisitor oopVisitor)
  {
    for (StackFrameStream fst = new StackFrameStream(thread); !fst.isDone(); fst.next()) {
      fst.getCurrent().oopsDo(oopVisitor, fst.getRegisterMap());
    }
  }
  
  private void doJNIHandleBlock(JNIHandleBlock handles, AddressVisitor oopVisitor)
  {
    handles.oopsDo(oopVisitor);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ReversePtrsAnalysis
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

final class RobustOopDeterminator$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    RobustOopDeterminator.access$000(VM.getVM().getTypeDataBase());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.RobustOopDeterminator.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities;

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.memory.Universe;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.OopField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class RobustOopDeterminator
{
  private static OopField klassField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        RobustOopDeterminator.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("oopDesc");
    if (VM.getVM().isCompressedOopsEnabled()) {
      klassField = type.getNarrowOopField("_metadata._compressed_klass");
    } else {
      klassField = type.getOopField("_metadata._klass");
    }
  }
  
  public static boolean oopLooksValid(OopHandle oop)
  {
    if (oop == null) {
      return false;
    }
    if (!VM.getVM().getUniverse().isIn(oop)) {
      return false;
    }
    try
    {
      for (int i = 0; i < 4; i++)
      {
        OopHandle next = klassField.getValue(oop);
        if (next == null) {
          return false;
        }
        if (next.equals(oop)) {
          return true;
        }
        oop = next;
      }
      return false;
    }
    catch (AddressException e) {}
    return false;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.RobustOopDeterminator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import javax.script.ScriptException;

public abstract interface Callable
{
  public abstract Object call(Object[] paramArrayOfObject)
    throws ScriptException;
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.Callable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

public class DefaultScriptObject
  implements ScriptObject
{
  public Object[] getIds()
  {
    return EMPTY_ARRAY;
  }
  
  public Object get(String name)
  {
    return UNDEFINED;
  }
  
  public Object get(int index)
  {
    return UNDEFINED;
  }
  
  public void put(String name, Object value) {}
  
  public void put(int index, Object value) {}
  
  public boolean has(String name)
  {
    return false;
  }
  
  public boolean has(int index)
  {
    return false;
  }
  
  public boolean delete(String name)
  {
    return false;
  }
  
  public boolean delete(int index)
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.DefaultScriptObject
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import javax.script.Invocable;
import javax.script.ScriptException;

public class InvocableCallable
  implements Callable
{
  private Object target;
  private String name;
  private Invocable invocable;
  
  public InvocableCallable(Object target, String name, Invocable invocable)
  {
    this.target = target;
    this.name = name;
    this.invocable = invocable;
  }
  
  public Object call(Object[] args)
    throws ScriptException
  {
    try
    {
      if (target == null) {
        return invocable.invokeFunction(name, args);
      }
      return invocable.invokeMethod(target, name, args);
    }
    catch (NoSuchMethodException nme)
    {
      throw new ScriptException(nme);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.InvocableCallable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import sun.jvm.hotspot.oops.Array;

public abstract class JSJavaArray
  extends JSJavaObject
{
  private JSJavaArrayKlass type;
  
  public JSJavaArray(Array array, JSJavaFactory fac)
  {
    super(array, fac);
    type = ((JSJavaArrayKlass)fac.newJSJavaKlass(array.getKlass()));
  }
  
  public final Array getArray()
  {
    return (Array)getOop();
  }
  
  public final JSJavaClass getJSJavaClass()
  {
    return type.getJSJavaClass();
  }
  
  public Object get(String name)
  {
    if (name.equals("length")) {
      return new Integer((int)getArray().getLength());
    }
    return super.get(name);
  }
  
  public Object get(int index)
  {
    return isInRange(index) ? type.getFieldValue(index, getArray()) : super.get(index);
  }
  
  public Object[] getIds()
  {
    Object[] superFields = super.getIds();
    int len = (int)getArray().getLength();
    Object[] res = new Object[superFields.length + len];
    for (int i = 0; i < len; i++) {
      res[i] = new Integer(i);
    }
    System.arraycopy(superFields, 0, res, len, superFields.length);
    return res;
  }
  
  public boolean has(String name)
  {
    if (name.equals("length")) {
      return true;
    }
    return super.has(name);
  }
  
  public boolean has(int index)
  {
    if (isInRange(index)) {
      return true;
    }
    return super.has(index);
  }
  
  public void put(String name, Object value)
  {
    if (!name.equals("length")) {
      super.put(name, value);
    }
  }
  
  public void put(int index, Object value)
  {
    if (!isInRange(index)) {
      super.put(index, value);
    }
  }
  
  private boolean isInRange(int index)
  {
    return (index >= 0) && (index < getArray().getLength());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.JSJavaArray
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import sun.jvm.hotspot.oops.Array;
import sun.jvm.hotspot.oops.ArrayKlass;

public abstract class JSJavaArrayKlass
  extends JSJavaKlass
{
  public JSJavaArrayKlass(ArrayKlass kls, JSJavaFactory fac)
  {
    super(kls, fac);
  }
  
  public final ArrayKlass getArrayKlass()
  {
    return (ArrayKlass)getKlass();
  }
  
  public Object getMetaClassFieldValue(String name)
  {
    if (name.equals("dimension")) {
      return new Long(getArrayKlass().getDimension());
    }
    return super.getMetaClassFieldValue(name);
  }
  
  public boolean hasMetaClassField(String name)
  {
    if (name.equals("dimension")) {
      return true;
    }
    return super.hasMetaClassField(name);
  }
  
  public boolean isArray()
  {
    return true;
  }
  
  public String[] getMetaClassFieldNames()
  {
    String[] superFields = super.getMetaClassFieldNames();
    String[] res = new String[superFields.length + 1];
    System.arraycopy(superFields, 0, res, 0, superFields.length);
    res[superFields.length] = "dimension";
    return res;
  }
  
  public abstract Object getFieldValue(int paramInt, Array paramArray);
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.JSJavaArrayKlass
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import sun.jvm.hotspot.oops.Instance;
import sun.jvm.hotspot.oops.Oop;

public class JSJavaClass
  extends JSJavaInstance
{
  private JSJavaKlass jklass;
  
  public JSJavaClass(Instance instance, JSJavaKlass jk, JSJavaFactory fac)
  {
    super(instance, fac);
    jklass = jk;
  }
  
  public JSJavaKlass getJSJavaKlass()
  {
    return jklass;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("Class (address=");
    buf.append(getOop().getHandle());
    buf.append(", name=");
    buf.append(jklass.getName());
    buf.append(')');
    return buf.toString();
  }
  
  protected Object getFieldValue(String name)
  {
    return jklass.getMetaClassFieldValue(name);
  }
  
  protected String[] getFieldNames()
  {
    return jklass.getMetaClassFieldNames();
  }
  
  protected boolean hasField(String name)
  {
    return jklass.hasMetaClassField(name);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.JSJavaClass
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.oops.Field;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.JavaVFrame;

public abstract interface JSJavaFactory
{
  public abstract JSJavaObject newJSJavaObject(Oop paramOop);
  
  public abstract JSJavaKlass newJSJavaKlass(Klass paramKlass);
  
  public abstract JSJavaField newJSJavaField(Field paramField);
  
  public abstract JSJavaThread newJSJavaThread(JavaThread paramJavaThread);
  
  public abstract JSJavaFrame newJSJavaFrame(JavaVFrame paramJavaVFrame);
  
  public abstract JSList newJSList(List paramList);
  
  public abstract JSMap newJSMap(Map paramMap);
  
  public abstract JSJavaHeap newJSJavaHeap();
  
  public abstract JSJavaVM newJSJavaVM();
  
  public abstract Object newJSJavaWrapper(Object paramObject);
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.JSJavaFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.memory.SymbolTable;
import sun.jvm.hotspot.oops.Field;
import sun.jvm.hotspot.oops.Instance;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.ObjArray;
import sun.jvm.hotspot.oops.ObjArrayKlass;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopUtilities;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.oops.TypeArray;
import sun.jvm.hotspot.oops.TypeArrayKlass;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.JavaVFrame;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.Assert;

public class JSJavaFactoryImpl
  implements JSJavaFactory
{
  public JSJavaObject newJSJavaObject(Oop oop)
  {
    if (oop == null) {
      return null;
    }
    SoftReference sref = (SoftReference)om.get(oop);
    JSJavaObject res = sref != null ? (JSJavaObject)sref.get() : null;
    if (res == null) {
      if ((oop instanceof TypeArray)) {
        res = new JSJavaTypeArray((TypeArray)oop, this);
      } else if ((oop instanceof ObjArray)) {
        res = new JSJavaObjArray((ObjArray)oop, this);
      } else if ((oop instanceof Instance)) {
        res = newJavaInstance((Instance)oop);
      } else if ((oop instanceof Method)) {
        res = new JSJavaMethod((Method)oop, this);
      }
    }
    if (res != null) {
      om.put(oop, new SoftReference(res));
    }
    return res;
  }
  
  public JSJavaKlass newJSJavaKlass(Klass klass)
  {
    JSJavaKlass res = null;
    if ((klass instanceof InstanceKlass)) {
      res = new JSJavaInstanceKlass((InstanceKlass)klass, this);
    } else if ((klass instanceof ObjArrayKlass)) {
      res = new JSJavaObjArrayKlass((ObjArrayKlass)klass, this);
    } else if ((klass instanceof TypeArrayKlass)) {
      res = new JSJavaTypeArrayKlass((TypeArrayKlass)klass, this);
    }
    if (res != null) {
      om.put(klass, new SoftReference(res));
    }
    return res;
  }
  
  public JSJavaField newJSJavaField(Field field)
  {
    if (field == null) {
      return null;
    }
    return new JSJavaField(field, this);
  }
  
  public JSJavaThread newJSJavaThread(JavaThread jthread)
  {
    if (jthread == null) {
      return null;
    }
    return new JSJavaThread(jthread, this);
  }
  
  public JSJavaFrame newJSJavaFrame(JavaVFrame jvf)
  {
    if (jvf == null) {
      return null;
    }
    return new JSJavaFrame(jvf, this);
  }
  
  public JSList newJSList(List list)
  {
    if (list == null) {
      return null;
    }
    return new JSList(list, this);
  }
  
  public JSMap newJSMap(Map map)
  {
    if (map == null) {
      return null;
    }
    return new JSMap(map, this);
  }
  
  public Object newJSJavaWrapper(Object item)
  {
    if (item == null) {
      return null;
    }
    if ((item instanceof Oop)) {
      return newJSJavaObject((Oop)item);
    }
    if ((item instanceof Field)) {
      return newJSJavaField((Field)item);
    }
    if ((item instanceof JavaThread)) {
      return newJSJavaThread((JavaThread)item);
    }
    if ((item instanceof JavaVFrame)) {
      return newJSJavaFrame((JavaVFrame)item);
    }
    if ((item instanceof List)) {
      return newJSList((List)item);
    }
    if ((item instanceof Map)) {
      return newJSMap((Map)item);
    }
    return item;
  }
  
  public JSJavaHeap newJSJavaHeap()
  {
    return new JSJavaHeap(this);
  }
  
  public JSJavaVM newJSJavaVM()
  {
    return new JSJavaVM(this);
  }
  
  private Symbol javaLangString()
  {
    if (javaLangString == null) {
      javaLangString = getSymbol("java/lang/String");
    }
    return javaLangString;
  }
  
  private Symbol javaLangThread()
  {
    if (javaLangThread == null) {
      javaLangThread = getSymbol("java/lang/Thread");
    }
    return javaLangThread;
  }
  
  private Symbol javaLangClass()
  {
    if (javaLangClass == null) {
      javaLangClass = getSymbol("java/lang/Class");
    }
    return javaLangClass;
  }
  
  private Symbol getSymbol(String str)
  {
    return VM.getVM().getSymbolTable().probe(str);
  }
  
  private JSJavaObject newJavaInstance(Instance instance)
  {
    Symbol className = instance.getKlass().getName();
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(className != null, "Null class name");
    }
    JSJavaObject res = null;
    if (className.equals(javaLangString()))
    {
      res = new JSJavaString(instance, this);
    }
    else if (className.equals(javaLangThread()))
    {
      res = new JSJavaThread(instance, this);
    }
    else if (className.equals(javaLangClass()))
    {
      Klass reflectedType = OopUtilities.classOopToKlass(instance);
      if (reflectedType != null)
      {
        JSJavaKlass jk = newJSJavaKlass(reflectedType);
        if (jk == null) {
          return null;
        }
        res = new JSJavaClass(instance, jk, this);
      }
      else
      {
        return null;
      }
    }
    else
    {
      Klass kls = instance.getKlass().getSuper();
      while (kls != null)
      {
        className = kls.getName();
        if (className.equals(javaLangThread()))
        {
          res = new JSJavaThread(instance, this);
          break;
        }
        kls = kls.getSuper();
      }
    }
    if (res == null) {
      res = new JSJavaInstance(instance, this);
    }
    return res;
  }
  
  private Map om = new HashMap();
  private Symbol javaLangString;
  private Symbol javaLangThread;
  private Symbol javaLangClass;
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.JSJavaFactoryImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import sun.jvm.hotspot.oops.Field;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Symbol;

public class JSJavaField
  extends DefaultScriptObject
{
  private static final int FIELD_NAME = 0;
  private static final int FIELD_SIGNATURE = 1;
  private static final int FIELD_HOLDER = 2;
  private static final int FIELD_IS_PRIVATE = 3;
  private static final int FIELD_IS_PUBLIC = 4;
  private static final int FIELD_IS_PROTECTED = 5;
  private static final int FIELD_IS_PACKAGE_PRIVATE = 6;
  private static final int FIELD_IS_STATIC = 7;
  private static final int FIELD_IS_FINAL = 8;
  private static final int FIELD_IS_VOLATILE = 9;
  private static final int FIELD_IS_TRANSIENT = 10;
  private static final int FIELD_IS_SYNTHETIC = 11;
  private static final int FIELD_UNDEFINED = -1;
  
  public JSJavaField(Field f, JSJavaFactory fac)
  {
    field = f;
    factory = fac;
  }
  
  public Object get(String name)
  {
    int fieldID = getFieldID(name);
    switch (fieldID)
    {
    case 0: 
      return field.getID().getName();
    case 1: 
      return field.getSignature().asString();
    case 2: 
      return getFieldHolder();
    case 3: 
      return Boolean.valueOf(field.isPrivate());
    case 4: 
      return Boolean.valueOf(field.isPublic());
    case 5: 
      return Boolean.valueOf(field.isProtected());
    case 6: 
      return Boolean.valueOf(field.isPackagePrivate());
    case 7: 
      return Boolean.valueOf(field.isStatic());
    case 8: 
      return Boolean.valueOf(field.isFinal());
    case 9: 
      return Boolean.valueOf(field.isVolatile());
    case 10: 
      return Boolean.valueOf(field.isTransient());
    case 11: 
      return Boolean.valueOf(field.isSynthetic());
    }
    return super.get(name);
  }
  
  public Object[] getIds()
  {
    Object[] fieldNames = fields.keySet().toArray();
    Object[] superFields = super.getIds();
    Object[] res = new Object[fieldNames.length + superFields.length];
    System.arraycopy(fieldNames, 0, res, 0, fieldNames.length);
    System.arraycopy(superFields, 0, res, fieldNames.length, superFields.length);
    return res;
  }
  
  public boolean has(String name)
  {
    if (getFieldID(name) != -1) {
      return true;
    }
    return super.has(name);
  }
  
  public void put(String name, Object value)
  {
    if (getFieldID(name) == -1) {
      super.put(name, value);
    }
  }
  
  public boolean equals(Object o)
  {
    if ((o == null) || (!(o instanceof JSJavaField))) {
      return false;
    }
    JSJavaField other = (JSJavaField)o;
    return field.equals(field);
  }
  
  public int hashCode()
  {
    return field.hashCode();
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("Field ");
    buf.append(field.getFieldHolder().getName().asString().replace('/', '.'));
    buf.append('.');
    buf.append(field.getID().getName());
    return buf.toString();
  }
  
  private JSJavaObject getFieldHolder()
  {
    return factory.newJSJavaKlass(field.getFieldHolder()).getJSJavaClass();
  }
  
  private static Map fields = new HashMap();
  private final Field field;
  private final JSJavaFactory factory;
  
  private static void addField(String name, int fieldId)
  {
    fields.put(name, new Integer(fieldId));
  }
  
  private static int getFieldID(String name)
  {
    Integer res = (Integer)fields.get(name);
    return res != null ? res.intValue() : -1;
  }
  
  static
  {
    addField("name", 0);
    addField("signature", 1);
    addField("holder", 2);
    addField("isPrivate", 3);
    addField("isPublic", 4);
    addField("isProtected", 5);
    addField("isPackagePrivate", 6);
    addField("isStatic", 7);
    addField("isFinal", 8);
    addField("isVolatile", 9);
    addField("isTransient", 10);
    addField("isSynthetic", 11);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.soql.JSJavaField
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.utilities.soql;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.ConstantPool;
import sun.jvm.hotspot.oops.LocalVariableTableElement;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.runtime.BasicType;
import sun.jvm.hotspot.runtime.JavaVFrame;
import sun.jvm.hotspot.runtime.StackValueCollection;
import sun.jvm.hotspot.runtime.VM;

public class JSJavaFrame
  extends DefaultScriptObject
{
  private static final int FIELD_METHOD = 0;
  private static final int FIELD_BCI = 1;
  private static final int FIELD_LINE_NUMBER = 2;
  private static final int FIELD_LOCALS = 3;
  private static final int FIELD_THIS_OBJECT = 4;
  private static final int FIELD_THREAD = 5;
  private static final int FIELD_UNDEFINED = -1;
  
  public JSJavaFrame(JavaVFrame jvf, JSJavaFactory fac)
  {
    this.jvf = jvf;
    factory = fac;
  }
  
  public Object get(String name)
  {
    int fieldID = getFieldID(name);
    switch (fieldID)
    {
    case 0: 
      return getMethod();
    case 1: 
      return new Integer(getBCI());
    case 2: 
      return new Integer(getLineNumber());
    case 3: 
      return getLocals();
    case 4: 
      return getThisObject();
    case 5: 
      return getThread();
    }
    return super.get(name);
  }
  
  public Object[] getIds()
  {
    Object[] fieldNames = fields.keySet().toArray();
    Object[] superFields = super.getIds();
    Object[] res = new Object[fieldNames.length + superFields.length];
    System.arraycopy(fieldNames, 0, res, 0, fieldNames.length);
    System.arraycopy(superFields, 0, res, fieldNames.length, superFields.length);
    return res;
  }
  
  public boolean has(String name)
  {
    if (getFieldID(name) != -1) {
      return true;
    }
    return super.has(name);
  }
  
  public void put(String name, Object value)
  {
    if (getFieldID(name) == -1) {
      super.put(name, value);
    }
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("Frame (method=");
    buf.append(jvf.getMethod().externalNameAndSignature());
    buf.append(", bci=");
    buf.append(getBCI());
    buf.append(", line=");
    buf.append(getLineNumber());
    buf.append(')');
    return buf.toString();
  }
  
  private static Map fields = new HashMap();
  private final JavaVFrame jvf;
  private final JSJavaFactory factory;
  private JSMap localsCache;
  
  private static void addField(String n
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd