sa-jdi

   public void doFloat(FloatField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 7: 
        final double[] arrayObj = new double[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doDouble(DoubleField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 8: 
        final byte[] arrayObj = new byte[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doByte(ByteField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 9: 
        final short[] arrayObj = new short[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doShort(ShortField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 10: 
        final int[] arrayObj = new int[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doInt(IntField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      case 11: 
        final long[] arrayObj = new long[length];
        array.iterate(new DefaultOopVisitor()
        {
          public void doLong(LongField field, boolean isVMField)
          {
            IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
            arrayObj[ifd.getIndex()] = field.getValue(array);
          }
        }, false);
        
        result = arrayObj;
        
        break;
      default: 
        throw new RuntimeException("should not reach here!");
      }
      putIntoObjTable(array, result);
    }
    return result;
  }
  
  protected final boolean isRobust(OopHandle handle)
  {
    return RobustOopDeterminator.oopLooksValid(handle);
  }
  
  public Object readObjectArray(ObjArray array)
    throws ClassNotFoundException
  {
    Object result = getFromObjTable(array);
    if (result == null)
    {
      int length = (int)array.getLength();
      ObjArrayKlass klass = (ObjArrayKlass)array.getKlass();
      Klass bottomKls = klass.getBottomKlass();
      Class bottomCls = null;
      int dimension = (int)klass.getDimension();
      int[] dimArray = null;
      if ((bottomKls instanceof InstanceKlass))
      {
        bottomCls = readClass((InstanceKlass)bottomKls);
        dimArray = new int[dimension];
      }
      else
      {
        TypeArrayKlass botKls = (TypeArrayKlass)bottomKls;
        dimArray = new int[dimension - 1];
      }
      dimArray[0] = length;
      final Object[] arrayObj = (Object[])Array.newInstance(bottomCls, dimArray);
      putIntoObjTable(array, arrayObj);
      result = arrayObj;
      array.iterate(new DefaultOopVisitor()
      {
        public void doOop(OopField field, boolean isVMField)
        {
          OopHandle handle = field.getValueAsOopHandle(getObj());
          if (!isRobust(handle)) {
            return;
          }
          IndexableFieldIdentifier ifd = (IndexableFieldIdentifier)field.getID();
          try
          {
            arrayObj[ifd.getIndex()] = readObject(field.getValue(getObj()));
          }
          catch (Exception e)
          {
            if (ObjectReader.DEBUG)
            {
              System.err.println("Array element set failed for " + ifd);
              e.printStackTrace();
            }
          }
        }
      }, false);
    }
    return result;
  }
  
  protected class FieldSetter
    extends DefaultOopVisitor
  {
    protected Object obj;
    
    public FieldSetter(Object obj)
    {
      this.obj = obj;
    }
    
    private void printFieldSetError(java.lang.reflect.Field f, Exception ex)
    {
      if (ObjectReader.DEBUG)
      {
        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 (!isRobust(handle)) {
        return;
      }
      java.lang.reflect.Field f = null;
      try
      {
        f = readField(field);
        if (Modifier.isFinal(f.getModifiers())) {
          return;
        }
        f.setAccessible(true);
        f.set(obj, readObject(field.getValue(getObj())));
      }
      catch (Exception ex)
      {
        printFieldSetError(f, ex);
      }
    }
    
    public void doByte(ByteField field, boolean isVMField)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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)
    {
      java.lang.reflect.Field f = null;
      try
      {
        f = 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!");
    }
  }
  
  public Class readClass(InstanceKlass kls)
    throws ClassNotFoundException
  {
    Class cls = (Class)getFromObjTable(kls);
    if (cls == null)
    {
      cls = Class.forName(kls.getName().asString().replace('/', '.'), true, cl);
      putIntoObjTable(kls, cls);
    }
    return cls;
  }
  
  public Object readMethodOrConstructor(sun.jvm.hotspot.oops.Method m)
    throws NoSuchMethodException, ClassNotFoundException
  {
    String name = m.getName().asString();
    if (name.equals("<init>")) {
      return readConstructor(m);
    }
    return readMethod(m);
  }
  
  public java.lang.reflect.Method readMethod(sun.jvm.hotspot.oops.Method m)
    throws NoSuchMethodException, ClassNotFoundException
  {
    java.lang.reflect.Method result = (java.lang.reflect.Method)getFromObjTable(m);
    if (result == null)
    {
      Class clz = readClass((InstanceKlass)m.getMethodHolder());
      String name = m.getName().asString();
      Class[] paramTypes = getParamTypes(m.getSignature());
      result = clz.getMethod(name, paramTypes);
      putIntoObjTable(m, result);
    }
    return result;
  }
  
  public Constructor readConstructor(sun.jvm.hotspot.oops.Method m)
    throws NoSuchMethodException, ClassNotFoundException
  {
    Constructor result = (Constructor)getFromObjTable(m);
    if (result == null)
    {
      Class clz = readClass((InstanceKlass)m.getMethodHolder());
      String name = m.getName().asString();
      Class[] paramTypes = getParamTypes(m.getSignature());
      result = clz.getDeclaredConstructor(paramTypes);
      putIntoObjTable(m, result);
    }
    return result;
  }
  
  public java.lang.reflect.Field readField(sun.jvm.hotspot.oops.Field f)
    throws NoSuchFieldException, ClassNotFoundException
  {
    java.lang.reflect.Field result = (java.lang.reflect.Field)fieldMap.get(f);
    if (result == null)
    {
      FieldIdentifier fieldId = f.getID();
      Class clz = readClass(f.getFieldHolder());
      String name = fieldId.getName();
      try
      {
        result = clz.getField(name);
      }
      catch (NoSuchFieldException nsfe)
      {
        result = clz.getDeclaredField(name);
      }
      fieldMap.put(f, result);
    }
    return result;
  }
  
  protected void putIntoObjTable(Oop oop, Object obj)
  {
    oopToObjMap.put(oop, obj);
  }
  
  protected Object getFromObjTable(Oop oop)
  {
    return oopToObjMap.get(oop);
  }
  
  protected class SignatureParser
    extends SignatureIterator
  {
    protected Vector tmp = new Vector();
    
    public SignatureParser(Symbol s)
    {
      super();
    }
    
    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, cl);
      }
      catch (Exception e)
      {
        if (ObjectReader.DEBUG) {
          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();
    }
  }
  
  protected Class[] getParamTypes(Symbol signature)
  {
    SignatureParser sp = new SignatureParser(signature);
    sp.iterateParameters();
    Class[] result = new Class[sp.getNumParams()];
    Enumeration e = sp.getParamTypes();
    int i = 0;
    while (e.hasMoreElements())
    {
      result[i] = ((Class)e.nextElement());
      i++;
    }
    return result;
  }
}

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

import java.io.PrintStream;

public class PlatformInfo
{
  public static String getOS()
    throws UnsupportedPlatformException
  {
    String os = System.getProperty("os.name");
    if (os.equals("SunOS")) {
      return "solaris";
    }
    if (os.equals("Linux")) {
      return "linux";
    }
    if (os.startsWith("Windows")) {
      return "win32";
    }
    throw new UnsupportedPlatformException("Operating system " + os + " not yet supported");
  }
  
  public static String getCPU()
    throws UnsupportedPlatformException
  {
    String cpu = System.getProperty("os.arch");
    if (cpu.equals("i386")) {
      return "x86";
    }
    if ((cpu.equals("sparc")) || (cpu.equals("x86")) || (cpu.equals("ia64"))) {
      return cpu;
    }
    if (cpu.equals("sparcv9")) {
      return "sparc";
    }
    if ((cpu.equals("x86_64")) || (cpu.equals("amd64"))) {
      return "amd64";
    }
    throw new UnsupportedPlatformException("CPU type " + cpu + " not yet supported");
  }
  
  public static void main(String[] args)
  {
    System.out.println(getOS());
  }
}

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

import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.code.NMethod;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.gc_interface.CollectedHeap;
import sun.jvm.hotspot.interpreter.Interpreter;
import sun.jvm.hotspot.memory.GenCollectedHeap;
import sun.jvm.hotspot.memory.Generation;
import sun.jvm.hotspot.memory.Universe;
import sun.jvm.hotspot.runtime.JNIHandleBlock;
import sun.jvm.hotspot.runtime.JNIHandles;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.ThreadLocalAllocBuffer;
import sun.jvm.hotspot.runtime.Threads;
import sun.jvm.hotspot.runtime.VM;

public class PointerFinder
{
  public static PointerLocation find(Address a)
  {
    PointerLocation loc = new PointerLocation(a);
    
    CollectedHeap heap = VM.getVM().getUniverse().heap();
    if ((heap instanceof GenCollectedHeap))
    {
      GenCollectedHeap genheap = (GenCollectedHeap)heap;
      if (genheap.isIn(a))
      {
        for (int i = 0; i < genheap.nGens(); i++)
        {
          Generation g = genheap.getGen(i);
          if (g.isIn(a))
          {
            gen = g;
            break;
          }
        }
        if (gen == null)
        {
          Generation permGen = genheap.permGen();
          if (Assert.ASSERTS_ENABLED) {
            Assert.that(permGen.isIn(a), "should have been in ordinary or perm gens if it's in the heap");
          }
          permGen = permGen;
        }
        if (VM.getVM().getUseTLAB()) {
          for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next())
          {
            ThreadLocalAllocBuffer tlab = t.tlab();
            if (tlab.contains(a))
            {
              inTLAB = true;
              tlabThread = t;
              tlab = tlab;
              break;
            }
          }
        }
        return loc;
      }
    }
    else if (heap.isIn(a))
    {
      heap = heap;
      return loc;
    }
    Interpreter interp = VM.getVM().getInterpreter();
    if (interp.contains(a))
    {
      inInterpreter = true;
      interpreterCodelet = interp.getCodeletContaining(a);
      return loc;
    }
    if (!VM.getVM().isCore())
    {
      CodeCache c = VM.getVM().getCodeCache();
      if (c.contains(a))
      {
        inCodeCache = true;
        blob = c.findBlobUnsafe(a);
        if (Assert.ASSERTS_ENABLED) {
          Assert.that(blob != null, "Should have found CodeBlob");
        }
        inBlobCode = blob.codeContains(a);
        inBlobData = blob.dataContains(a);
        if (blob.isNMethod())
        {
          NMethod nm = (NMethod)blob;
          inBlobOops = nm.oopsContains(a);
        }
        inBlobUnknownLocation = ((!inBlobCode) && (!inBlobData) && (!inBlobOops));
        
        return loc;
      }
    }
    JNIHandles handles = VM.getVM().getJNIHandles();
    JNIHandleBlock handleBlock = handles.globalHandles();
    if (handleBlock != null) {
      handleBlock = handleBlock.blockContainingHandle(a);
    }
    if (handleBlock != null)
    {
      inStrongGlobalJNIHandleBlock = true;
      handleBlock = handleBlock;
      return loc;
    }
    handleBlock = handles.weakGlobalHandles();
    if (handleBlock != null)
    {
      handleBlock = handleBlock.blockContainingHandle(a);
      if (handleBlock != null)
      {
        inWeakGlobalJNIHandleBlock = true;
        handleBlock = handleBlock;
        return loc;
      }
      for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next())
      {
        handleBlock = t.activeHandles();
        if (handleBlock != null)
        {
          handleBlock = handleBlock.blockContainingHandle(a);
          if (handleBlock != null)
          {
            inLocalJNIHandleBlock = true;
            handleBlock = handleBlock;
            handleThread = t;
            return loc;
          }
        }
      }
    }
    return loc;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.PointerFinder
 * 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 sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.gc_interface.CollectedHeap;
import sun.jvm.hotspot.interpreter.InterpreterCodelet;
import sun.jvm.hotspot.memory.Generation;
import sun.jvm.hotspot.runtime.JNIHandleBlock;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.Thread;
import sun.jvm.hotspot.runtime.ThreadLocalAllocBuffer;

public class PointerLocation
{
  Address addr;
  CollectedHeap heap;
  Generation gen;
  Generation permGen;
  boolean inTLAB;
  JavaThread tlabThread;
  ThreadLocalAllocBuffer tlab;
  boolean inInterpreter;
  boolean inCodeCache;
  InterpreterCodelet interpreterCodelet;
  CodeBlob blob;
  boolean inBlobCode;
  boolean inBlobData;
  boolean inBlobOops;
  boolean inBlobUnknownLocation;
  boolean inStrongGlobalJNIHandleBlock;
  boolean inWeakGlobalJNIHandleBlock;
  boolean inLocalJNIHandleBlock;
  JNIHandleBlock handleBlock;
  Thread handleThread;
  
  public PointerLocation(Address addr)
  {
    this.addr = addr;
  }
  
  public boolean isInHeap()
  {
    return (heap != null) || (gen != null) || (permGen != null);
  }
  
  public boolean isInNewGen()
  {
    return (gen != null) && (gen.level() == 0);
  }
  
  public boolean isInOldGen()
  {
    return (gen != null) && (gen.level() == 1);
  }
  
  public boolean isInPermGen()
  {
    return permGen != null;
  }
  
  public boolean inOtherGen()
  {
    return (!isInNewGen()) && (!isInOldGen()) && (!isInPermGen());
  }
  
  public Generation getGeneration()
  {
    if (gen != null) {
      return gen;
    }
    return permGen;
  }
  
  public boolean isInTLAB()
  {
    return inTLAB;
  }
  
  public JavaThread getTLABThread()
  {
    return tlabThread;
  }
  
  public ThreadLocalAllocBuffer getTLAB()
  {
    return tlab;
  }
  
  public boolean isInInterpreter()
  {
    return inInterpreter;
  }
  
  public InterpreterCodelet getInterpreterCodelet()
  {
    return interpreterCodelet;
  }
  
  public boolean isInCodeCache()
  {
    return inCodeCache;
  }
  
  public CodeBlob getCodeBlob()
  {
    return blob;
  }
  
  public boolean isInBlobCode()
  {
    return inBlobCode;
  }
  
  public boolean isInBlobData()
  {
    return inBlobData;
  }
  
  public boolean isInBlobOops()
  {
    return inBlobOops;
  }
  
  public boolean isInBlobUnknownLocation()
  {
    return inBlobUnknownLocation;
  }
  
  public boolean isInStrongGlobalJNIHandleBlock()
  {
    return inStrongGlobalJNIHandleBlock;
  }
  
  public boolean isInWeakGlobalJNIHandleBlock()
  {
    return inWeakGlobalJNIHandleBlock;
  }
  
  public boolean isInLocalJNIHandleBlock()
  {
    return inLocalJNIHandleBlock;
  }
  
  public JNIHandleBlock getJNIHandleBlock()
  {
    return handleBlock;
  }
  
  public Thread getJNIHandleThread()
  {
    return handleThread;
  }
  
  public boolean isUnknown()
  {
    return (!isInHeap()) && (!isInInterpreter()) && (!isInCodeCache()) && (!isInStrongGlobalJNIHandleBlock()) && (!isInWeakGlobalJNIHandleBlock()) && (!isInLocalJNIHandleBlock());
  }
  
  public String toString()
  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    printOn(new PrintStream(bos));
    return bos.toString();
  }
  
  public void print()
  {
    printOn(System.out);
  }
  
  public void printOn(PrintStream tty)
  {
    tty.print("Address ");
    if (addr == null) {
      tty.print("0x0");
    } else {
      tty.print(addr.toString());
    }
    tty.print(": ");
    if (isInHeap())
    {
      if (isInTLAB())
      {
        tty.print("In thread-local allocation buffer for thread \"" + getTLABThread().getThreadName() + "\" (");
        
        getTLABThread().printThreadIDOn(tty);
        tty.print(") ");
        getTLAB().printOn(tty);
      }
      else
      {
        if (isInNewGen()) {
          tty.print("In new generation ");
        } else if (isInOldGen()) {
          tty.print("In old generation ");
        } else if (isInPermGen()) {
          tty.print("In perm generation ");
        } else if (gen != null) {
          tty.print("In Generation " + getGeneration().level());
        } else {
          tty.print("In unknown section of Java heap");
        }
        if (getGeneration() != null) {
          getGeneration().printOn(tty);
        }
      }
    }
    else if (isInInterpreter())
    {
      tty.println("In interpreter codelet \"" + interpreterCodelet.getDescription() + "\"");
      interpreterCodelet.printOn(tty);
    }
    else if (isInCodeCache())
    {
      CodeBlob b = getCodeBlob();
      tty.print("In ");
      if (isInBlobCode())
      {
        tty.print("code");
      }
      else if (isInBlobData())
      {
        tty.print("data");
      }
      else if (isInBlobOops())
      {
        tty.print("oops");
      }
      else
      {
        if (Assert.ASSERTS_ENABLED) {
          Assert.that(isInBlobUnknownLocation(), "Should have known location in CodeBlob");
        }
        tty.print("unknown location");
      }
      tty.print(" in ");
      b.printOn(tty);
    }
    else if ((isInStrongGlobalJNIHandleBlock()) || (isInWeakGlobalJNIHandleBlock()) || (isInLocalJNIHandleBlock()))
    {
      tty.print("In ");
      if (isInStrongGlobalJNIHandleBlock()) {
        tty.print("strong global");
      } else if (isInWeakGlobalJNIHandleBlock()) {
        tty.print("weak global");
      } else {
        tty.print("thread-local");
      }
      tty.print(" JNI handle block (" + handleBlock.top() + " handle slots present)");
      if (isInLocalJNIHandleBlock()) {
        if (handleThread.isJavaThread())
        {
          tty.print(" for JavaThread ");
          ((JavaThread)handleThread).printThreadIDOn(tty);
        }
        else
        {
          tty.print("for a non-Java Thread");
        }
      }
    }
    else
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(isUnknown(), "Should have unknown location");
      }
      tty.print("In unknown location");
    }
  }
}

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

import java.io.ByteArrayOutputStream;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.tools.jcore.ClassWriter;

public class ProcImageClassLoader
  extends ClassLoader
{
  public ProcImageClassLoader(ClassLoader parent)
  {
    super(parent);
  }
  
  public ProcImageClassLoader()
  {
    this(Thread.currentThread().getContextClassLoader());
  }
  
  protected Class findClass(String className)
    throws ClassNotFoundException
  {
    try
    {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      InstanceKlass klass = SystemDictionaryHelper.findInstanceKlass(className);
      ClassWriter cw = new ClassWriter(klass, bos);
      cw.write();
      byte[] buf = bos.toByteArray();
      return defineClass(className, buf, 0, buf.length);
    }
    catch (Exception e)
    {
      throw ((ClassNotFoundException)new ClassNotFoundException().initCause(e));
    }
  }
}

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

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

public class ProgressiveHeapVisitor
  implements HeapVisitor
{
  private HeapVisitor userHeapVisitor;
  private HeapProgressThunk thunk;
  private long usedSize;
  private long visitedSize;
  private double lastNotificationFraction;
  private static double MINIMUM_NOTIFICATION_FRACTION = 0.01D;
  
  public ProgressiveHeapVisitor(HeapVisitor userHeapVisitor, HeapProgressThunk thunk)
  {
    this.userHeapVisitor = userHeapVisitor;
    this.thunk = thunk;
  }
  
  public void prologue(long usedSize)
  {
    this.usedSize = usedSize;
    visitedSize = 0L;
    userHeapVisitor.prologue(usedSize);
  }
  
  public boolean doObj(Oop obj)
  {
    userHeapVisitor.doObj(obj);
    visitedSize += obj.getObjectSize();
    double curFrac = visitedSize / usedSize;
    if (curFrac > lastNotificationFraction + MINIMUM_NOTIFICATION_FRACTION)
    {
      thunk.heapIterationFractionUpdate(curFrac);
      lastNotificationFraction = curFrac;
    }
    return false;
  }
  
  public void epilogue()
  {
    userHeapVisitor.epilogue();
    thunk.heapIterationComplete();
  }
}

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

public class RBColor
{
  public static final RBColor RED = new RBColor("red");
  public static final RBColor BLACK = new RBColor("black");
  private String name;
  
  public String getName()
  {
    return name;
  }
  
  private RBColor(String name)
  {
    this.name = name;
  }
}

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

public class RBNode
{
  private Object data;
  private RBNode left;
  private RBNode right;
  private RBNode parent;
  private RBColor color;
  
  public RBNode(Object data)
  {
    this.data = data;
    color = RBColor.RED;
  }
  
  public Object getData()
  {
    return data;
  }
  
  public void copyFrom(RBNode arg)
  {
    data = data;
  }
  
  public boolean update()
  {
    return false;
  }
  
  public RBColor getColor()
  {
    return color;
  }
  
  public void setColor(RBColor color)
  {
    this.color = color;
  }
  
  public RBNode getParent()
  {
    return parent;
  }
  
  public void setParent(RBNode parent)
  {
    this.parent = parent;
  }
  
  public RBNode getLeft()
  {
    return left;
  }
  
  public void setLeft(RBNode left)
  {
    this.left = left;
  }
  
  public RBNode getRight()
  {
    return right;
  }
  
  public void setRight(RBNode right)
  {
    this.right = right;
  }
}

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

import java.util.Comparator;

final class RBTree$1
  implements 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;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.utilities.RBTree.1
 * 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.Comparator;
import java.util.Random;

public class RBTree
{
  private RBNode root;
  private Comparator comparator;
  protected static final boolean DEBUGGING = true;
  protected static final boolean VERBOSE = true;
  protected static final boolean REALLY_VERBOSE = false;
  
  public RBTree(Comparator comparator)
  {
    this.comparator = comparator;
  }
  
  public RBNode getRoot()
  {
    return root;
  }
  
  public void insertNode(RBNode x)
  {
    treeInsert(x);
    
    x.setColor(RBColor.RED);
    boolean shouldPropagate = x.update();
    
    RBNode propagateStart = x;
    while ((x != root) && (x.getParent().getColor() == RBColor.RED)) {
      if (x.getParent() == x.getParent().getParent().getLeft())
      {
        RBNode y = x.getParent().getParent().getRight();
        if ((y != null) && (y.getColor() == RBColor.RED))
        {
          x.getParent().setColor(RBColor.BLACK);
          y.setColor(RBColor.BLACK);
          x.getParent().getParent().setColor(RBColor.RED);
          x.getParent().update();
          x = x.getParent().getParent();
          shouldPropagate = x.update();
          propagateStart = x;
        }
        else
        {
          if (x == x.getParent().getRight())
          {
            x = x.getParent();
            leftRotate(x);
          }
          x.getParent().setColor(RBColor.BLACK);
          x.getParent().getParent().setColor(RBColor.RED);
          shouldPropagate = rightRotate(x.getParent().getParent());
          propagateStart = x.getParent();
        }
      }
      else
      {
        RBNode y = x.getParent().getParent().getLeft();
        if ((y != null) && (y.getColor() == RBColor.RED))
        {
          x.getParent().setColor(RBColor.BLACK);
          y.setColor(RBColor.BLACK);
          x.getParent().getParent().setColor(RBColor.RED);
          x.getParent().update();
          x = x.getParent().getParent();
          shouldPropagate = x.update();
          propagateStart = x;
        }
        else
        {
          if (x == x.getParent().getLeft())
          {
            x = x.getParent();
            rightRotate(x);
          }
          x.getParent().setColor(RBColor.BLACK);
          x.getParent().getParent().setColor(RBColor.RED);
          shouldPropagate = leftRotate(x.getParent().getParent());
          propagateStart = x.getParent();
        }
      }
    }
    while ((shouldPropagate) && (propagateStart != root))
    {
      propagateStart = propagateStart.getParent();
      shouldPropagate = propagateStart.update();
    }
    root.setColor(RBColor.BLACK);
    
    verify();
  }
  
  public void deleteNode(RBNode z)
  {
    RBNode y;
    RBNode y;
    if ((z.getLeft() == null) || (z.getRight() == null)) {
      y = z;
    } else {
      y = treeSuccessor(z);
    }
    RBNode x;
    RBNode x;
    if (y.getLeft() != null) {
      x = y.getLeft();
    } else {
      x = y.getRight();
    }
    RBNode xParent;
    RBNode xParent;
    if (x != null)
    {
      x.setParent(y.getParent());
      xParent = x.getParent();
    }
    else
    {
      xParent = y.getParent();
    }
    if (y.getParent() == null) {
      root = x;
    } else if (y == y.getParent().getLeft()) {
      y.getParent().setLeft(x);
    } else {
      y.getParent().setRight(x);
    }
    if (y != z) {
      z.copyFrom(y);
    }
    if (y.getColor() == RBColor.BLACK) {
      deleteFixup(x, xParent);
    }
    verify();
  }
  
  public void print()
  {
    printOn(System.out);
  }
  
  public void printOn(PrintStream tty)
  {
    printFromNode(root, tty, 0);
  }
  
  protected Object getNodeValue(RBNode node)
  {
    return node.getData();
  }
  
  protected void verify()
  {
    verifyFromNode(root);
  }
  
  private void treeInsert(RBNode z)
  {
    RBNode y = null;
    RBNode x = root;
    while (x != null)
    {
      y = x;
      if (comparator.compare(getNodeValue(z), getNodeValue(x)) < 0) {
        x = x.getLeft();
      } else {
        x = x.getRight();
      }
    }
    z.setParent(y);
    if (y == null) {
      root = z;
    } else if (comparator.compare(getNodeValue(z), getNodeValue(y)) < 0) {
      y.setLeft(z);
    } else {
      y.setRight(z);
    }
  }
  
  private RBNode treeSuccessor(RBNode x)
  {
    if (x.getRight() != null) {
      return treeMinimum(x.getRight());
    }
    RBNode y = x.getParent();
    while ((y != null) && (x == y.getRight()))
    {
      x = y;
      y = y.getParent();
    }
    return y;
  }
  
  private RBNode treeMinimum(RBNode x)
  {
    while (x.getLeft() != null) {
      x = x.getLeft();
    }
    return x;
  }
  
  private boolean leftRotate(RBNode x)
  {
    RBNode y = x.getRight();
    
    x.setRight(y.getLeft());
    if (y.getLeft() != null) {
      y.getLeft().setParent(x);
    }
    y.setParent(x.getParent());
    if (x.getParent() == null) {
      root = y;
    } else if (x == x.getParent().getLeft()) {
      x.getParent().setLeft(y);
    } else {
      x.getParent().setRight(y);
    }
    y.setLeft(x);
    x.setParent(y);
    
    boolean res = x.update();
    res = (y.update()) || (res);
    return res;
  }
  
  private boolean rightRotate(RBNode y)
  {
    RBNode x = y.getLeft();
    
    y.setLeft(x.getRight());
    if (x.getRight() != null) {
      x.getRight().setParent(y);
    }
    x.setParent(y.getParent());
    if (y.getParent() == null) {
      root = x;
    } else if (y == y.getParent().getLeft()) {
      y.getParent().setLeft(x);
    } else {
      y.getParent().setRight(x);
    }
    x.setRight(y);
    y.setParent(x);
    
    boolean res = y.update();
    res = (x.update()) || (res);
    return res;
  }
  
  private void deleteFixup(RBNode x, RBNode xParent)
  {
    while ((x != root) && ((x == null) || (x.getColor() == RBColor.BLACK))) {
      if (x == xParent.getLeft())
      {
        RBNode w = xParent.getRight();
        if (w == null) {
          throw new RuntimeException("x's sibling should not be null");
        }
        if (w.getColor() == RBColor.RED)
        {
          w.setColor(RBColor.BLACK);
          xParent.setColor(RBColor.RED);
          leftRotate(xParent);
          w = xParent.getRight();
        }
        if (((w.getLeft() == null) || (w.getLeft().getColor() == RBColor.BLACK)) && ((w.getRight() == null) || (w.getRight().getColor() == RBColor.BLACK)))
        {
          w.setColor(RBColor.RED);
          x = xParent;
          xParent = x.getParent();
        }
        else
        {
          if ((w.getRight() == null) || (w.getRight().getColor() == RBColor.BLACK))
          {
            w.getLeft().setColor(RBColor.BLACK);
            w.setColor(RBColor.RED);
            rightRotate(w);
            w = xParent.getRight();
          }
          w.setColor(xParent.getColor());
          xParent.setColor(RBColor.BLACK);
          if (w.getRight() != null) {
            w.getRight().setColor(RBColor.BLACK);
          }
          leftRotate(xParent);
          x = root;
          xParent = x.getParent();
        }
      }
      else
      {
        RBNode w = xParent.getLeft();
        if (w == null) {
          throw new RuntimeException("x's sibling should not be null");
        }
        if (w.getColor() == RBColor.RED)
        {
          w.setColor(RBColor.BLACK);
          xParent.setColor(RBColor.RED);
          rightRotate(xParent);
          w = xParent.getLeft();
        }
        if (((w.getRight() == null) || (w.getRight().getColor() == RBColor.BLACK)) && ((w.getLeft() == null) || (w.getLeft().getColor() == RBColor.BLACK)))
        {
          w.setColor(RBColor.RED);
          x = xParent;
          xParent = x.getParent();
        }
        else
        {
          if ((w.getLeft() == null) || (w.getLeft().getColor() == RBColor.BLACK))
          {
            w.getRight().setColor(RBColor.BLACK);
            w.setColor(RBColor.RED);
            leftRotate(w);
            w = xParent.getLeft();
          }
          w.setColor(xParent.getColor());
          xParent.setColor(RBColor.BLACK);
          if (w.getLeft() != null) {
            w.getLeft().setColor(RBColor.BLACK);
          }
          rightRotate(xParent);
          x = root;
          xParent = x.getParent();
        }
      }
    }
    if (x != null) {
      x.setColor(RBColor.BLACK);
    }
  }
  
  private int verifyFromNode(RBNode node)
  {
    if (node == null) {
      return 1;
    }
    if ((node.getColor() != RBColor.RED) && (node.getColor() != RBColor.BLACK))
    {
      System.err.println("Verify failed:");
      printOn(System.err);
      
      throw new RuntimeException("Verify failed (1)");
    }
    if (node.getColor() == RBColor.RED)
    {
      if ((node.getLeft() != null) && 
        (node.getLeft().getColor() != RBColor.BLACK))
      {
        System.err.println("Verify failed:");
        printOn(System.err);
        
        throw new RuntimeException("Verify failed (2)");
      }
      if ((node.getRight() != null) && 
        (node.getRight().getColor() != RBColor.BLACK))
      {
        System.err.println("Verify failed:");
        printOn(System.err);
        
        throw new RuntimeException("Verify failed (3)");
      }
    }
    int i = verifyFromNode(node.getLeft());
    int j = verifyFromNode(node.getRight());
    if (i != j)
    {
      System.err.println("Veri
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