sa-jdi

terval, retList);
    return retList;
  }
  
  public void print()
  {
    printOn(System.out);
  }
  
  public void printOn(PrintStream tty)
  {
    printFromNode(getRoot(), tty, 0);
  }
  
  protected Object getNodeValue(RBNode node)
  {
    return ((IntervalNode)node).getInterval();
  }
  
  protected void verify()
  {
    super.verify();
    verifyFromNode(getRoot());
  }
  
  private void verifyFromNode(RBNode node)
  {
    if (node == null) {
      return;
    }
    IntervalNode intNode = (IntervalNode)node;
    if (!intNode.getMaxEndpoint().equals(intNode.computeMaxEndpoint()))
    {
      print();
      
      throw new RuntimeException("Node's max endpoint was not updated properly");
    }
    if (!intNode.getMinEndpoint().equals(intNode.computeMinEndpoint()))
    {
      print();
      
      throw new RuntimeException("Node's min endpoint was not updated properly");
    }
    verifyFromNode(node.getLeft());
    verifyFromNode(node.getRight());
  }
  
  static class IntervalComparator
    implements Comparator
  {
    private Comparator endpointComparator;
    
    public IntervalComparator(Comparator endpointComparator)
    {
      this.endpointComparator = endpointComparator;
    }
    
    public int compare(Object o1, Object o2)
    {
      Interval i1 = (Interval)o1;
      Interval i2 = (Interval)o2;
      return endpointComparator.compare(i1.getLowEndpoint(), i2.getLowEndpoint());
    }
  }
  
  private void searchForIntersectingNodesFrom(IntervalNode node, Interval interval, List resultList)
  {
    if (node == null) {
      return;
    }
    IntervalNode left = (IntervalNode)node.getLeft();
    if ((left != null) && (endpointComparator.compare(left.getMaxEndpoint(), interval.getLowEndpoint()) > 0)) {
      searchForIntersectingNodesFrom(left, interval, resultList);
    }
    if (node.getInterval().overlaps(interval, endpointComparator)) {
      resultList.add(node);
    }
    IntervalNode right = (IntervalNode)node.getRight();
    if ((right != null) && (endpointComparator.compare(interval.getHighEndpoint(), right.getMinEndpoint()) > 0)) {
      searchForIntersectingNodesFrom(right, interval, resultList);
    }
  }
  
  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(" " + node + " (min " + ((IntervalNode)node).getMinEndpoint() + ", max " + ((IntervalNode)node).getMaxEndpoint() + ")" + (node.getColor() == RBColor.RED ? " (red)" : " (black)"));
    if (node.getLeft() != null) {
      printFromNode(node.getLeft(), tty, indentDepth + 2);
    }
    if (node.getRight() != null) {
      printFromNode(node.getRight(), tty, indentDepth + 2);
    }
  }
}

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

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.VM;

public class LivenessAnalysis
{
  private static final boolean DEBUG = false;
  
  public static LivenessPathList computeAllLivenessPaths(Oop target)
  {
    LivenessPathList list = computeAllLivenessPaths(target, true);
    if ((list == null) || (list.size() == 0)) {
      return null;
    }
    return list;
  }
  
  private static LivenessPathList computeAllLivenessPaths(Oop target, boolean trimPathsThroughPopularObjects)
  {
    ReversePtrs rev = VM.getVM().getRevPtrs();
    if (rev == null) {
      throw new RuntimeException("LivenessAnalysis requires ReversePtrs to have been computed");
    }
    if (rev.get(target) == null) {
      return null;
    }
    Set visitedOops = new HashSet();
    
    Map visitedRoots = new IdentityHashMap();
    
    visitedOops.add(target);
    
    LivenessPathList list = new LivenessPathList();
    
    LivenessPath path = new LivenessPath();
    path.push(new LivenessPathElement(target, null));
    list.add(path);
    for (;;)
    {
      LivenessPath path = null;
      for (int i = list.size() - 1; i >= 0; i--)
      {
        LivenessPath tmp = list.get(i);
        if (!tmp.isComplete())
        {
          path = tmp;
          break;
        }
      }
      if (path == null) {
        return list;
      }
      list.remove(path);
      try
      {
        ArrayList nextPtrs = rev.get(path.peek().getObj());
        if (nextPtrs != null) {
          for (Iterator iter = nextPtrs.iterator(); iter.hasNext(); goto 406)
          {
            LivenessPathElement nextElement = (LivenessPathElement)iter.next();
            if (((nextElement.isRoot()) && (visitedRoots.get(nextElement) == null)) || ((!nextElement.isRoot()) && (!visitedOops.contains(nextElement.getObj()))))
            {
              if (nextElement.isRoot()) {
                visitedRoots.put(nextElement, nextElement);
              } else {
                visitedOops.add(nextElement.getObj());
              }
              LivenessPath nextPath = path.copy();
              nextPath.push(nextElement);
              
              list.add(path);
              list.add(nextPath);
              if ((!trimPathsThroughPopularObjects) || (!nextElement.isRoot())) {
                break;
              }
              for (int i = 1; i < nextPath.size() - 1; i++)
              {
                LivenessPathElement el = nextPath.get(i);
                int j = 0;
                while (j < list.size())
                {
                  LivenessPath curPath = list.get(j);
                  if (curPath.peek() == el) {
                    list.remove(curPath);
                  } else {
                    j++;
                  }
                }
              }
            }
          }
        }
      }
      catch (Exception e)
      {
        System.err.println("LivenessAnalysis: WARNING: " + e + " during traversal");
      }
    }
  }
}

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

import java.io.PrintStream;
import java.util.Stack;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.Oop;

public class LivenessPath
{
  private Stack stack;
  
  LivenessPath()
  {
    stack = new Stack();
  }
  
  public int size()
  {
    return stack.size();
  }
  
  public LivenessPathElement get(int index)
    throws ArrayIndexOutOfBoundsException
  {
    return (LivenessPathElement)stack.get(index);
  }
  
  public void printOn(PrintStream tty)
  {
    for (int j = 0; j < size(); j++)
    {
      LivenessPathElement el = get(j);
      tty.print("  - ");
      if (el.getObj() != null) {
        Oop.printOopValueOn(el.getObj(), tty);
      }
      if (el.getField() != null)
      {
        if (el.getObj() != null) {
          tty.print(", field ");
        }
        tty.print(el.getField().getName());
      }
      tty.println();
    }
  }
  
  boolean isComplete()
  {
    if (size() == 0) {
      return false;
    }
    return peek().isRoot();
  }
  
  LivenessPathElement peek()
  {
    return (LivenessPathElement)stack.peek();
  }
  
  void push(LivenessPathElement el)
  {
    stack.push(el);
  }
  
  void pop()
  {
    stack.pop();
  }
  
  LivenessPath copy()
  {
    LivenessPath dup = new LivenessPath();
    for (int i = 0; i < stack.size(); i++) {
      stack.push(stack.get(i));
    }
    return dup;
  }
}

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

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

public class LivenessPathElement
{
  private Oop obj;
  private FieldIdentifier id;
  
  LivenessPathElement(Oop obj, FieldIdentifier id)
  {
    this.obj = obj;
    this.id = id;
  }
  
  public boolean isRoot()
  {
    return obj == null;
  }
  
  public boolean isTerminal()
  {
    return id == null;
  }
  
  public Oop getObj()
  {
    return obj;
  }
  
  public FieldIdentifier getField()
  {
    return id;
  }
}

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

import java.util.ArrayList;

public class LivenessPathList
{
  private ArrayList list;
  
  public LivenessPathList()
  {
    list = new ArrayList();
  }
  
  public int size()
  {
    return list.size();
  }
  
  public LivenessPath get(int i)
  {
    return (LivenessPath)list.get(i);
  }
  
  void add(LivenessPath path)
  {
    list.add(path);
  }
  
  void remove(LivenessPath path)
  {
    list.remove(path);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.LivenessPathList
 * 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.Address;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.gc_interface.CollectedHeap;
import sun.jvm.hotspot.memory.MemRegion;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.VM;

public class MarkBits
{
  private BitMap bits;
  private Address start;
  private Address end;
  
  public MarkBits(CollectedHeap heap)
  {
    MemRegion reserved = heap.reservedRegion();
    
    start = reserved.start();
    end = reserved.end();
    long numOopHandles = end.minus(start) / VM.getVM().getOopSize();
    
    bits = new BitMap((int)numOopHandles);
  }
  
  public void clear()
  {
    bits.clear();
  }
  
  public boolean mark(Oop obj)
  {
    if (obj == null)
    {
      System.err.println("MarkBits: WARNING: null object, ignoring");
      return false;
    }
    OopHandle handle = obj.getHandle();
    
    long idx = handle.minus(start) / VM.getVM().getOopSize();
    if ((idx < 0L) || (idx >= bits.size()))
    {
      System.err.println("MarkBits: WARNING: object " + handle + " outside of heap, ignoring");
      return false;
    }
    int intIdx = (int)idx;
    if (bits.at(intIdx)) {
      return false;
    }
    bits.atPut(intIdx, true);
    return true;
  }
  
  public void clear(Oop obj)
  {
    OopHandle handle = obj.getHandle();
    
    long idx = handle.minus(start) / VM.getVM().getOopSize();
    if ((idx < 0L) || (idx >= bits.size()))
    {
      System.err.println("MarkBits: WARNING: object " + handle + " outside of heap, ignoring");
      return;
    }
    int intIdx = (int)idx;
    bits.atPut(intIdx, false);
  }
}

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

public abstract class MemoizedBoolean
{
  private boolean computed;
  private boolean value;
  
  protected abstract boolean computeValue();
  
  public boolean getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedByte
{
  private boolean computed;
  private byte value;
  
  protected abstract byte computeValue();
  
  public byte getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedChar
{
  private boolean computed;
  private char value;
  
  protected abstract char computeValue();
  
  public char getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedDouble
{
  private boolean computed;
  private double value;
  
  protected abstract double computeValue();
  
  public double getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedFloat
{
  private boolean computed;
  private float value;
  
  protected abstract float computeValue();
  
  public float getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedInt
{
  private boolean computed;
  private int value;
  
  protected abstract int computeValue();
  
  public int getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedLong
{
  private boolean computed;
  private long value;
  
  protected abstract long computeValue();
  
  public long getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedObject
{
  private boolean computed;
  private Object value;
  
  protected abstract Object computeValue();
  
  public Object getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract class MemoizedShort
{
  private boolean computed;
  private short value;
  
  protected abstract short computeValue();
  
  public short getValue()
  {
    if (!computed)
    {
      value = computeValue();
      computed = true;
    }
    return value;
  }
}

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

public abstract interface MessageQueue
{
  public abstract Object readMessage();
  
  public abstract Object readMessageWithTimeout(long paramLong);
  
  public abstract void writeMessage(Object paramObject);
}

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

import java.util.LinkedList;

class MessageQueueBackend$MessageQueueImpl
  implements MessageQueue
{
  private LinkedList readList;
  private LinkedList writeList;
  private final MessageQueueBackend this$0;
  
  public MessageQueueBackend$MessageQueueImpl(MessageQueueBackend paramMessageQueueBackend, LinkedList listToReadFrom, LinkedList listToWriteTo)
  {
    readList = listToReadFrom;
    writeList = listToWriteTo;
  }
  
  public Object readMessage()
  {
    synchronized (readList)
    {
      while (readList.isEmpty()) {
        try
        {
          readList.wait();
        }
        catch (InterruptedException e) {}
      }
      return readList.removeFirst();
    }
  }
  
  public Object readMessageWithTimeout(long millis)
  {
    synchronized (readList)
    {
      if (readList.isEmpty())
      {
        if (millis == 0L) {
          return null;
        }
        try
        {
          readList.wait(millis);
        }
        catch (InterruptedException e) {}
      }
      if (readList.isEmpty()) {
        return null;
      }
      return readList.removeFirst();
    }
  }
  
  public void writeMessage(Object obj)
  {
    synchronized (writeList)
    {
      writeList.addLast(obj);
      writeList.notify();
    }
  }
}

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

import java.util.LinkedList;

public class MessageQueueBackend
{
  private MessageQueueImpl leftRightQueue;
  private MessageQueueImpl rightLeftQueue;
  
  public MessageQueueBackend()
  {
    LinkedList leftRightPipe = new LinkedList();
    LinkedList rightLeftPipe = new LinkedList();
    leftRightQueue = new MessageQueueImpl(rightLeftPipe, leftRightPipe);
    rightLeftQueue = new MessageQueueImpl(leftRightPipe, rightLeftPipe);
  }
  
  public MessageQueue getFirstQueue()
  {
    return leftRightQueue;
  }
  
  public MessageQueue getSecondQueue()
  {
    return rightLeftQueue;
  }
  
  private class MessageQueueImpl
    implements MessageQueue
  {
    private LinkedList readList;
    private LinkedList writeList;
    
    public MessageQueueImpl(LinkedList listToReadFrom, LinkedList listToWriteTo)
    {
      readList = listToReadFrom;
      writeList = listToWriteTo;
    }
    
    public Object readMessage()
    {
      synchronized (readList)
      {
        while (readList.isEmpty()) {
          try
          {
            readList.wait();
          }
          catch (InterruptedException e) {}
        }
        return readList.removeFirst();
      }
    }
    
    public Object readMessageWithTimeout(long millis)
    {
      synchronized (readList)
      {
        if (readList.isEmpty())
        {
          if (millis == 0L) {
            return null;
          }
          try
          {
            readList.wait(millis);
          }
          catch (InterruptedException e) {}
        }
        if (readList.isEmpty()) {
          return null;
        }
        return readList.removeFirst();
      }
    }
    
    public void writeMessage(Object obj)
    {
      synchronized (writeList)
      {
        writeList.addLast(obj);
        writeList.notify();
      }
    }
  }
}

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

import sun.jvm.hotspot.oops.BooleanField;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$1
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$1(ObjectReader paramObjectReader, boolean[] paramArrayOfBoolean, TypeArray paramTypeArray) {}
  
  public void doBoolean(BooleanField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.CharField;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$2
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$2(ObjectReader paramObjectReader, char[] paramArrayOfChar, TypeArray paramTypeArray) {}
  
  public void doChar(CharField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FloatField;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$3
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$3(ObjectReader paramObjectReader, float[] paramArrayOfFloat, TypeArray paramTypeArray) {}
  
  public void doFloat(FloatField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.DoubleField;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$4
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$4(ObjectReader paramObjectReader, double[] paramArrayOfDouble, TypeArray paramTypeArray) {}
  
  public void doDouble(DoubleField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.ByteField;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$5
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$5(ObjectReader paramObjectReader, byte[] paramArrayOfByte, TypeArray paramTypeArray) {}
  
  public void doByte(ByteField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.ShortField;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$6
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$6(ObjectReader paramObjectReader, short[] paramArrayOfShort, TypeArray paramTypeArray) {}
  
  public void doShort(ShortField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.IntField;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$7
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$7(ObjectReader paramObjectReader, int[] paramArrayOfInt, TypeArray paramTypeArray) {}
  
  public void doInt(IntField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

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

import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.LongField;
import sun.jvm.hotspot.oops.TypeArray;

final class ObjectReader$8
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$8(ObjectReader paramObjectReader, long[] paramArrayOfLong, TypeArray paramTypeArray) {}
  
  public void doLong(LongField field, boolean isVMField)
  {
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    val$arrayObj[ifd.getIndex()] = field.getValue(val$array);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.ObjectReader.8
 * 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.OopHandle;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.OopField;

final class ObjectReader$9
  extends DefaultOopVisitor
{
  private final ObjectReader this$0;
  
  ObjectReader$9(ObjectReader paramObjectReader, Object[] paramArrayOfObject) {}
  
  public void doOop(OopField field, boolean isVMField)
  {
    OopHandle handle = field.getValueAsOopHandle(getObj());
    if (!this$0.isRobust(handle)) {
      return;
    }
    IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
    try
    {
      val$arrayObj[ifd.getIndex()] = this$0.readObject(field.getValue(getObj()));
    }
    catch (Exception e)
    {
      if (ObjectReader.access$000())
      {
        System.err.println("Array element set failed for " + ifd);
        e.printStackTrace();
      }
    }
  }
}

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

import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.BooleanField;
import sun.jvm.hotspot.oops.ByteField;
import sun.jvm.hotspot.oops.CIntField;
import sun.jvm.hotspot.oops.CharField;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.DoubleField;
import sun.jvm.hotspot.oops.FloatField;
import sun.jvm.hotspot.oops.IntField;
import sun.jvm.hotspot.oops.LongField;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.oops.ShortField;

public class ObjectReader$FieldSetter
  extends DefaultOopVisitor
{
  protected Object obj;
  private final ObjectReader this$0;
  
  public ObjectReader$FieldSetter(ObjectReader paramObjectReader, Object obj)
  {
    this.obj = obj;
  }
  
  private void printFieldSetError(Field f, Exception ex)
  {
    if (ObjectReader.access$000())
    {
      if (f != null) {
        System.err.println("Field set failed for " + f);
      }
      ex.printStackTrace();
    }
  }
  
  public void doOop(OopField field, boolean isVMField)
  {
    OopHandle handle = field.getValueAsOopHandle(getObj());
    if (!this$0.isRobust(handle)) {
      return;
    }
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.set(obj, this$0.readObject(field.getValue(getObj())));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doByte(ByteField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setByte(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doChar(CharField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setChar(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doBoolean(BooleanField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setBoolean(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doShort(ShortField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setShort(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doInt(IntField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setInt(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doLong(LongField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setLong(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doFloat(FloatField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setFloat(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doDouble(DoubleField field, boolean isVMField)
  {
    Field f = null;
    try
    {
      f = this$0.readField(field);
      if (Modifier.isFinal(f.getModifiers())) {
        return;
      }
      f.setAccessible(true);
      f.setDouble(obj, field.getValue(getObj()));
    }
    catch (Exception ex)
    {
      printFieldSetError(f, ex);
    }
  }
  
  public void doCInt(CIntField field, boolean isVMField)
  {
    throw new RuntimeException("should not reach here!");
  }
}

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

import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.Enumeration;
import java.util.Vector;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.runtime.SignatureIterator;

public class ObjectReader$SignatureParser
  extends SignatureIterator
{
  protected Vector tmp = new Vector();
  private final ObjectReader this$0;
  
  public ObjectReader$SignatureParser(ObjectReader paramObjectReader, Symbol s)
  {
    super(s);
  }
  
  public void doBool()
  {
    tmp.add(Boolean.TYPE);
  }
  
  public void doChar()
  {
    tmp.add(Character.TYPE);
  }
  
  public void doFloat()
  {
    tmp.add(Float.TYPE);
  }
  
  public void doDouble()
  {
    tmp.add(Double.TYPE);
  }
  
  public void doByte()
  {
    tmp.add(Byte.TYPE);
  }
  
  public void doShort()
  {
    tmp.add(Short.TYPE);
  }
  
  public void doInt()
  {
    tmp.add(Integer.TYPE);
  }
  
  public void doLong()
  {
    tmp.add(Long.TYPE);
  }
  
  public void doVoid()
  {
    if (isReturnType()) {
      tmp.add(Void.TYPE);
    } else {
      throw new RuntimeException("should not reach here");
    }
  }
  
  public void doObject(int begin, int end)
  {
    tmp.add(getClass(begin, end));
  }
  
  public void doArray(int begin, int end)
  {
    int inner = arrayInnerBegin(begin);
    Class elemCls = null;
    switch (_signature.getByteAt(inner))
    {
    case 66: 
      elemCls = Boolean.TYPE; break;
    case 67: 
      elemCls = Character.TYPE; break;
    case 68: 
      elemCls = Double.TYPE; break;
    case 70: 
      elemCls = Float.TYPE; break;
    case 73: 
      elemCls = Integer.TYPE; break;
    case 74: 
      elemCls = Long.TYPE; break;
    case 83: 
      elemCls = Short.TYPE; break;
    case 90: 
      elemCls = Boolean.TYPE; break;
    case 76: 
      elemCls = getClass(inner + 1, end); break;
    }
    int dimension = inner - begin;
    
    int[] dimArray = new int[dimension];
    tmp.add(Array.newInstance(elemCls, dimArray).getClass());
  }
  
  protected Class getClass(int begin, int end)
  {
    String className = getClassName(begin, end);
    try
    {
      return Class.forName(className, true, this$0.cl);
    }
    catch (Exception e)
    {
      if (ObjectReader.access$000()) {
        System.err.println("Can't load class " + className);
      }
      throw new RuntimeException(e);
    }
  }
  
  protected String getClassName(int begin, int end)
  {
    StringBuffer buf = new StringBuffer();
    for (int i = begin; i < end; i++)
    {
      char c = (char)(_signature.getByteAt(i) & 0xFF);
      if (c == '/') {
        buf.append('.');
      } else {
        buf.append(c);
      }
    }
    return buf.toString();
  }
  
  protected int arrayInnerBegin(int begin)
  {
    while (_signature.getByteAt(begin) == 91) {
      begin++;
    }
    return begin;
  }
  
  public int getNumParams()
  {
    return tmp.size();
  }
  
  public Enumeration getParamTypes()
  {
    return tmp.elements();
  }
}

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

import java.io.PrintStream;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.memory.SymbolTable;
import sun.jvm.hotspot.oops.BooleanField;
import sun.jvm.hotspot.oops.ByteField;
import sun.jvm.hotspot.oops.CIntField;
import sun.jvm.hotspot.oops.CharField;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.DoubleField;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.FloatField;
import sun.jvm.hotspot.oops.IndexableFieldIdentifier;
import sun.jvm.hotspot.oops.Instance;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.IntField;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.LongField;
import sun.jvm.hotspot.oops.ObjArray;
import sun.jvm.hotspot.oops.ObjArrayKlass;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.oops.OopUtilities;
import sun.jvm.hotspot.oops.ShortField;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.oops.TypeArray;
import sun.jvm.hotspot.oops.TypeArrayKlass;
import sun.jvm.hotspot.runtime.SignatureIterator;
import sun.jvm.hotspot.runtime.VM;

public class ObjectReader
{
  private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.utilities.ObjectReader.DEBUG") != null;
  protected Symbol javaLangString;
  protected final ClassLoader cl;
  protected Map oopToObjMap;
  protected Map fieldMap;
  
  public ObjectReader(ClassLoader cl)
  {
    this.cl = cl;
    oopToObjMap = new HashMap();
    fieldMap = new HashMap();
  }
  
  public ObjectReader()
  {
    this(new ProcImageClassLoader());
  }
  
  public Object readObject(Oop oop)
    throws ClassNotFoundException
  {
    if ((oop instanceof Instance)) {
      return readInstance((Instance)oop);
    }
    if ((oop instanceof TypeArray)) {
      return readPrimitiveArray((TypeArray)oop);
    }
    if ((oop instanceof ObjArray)) {
      return readObjectArray((ObjArray)oop);
    }
    return null;
  }
  
  protected final Object getDefaultPrimitiveValue(Class clz)
  {
    if (clz == Boolean.TYPE) {
      return Boolean.FALSE;
    }
    if (clz == Character.TYPE) {
      return new Character(' ');
    }
    if (clz == Byte.TYPE) {
      return new Byte((byte)0);
    }
    if (clz == Short.TYPE) {
      return new Short((short)0);
    }
    if (clz == Integer.TYPE) {
      return new Integer(0);
    }
    if (clz == Long.TYPE) {
      return new Long(0L);
    }
    if (clz == Float.TYPE) {
      return new Float(0.0F);
    }
    if (clz == Double.TYPE) {
      return new Double(0.0D);
    }
    throw new RuntimeException("should not reach here!");
  }
  
  protected Symbol javaLangString()
  {
    if (javaLangString == null) {
      javaLangString = VM.getVM().getSymbolTable().probe("java/lang/String");
    }
    return javaLangString;
  }
  
  public Object readInstance(Instance oop)
    throws ClassNotFoundException
  {
    Object result = getFromObjTable(oop);
    if (result == null)
    {
      InstanceKlass kls = (InstanceKlass)oop.getKlass();
      if (kls.getName().equals(javaLangString())) {
        return OopUtilities.stringOopToString(oop);
      }
      Class clz = readClass(kls);
      Constructor[] ctrs;
      int n;
      try
      {
        result = clz.newInstance();
      }
      catch (Exception ex)
      {
        ctrs = clz.getDeclaredConstructors();
        n = 0;
      }
      for (; n < ctrs.length; n++)
      {
        Constructor c = ctrs[n];
        Class[] paramTypes = c.getParameterTypes();
        Object[] params = new Object[paramTypes.length];
        for (int i = 0; i < params.length; i++) {
          if (paramTypes[i].isPrimitive()) {
            params[i] = getDefaultPrimitiveValue(paramTypes[i]);
          }
        }
        try
        {
          c.setAccessible(true);
          result = c.newInstance(params);
        }
        catch (Exception exp)
        {
          if (DEBUG)
          {
            System.err.println("Can't create object using " + c);
            exp.printStackTrace();
          }
        }
      }
      if (result != null)
      {
        putIntoObjTable(oop, result);
        oop.iterate(new FieldSetter(result), false);
      }
    }
    return result;
  }
  
  public Object readPrimitiveArray(final TypeArray array)
  {
    Object result = getFromObjTable(array);
    if (result == null)
    {
      int length = (int)array.getLength();
      TypeArrayKlass klass = (TypeArrayKlass)array.getKlass();
      int type = klass.getElementType();
      switch (type)
      {
      case 4: 
        final boolean[] arrayObj = new boolean[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doBoolean(BooleanField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 5: 
        final char[] arrayObj = new char[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doChar(CharField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 6: 
        final float[] arrayObj = new float[length];
        array.iterate(new DefaultOopVisitor()
        {
       
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