sa-jdi

ypeException
  {
    Type type = db.lookupType("constantPoolOopDesc");
    tags = new OopField(type.getOopField("_tags"), 0L);
    operands = new OopField(type.getOopField("_operands"), 0L);
    cache = new OopField(type.getOopField("_cache"), 0L);
    poolHolder = new OopField(type.getOopField("_pool_holder"), 0L);
    length = new CIntField(type.getCIntegerField("_length"), 0L);
    headerSize = type.getSize();
    elementSize = 0L;
    
    INDY_BSM_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_bsm_offset").intValue();
    INDY_ARGC_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argc_offset").intValue();
    INDY_ARGV_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argv_offset").intValue();
  }
  
  ConstantPool(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public boolean isConstantPool()
  {
    return true;
  }
  
  public TypeArray getTags()
  {
    return (TypeArray)tags.getValue(this);
  }
  
  public TypeArray getOperands()
  {
    return (TypeArray)operands.getValue(this);
  }
  
  public ConstantPoolCache getCache()
  {
    return (ConstantPoolCache)cache.getValue(this);
  }
  
  public Klass getPoolHolder()
  {
    return (Klass)poolHolder.getValue(this);
  }
  
  public int getLength()
  {
    return (int)length.getValue(this);
  }
  
  private long getElementSize()
  {
    if (elementSize != 0L) {
      return elementSize;
    }
    elementSize = VM.getVM().getOopSize();
    
    return elementSize;
  }
  
  private long indexOffset(long index)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that((index > 0L) && (index < getLength()), "invalid cp index " + index + " " + getLength());
    }
    return index * getElementSize() + headerSize;
  }
  
  public ConstantTag getTagAt(long index)
  {
    return new ConstantTag(getTags().getByteAt((int)index));
  }
  
  public Oop getObjAt(long index)
  {
    return getHeap().newOop(getHandle().getOopHandleAt(indexOffset(index)));
  }
  
  public Symbol getSymbolAt(long index)
  {
    return (Symbol)getObjAt(index);
  }
  
  public int getIntAt(long index)
  {
    return getHandle().getJIntAt(indexOffset(index));
  }
  
  public float getFloatAt(long index)
  {
    return getHandle().getJFloatAt(indexOffset(index));
  }
  
  public long getLongAt(long index)
  {
    int oneHalf = getHandle().getJIntAt(indexOffset(index + 1L));
    int otherHalf = getHandle().getJIntAt(indexOffset(index));
    
    return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf);
  }
  
  public double getDoubleAt(long index)
  {
    return Double.longBitsToDouble(getLongAt(index));
  }
  
  public int getFieldOrMethodAt(int which)
  {
    int i = -1;
    ConstantPoolCache cache = getCache();
    if (cache == null) {
      i = which;
    } else {
      i = cache.getEntryAt(0xFFFF & VM.getVM().getBytes().swapShort((short)which)).getConstantPoolIndex();
    }
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(getTagAt(i).isFieldOrMethod(), "Corrupted constant pool");
    }
    int res = getIntAt(i);
    
    return res;
  }
  
  public int[] getNameAndTypeAt(int which)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(getTagAt(which).isNameAndType(), "Corrupted constant pool");
    }
    int i = getIntAt(which);
    
    return new int[] { extractLowShortFromInt(i), extractHighShortFromInt(i) };
  }
  
  public Symbol getNameRefAt(int which)
  {
    int nameIndex = getNameAndTypeAt(getNameAndTypeRefIndexAt(which))[0];
    return getSymbolAt(nameIndex);
  }
  
  public Symbol getSignatureRefAt(int which)
  {
    int sigIndex = getNameAndTypeAt(getNameAndTypeRefIndexAt(which))[1];
    return getSymbolAt(sigIndex);
  }
  
  public Klass getKlassRefAt(int which)
  {
    if (!getTagAt(which).isKlass()) {
      return null;
    }
    return (Klass)getObjAt(which);
  }
  
  public InstanceKlass getFieldOrMethodKlassRefAt(int which)
  {
    int refIndex = getFieldOrMethodAt(which);
    int klassIndex = extractLowShortFromInt(refIndex);
    return (InstanceKlass)getKlassRefAt(klassIndex);
  }
  
  public Method getMethodRefAt(int which)
  {
    InstanceKlass klass = getFieldOrMethodKlassRefAt(which);
    if (klass == null) {
      return null;
    }
    Symbol name = getNameRefAt(which);
    Symbol sig = getSignatureRefAt(which);
    return klass.findMethod(name, sig);
  }
  
  public Field getFieldRefAt(int which)
  {
    InstanceKlass klass = getFieldOrMethodKlassRefAt(which);
    if (klass == null) {
      return null;
    }
    Symbol name = getNameRefAt(which);
    Symbol sig = getSignatureRefAt(which);
    return klass.findField(name, sig);
  }
  
  public int getNameAndTypeRefIndexAt(int index)
  {
    int refIndex = getFieldOrMethodAt(index);
    
    int i = extractHighShortFromInt(refIndex);
    
    return i;
  }
  
  public int getNameRefIndexAt(int index)
  {
    int[] refIndex = getNameAndTypeAt(index);
    
    int i = refIndex[0];
    
    return i;
  }
  
  public int getSignatureRefIndexAt(int index)
  {
    int[] refIndex = getNameAndTypeAt(index);
    
    int i = refIndex[1];
    
    return i;
  }
  
  public int getMethodHandleIndexAt(int i)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(getTagAt(i).isMethodHandle(), "Corrupted constant pool");
    }
    int res = extractHighShortFromInt(getIntAt(i));
    
    return res;
  }
  
  public int getMethodHandleRefKindAt(int i)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(getTagAt(i).isMethodHandle(), "Corrupted constant pool");
    }
    int res = extractLowShortFromInt(getIntAt(i));
    
    return res;
  }
  
  public int getMethodTypeIndexAt(int i)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(getTagAt(i).isMethodType(), "Corrupted constant pool");
    }
    int res = getIntAt(i);
    
    return res;
  }
  
  public short[] getBootstrapSpecifierAt(int i)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(getTagAt(i).isInvokeDynamic(), "Corrupted constant pool");
    }
    if (getTagAt(i).value() == 17) {
      return null;
    }
    int bsmSpec = extractLowShortFromInt(getIntAt(i));
    TypeArray operands = getOperands();
    if (operands == null) {
      return null;
    }
    int basePos = VM.getVM().buildIntFromShorts(operands.getShortAt(bsmSpec * 2 + 0), operands.getShortAt(bsmSpec * 2 + 1));
    
    int argv = basePos + INDY_ARGV_OFFSET;
    int argc = operands.getShortAt(basePos + INDY_ARGC_OFFSET);
    int endPos = argv + argc;
    short[] values = new short[endPos - basePos];
    for (int j = 0; j < values.length; j++) {
      values[j] = operands.getShortAt(basePos + j);
    }
    return values;
  }
  
  private static final String[] nameForTag = new String[0];
  
  private String nameForTag(int tag)
  {
    switch (tag)
    {
    case 1: 
      return "JVM_CONSTANT_Utf8";
    case 2: 
      return "JVM_CONSTANT_Unicode";
    case 3: 
      return "JVM_CONSTANT_Integer";
    case 4: 
      return "JVM_CONSTANT_Float";
    case 5: 
      return "JVM_CONSTANT_Long";
    case 6: 
      return "JVM_CONSTANT_Double";
    case 7: 
      return "JVM_CONSTANT_Class";
    case 8: 
      return "JVM_CONSTANT_String";
    case 9: 
      return "JVM_CONSTANT_Fieldref";
    case 10: 
      return "JVM_CONSTANT_Methodref";
    case 11: 
      return "JVM_CONSTANT_InterfaceMethodref";
    case 12: 
      return "JVM_CONSTANT_NameAndType";
    case 15: 
      return "JVM_CONSTANT_MethodHandle";
    case 16: 
      return "JVM_CONSTANT_MethodType";
    case 18: 
      return "JVM_CONSTANT_InvokeDynamic";
    case 17: 
      return "JVM_CONSTANT_InvokeDynamic/transitional";
    case 0: 
      return "JVM_CONSTANT_Invalid";
    case 100: 
      return "JVM_CONSTANT_UnresolvedClass";
    case 104: 
      return "JVM_CONSTANT_UnresolvedClassInError";
    case 101: 
      return "JVM_CONSTANT_ClassIndex";
    case 102: 
      return "JVM_CONSTANT_UnresolvedString";
    case 103: 
      return "JVM_CONSTANT_StringIndex";
    }
    throw new InternalError("Unknown tag: " + tag);
  }
  
  public void iterateFields(OopVisitor visitor, boolean doVMFields)
  {
    super.iterateFields(visitor, doVMFields);
    if (doVMFields)
    {
      visitor.doOop(tags, true);
      visitor.doOop(cache, true);
      visitor.doOop(poolHolder, true);
      
      int length = getLength();
      for (int index = 1; index < length; index++)
      {
        int ctag = getTags().getByteAt(index);
        switch (ctag)
        {
        case 3: 
        case 101: 
        case 103: 
          visitor.doInt(new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
          break;
        case 4: 
          visitor.doFloat(new FloatField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
          break;
        case 5: 
          visitor.doLong(new LongField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
          
          index++;
          break;
        case 6: 
          visitor.doDouble(new DoubleField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
          
          index++;
          break;
        case 1: 
        case 7: 
        case 100: 
        case 102: 
        case 104: 
          visitor.doOop(new OopField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
          break;
        case 9: 
        case 10: 
        case 11: 
        case 12: 
        case 15: 
        case 16: 
        case 17: 
        case 18: 
          visitor.doInt(new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
        }
      }
    }
  }
  
  public void writeBytes(OutputStream os)
    throws IOException
  {
    Map utf8ToIndex = new HashMap();
    DataOutputStream dos = new DataOutputStream(os);
    TypeArray tags = getTags();
    int len = getLength();
    int ci = 0;
    for (ci = 1; ci < len; ci++)
    {
      byte cpConstType = tags.getByteAt(ci);
      if (cpConstType == 1)
      {
        Symbol sym = getSymbolAt(ci);
        utf8ToIndex.put(sym.asString(), new Short((short)ci));
      }
      else if ((cpConstType == 5) || (cpConstType == 6))
      {
        ci++;
      }
    }
    for (ci = 1; ci < len; ci++)
    {
      int cpConstType = tags.getByteAt(ci);
      switch (cpConstType)
      {
      case 1: 
        dos.writeByte(cpConstType);
        Symbol sym = getSymbolAt(ci);
        dos.writeShort((short)(int)sym.getLength());
        dos.write(sym.asByteArray());
        
        break;
      case 2: 
        throw new IllegalArgumentException("Unicode constant!");
      case 3: 
        dos.writeByte(cpConstType);
        dos.writeInt(getIntAt(ci));
        
        break;
      case 4: 
        dos.writeByte(cpConstType);
        dos.writeFloat(getFloatAt(ci));
        
        break;
      case 5: 
        dos.writeByte(cpConstType);
        long l = getLongAt(ci);
        
        ci++;
        dos.writeLong(l);
        break;
      case 6: 
        dos.writeByte(cpConstType);
        dos.writeDouble(getDoubleAt(ci));
        
        ci++;
        break;
      case 7: 
        dos.writeByte(cpConstType);
        
        Klass refKls = (Klass)getObjAt(ci);
        String klassName = refKls.getName().asString();
        Short s = (Short)utf8ToIndex.get(klassName);
        dos.writeShort(s.shortValue());
        
        break;
      case 100: 
      case 104: 
        dos.writeByte(7);
        String klassName = getSymbolAt(ci).asString();
        Short s = (Short)utf8ToIndex.get(klassName);
        dos.writeShort(s.shortValue());
        
        break;
      case 8: 
        dos.writeByte(cpConstType);
        String str = OopUtilities.stringOopToString(getObjAt(ci));
        Short s = (Short)utf8ToIndex.get(str);
        dos.writeShort(s.shortValue());
        
        break;
      case 102: 
        dos.writeByte(8);
        String val = getSymbolAt(ci).asString();
        
        Short s = (Short)utf8ToIndex.get(val);
        dos.writeShort(s.shortValue());
        
        break;
      case 9: 
      case 10: 
      case 11: 
        dos.writeByte(cpConstType);
        int value = getIntAt(ci);
        short klassIndex = (short)extractLowShortFromInt(value);
        short nameAndTypeIndex = (short)extractHighShortFromInt(value);
        dos.writeShort(klassIndex);
        dos.writeShort(nameAndTypeIndex);
        
        break;
      case 12: 
        dos.writeByte(cpConstType);
        int value = getIntAt(ci);
        short nameIndex = (short)extractLowShortFromInt(value);
        short signatureIndex = (short)extractHighShortFromInt(value);
        dos.writeShort(nameIndex);
        dos.writeShort(signatureIndex);
        
        break;
      case 15: 
        dos.writeByte(cpConstType);
        int value = getIntAt(ci);
        short nameIndex = (short)extractLowShortFromInt(value);
        short signatureIndex = (short)extractHighShortFromInt(value);
        dos.writeShort(nameIndex);
        dos.writeShort(signatureIndex);
        
        break;
      case 17: 
      case 18: 
        dos.writeByte(cpConstType);
        int value = getIntAt(ci);
        short bsmIndex = (short)extractLowShortFromInt(value);
        short nameAndTypeIndex = (short)extractHighShortFromInt(value);
        dos.writeShort(bsmIndex);
        dos.writeShort(nameAndTypeIndex);
        
        break;
      default: 
        throw new InternalError("unknown tag: " + cpConstType);
      }
    }
    dos.flush();
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("ConstantPool for " + getPoolHolder().getName().asString());
  }
  
  public long getObjectSize()
  {
    return alignObjectSize(headerSize + getLength() * getElementSize());
  }
  
  private static int extractHighShortFromInt(int val)
  {
    return val >> 16 & 0xFFFF;
  }
  
  private static int extractLowShortFromInt(int val)
  {
    return val & 0xFFFF;
  }
}

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

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

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;
import sun.jvm.hotspot.utilities.Assert;

public class ConstantPoolCache
  extends Oop
{
  private static OopField constants;
  private static long baseOffset;
  private static long elementSize;
  private static CIntField length;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConstantPoolCache.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("constantPoolCacheOopDesc");
    constants = new OopField(type.getOopField("_constant_pool"), 0L);
    baseOffset = type.getSize();
    Type elType = db.lookupType("ConstantPoolCacheEntry");
    elementSize = elType.getSize();
    length = new CIntField(type.getCIntegerField("_length"), 0L);
  }
  
  ConstantPoolCache(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public boolean isConstantPoolCache()
  {
    return true;
  }
  
  public ConstantPool getConstants()
  {
    return (ConstantPool)constants.getValue(this);
  }
  
  public long getObjectSize()
  {
    return alignObjectSize(baseOffset + getLength() * elementSize);
  }
  
  public ConstantPoolCacheEntry getEntryAt(int i)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that((0 <= i) && (i < getLength()), "index out of bounds");
    }
    return new ConstantPoolCacheEntry(this, i);
  }
  
  public static boolean isSecondaryIndex(int i)
  {
    return i < 0;
  }
  
  public static int decodeSecondaryIndex(int i)
  {
    return isSecondaryIndex(i) ? i ^ 0xFFFFFFFF : i;
  }
  
  public static int encodeSecondaryIndex(int i)
  {
    return !isSecondaryIndex(i) ? i ^ 0xFFFFFFFF : i;
  }
  
  public ConstantPoolCacheEntry getSecondaryEntryAt(int i)
  {
    ConstantPoolCacheEntry e = new ConstantPoolCacheEntry(this, decodeSecondaryIndex(i));
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(e.isSecondaryEntry(), "must be a secondary entry");
    }
    return e;
  }
  
  public ConstantPoolCacheEntry getMainEntryAt(int i)
  {
    if (isSecondaryIndex(i)) {
      i = getSecondaryEntryAt(i).getMainEntryIndex();
    }
    ConstantPoolCacheEntry e = new ConstantPoolCacheEntry(this, i);
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(!e.isSecondaryEntry(), "must not be a secondary entry");
    }
    return e;
  }
  
  public int getIntAt(int entry, int fld)
  {
    long offset = baseOffset + entry * elementSize + fld * getHeap().getIntSize();
    return (int)getHandle().getCIntegerAt(offset, getHeap().getIntSize(), true);
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString());
  }
  
  public int getLength()
  {
    return (int)length.getValue(this);
  }
  
  public void iterateFields(OopVisitor visitor, boolean doVMFields)
  {
    super.iterateFields(visitor, doVMFields);
    if (doVMFields)
    {
      visitor.doOop(constants, true);
      for (int i = 0; i < getLength(); i++)
      {
        ConstantPoolCacheEntry entry = getEntryAt(i);
        entry.iterateFields(visitor);
      }
    }
  }
}

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

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

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

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;
import sun.jvm.hotspot.utilities.Assert;

public class ConstantPoolCacheEntry
{
  private static long size;
  private static long baseOffset;
  private static CIntegerField indices;
  private static sun.jvm.hotspot.types.OopField f1;
  private static CIntegerField f2;
  private static CIntegerField flags;
  private ConstantPoolCache cp;
  private long offset;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConstantPoolCacheEntry.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("ConstantPoolCacheEntry");
    size = type.getSize();
    
    indices = type.getCIntegerField("_indices");
    f1 = type.getOopField("_f1");
    f2 = type.getCIntegerField("_f2");
    flags = type.getCIntegerField("_flags");
    
    type = db.lookupType("constantPoolCacheOopDesc");
    baseOffset = type.getSize();
  }
  
  ConstantPoolCacheEntry(ConstantPoolCache cp, int index)
  {
    this.cp = cp;
    offset = (baseOffset + index * size);
  }
  
  public int getConstantPoolIndex()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(!isSecondaryEntry(), "must not be a secondary CP entry");
    }
    return (int)(getIndices() & 0xFFFF);
  }
  
  public boolean isSecondaryEntry()
  {
    return (getIndices() & 0xFFFF) == 0L;
  }
  
  public int getMainEntryIndex()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isSecondaryEntry(), "must be a secondary CP entry");
    }
    return (int)(getIndices() >>> 16);
  }
  
  private long getIndices()
  {
    return cp.getHandle().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned());
  }
  
  public Oop getF1()
  {
    return cp.getHeap().newOop(cp.getHandle().getOopHandleAt(f1.getOffset() + offset));
  }
  
  public int getF2()
  {
    return cp.getHandle().getJIntAt(f1.getOffset() + offset);
  }
  
  public int getFlags()
  {
    return cp.getHandle().getJIntAt(flags.getOffset() + offset);
  }
  
  static NamedFieldIdentifier f1FieldName = new NamedFieldIdentifier("_f1");
  static NamedFieldIdentifier f2FieldName = new NamedFieldIdentifier("_f2");
  static NamedFieldIdentifier flagsFieldName = new NamedFieldIdentifier("_flags");
  
  public void iterateFields(OopVisitor visitor)
  {
    visitor.doOop(new OopField(f1FieldName, f1.getOffset() + offset, true), true);
    visitor.doInt(new IntField(f2FieldName, f2.getOffset() + offset, true), true);
    visitor.doInt(new IntField(flagsFieldName, flags.getOffset() + offset, true), true);
  }
}

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

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

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;

public class ConstantPoolCacheKlass
  extends Klass
{
  private static long headerSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConstantPoolCacheKlass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("constantPoolCacheKlass");
    headerSize = type.getSize() + Oop.getHeaderSize();
  }
  
  ConstantPoolCacheKlass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public long getObjectSize()
  {
    return alignObjectSize(headerSize);
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("ConstantPoolCacheKlass");
  }
}

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

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

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;

public class ConstantPoolKlass
  extends Klass
{
  private static long headerSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConstantPoolKlass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("constantPoolKlass");
    headerSize = type.getSize() + Oop.getHeaderSize();
  }
  
  ConstantPoolKlass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public long getObjectSize()
  {
    return alignObjectSize(headerSize);
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("ConstantPoolKlass");
  }
}

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

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

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;
import sun.jvm.hotspot.utilities.Assert;

public class ConstMethod
  extends Oop
{
  private static int HAS_LINENUMBER_TABLE;
  private static int HAS_CHECKED_EXCEPTIONS;
  private static int HAS_LOCALVARIABLE_TABLE;
  private static OopField method;
  private static OopField exceptionTable;
  private static CIntField constMethodSize;
  private static ByteField flags;
  private static CIntField codeSize;
  private static CIntField nameIndex;
  private static CIntField signatureIndex;
  private static CIntField genericSignatureIndex;
  private static long bytecodeOffset;
  private static long checkedExceptionElementSize;
  private static long localVariableTableElementSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConstMethod.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("constMethodOopDesc");
    
    method = new OopField(type.getOopField("_method"), 0L);
    
    exceptionTable = new OopField(type.getOopField("_exception_table"), 0L);
    constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0L);
    flags = new ByteField(type.getJByteField("_flags"), 0L);
    
    HAS_LINENUMBER_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_linenumber_table").intValue();
    HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("constMethodOopDesc::_has_checked_exceptions").intValue();
    HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_localvariable_table").intValue();
    
    codeSize = new CIntField(type.getCIntegerField("_code_size"), 0L);
    nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0L);
    signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0L);
    genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0L);
    
    bytecodeOffset = type.getSize();
    
    type = db.lookupType("CheckedExceptionElement");
    checkedExceptionElementSize = type.getSize();
    
    type = db.lookupType("LocalVariableTableElement");
    localVariableTableElementSize = type.getSize();
  }
  
  ConstMethod(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public Method getMethod()
  {
    return (Method)method.getValue(this);
  }
  
  public TypeArray getExceptionTable()
  {
    return (TypeArray)exceptionTable.getValue(this);
  }
  
  public long getConstMethodSize()
  {
    return constMethodSize.getValue(this);
  }
  
  public byte getFlags()
  {
    return flags.getValue(this);
  }
  
  public long getCodeSize()
  {
    return codeSize.getValue(this);
  }
  
  public long getNameIndex()
  {
    return nameIndex.getValue(this);
  }
  
  public long getSignatureIndex()
  {
    return signatureIndex.getValue(this);
  }
  
  public long getGenericSignatureIndex()
  {
    return genericSignatureIndex.getValue(this);
  }
  
  public Symbol getName()
  {
    return getMethod().getName();
  }
  
  public Symbol getSignature()
  {
    return getMethod().getSignature();
  }
  
  public Symbol getGenericSignature()
  {
    return getMethod().getGenericSignature();
  }
  
  public int getBytecodeOrBPAt(int bci)
  {
    return getHandle().getJByteAt(bytecodeOffset + bci) & 0xFF;
  }
  
  public byte getBytecodeByteArg(int bci)
  {
    return (byte)getBytecodeOrBPAt(bci);
  }
  
  public short getBytecodeShortArg(int bci)
  {
    int hi = getBytecodeOrBPAt(bci);
    int lo = getBytecodeOrBPAt(bci + 1);
    return (short)(hi << 8 | lo);
  }
  
  public int getBytecodeIntArg(int bci)
  {
    int b4 = getBytecodeOrBPAt(bci);
    int b3 = getBytecodeOrBPAt(bci + 1);
    int b2 = getBytecodeOrBPAt(bci + 2);
    int b1 = getBytecodeOrBPAt(bci + 3);
    
    return b4 << 24 | b3 << 16 | b2 << 8 | b1;
  }
  
  public byte[] getByteCode()
  {
    byte[] bc = new byte[(int)getCodeSize()];
    for (int i = 0; i < bc.length; i++)
    {
      long offs = bytecodeOffset + i;
      bc[i] = getHandle().getJByteAt(offs);
    }
    return bc;
  }
  
  public long getObjectSize()
  {
    return getConstMethodSize() * getHeap().getOopSize();
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getHandle());
  }
  
  public void iterateFields(OopVisitor visitor, boolean doVMFields)
  {
    super.iterateFields(visitor, doVMFields);
    if (doVMFields)
    {
      visitor.doOop(method, true);
      visitor.doOop(exceptionTable, true);
      visitor.doCInt(constMethodSize, true);
      visitor.doByte(flags, true);
      visitor.doCInt(codeSize, true);
      visitor.doCInt(nameIndex, true);
      visitor.doCInt(signatureIndex, true);
      visitor.doCInt(genericSignatureIndex, true);
      visitor.doCInt(codeSize, true);
    }
  }
  
  public boolean hasLineNumberTable()
  {
    return (getFlags() & HAS_LINENUMBER_TABLE) != 0;
  }
  
  public int getLineNumberFromBCI(int bci)
  {
    if ((!VM.getVM().isCore()) && 
      (bci == -1)) {
      bci = 0;
    }
    if (isNative()) {
      return -1;
    }
    if (Assert.ASSERTS_ENABLED) {
      Assert.that((bci == 0) || ((0 <= bci) && (bci < getCodeSize())), "illegal bci");
    }
    int bestBCI = 0;
    int bestLine = -1;
    if (hasLineNumberTable())
    {
      CompressedLineNumberReadStream stream = new CompressedLineNumberReadStream(getHandle(), (int)offsetOfCompressedLineNumberTable());
      while (stream.readPair())
      {
        if (stream.bci() == bci) {
          return stream.line();
        }
        if ((stream.bci() < bci) && (stream.bci() >= bestBCI))
        {
          bestBCI = stream.bci();
          bestLine = stream.line();
        }
      }
    }
    return bestLine;
  }
  
  public LineNumberTableElement[] getLineNumberTable()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(hasLineNumberTable(), "should only be called if table is present");
    }
    int len = getLineNumberTableLength();
    CompressedLineNumberReadStream stream = new CompressedLineNumberReadStream(getHandle(), (int)offsetOfCompressedLineNumberTable());
    
    LineNumberTableElement[] ret = new LineNumberTableElement[len];
    for (int idx = 0; idx < len; idx++)
    {
      stream.readPair();
      ret[idx] = new LineNumberTableElement(stream.bci(), stream.line());
    }
    return ret;
  }
  
  public boolean hasLocalVariableTable()
  {
    return (getFlags() & HAS_LOCALVARIABLE_TABLE) != 0;
  }
  
  public Symbol getLocalVariableName(int bci, int slot)
  {
    return getMethod().getLocalVariableName(bci, slot);
  }
  
  public LocalVariableTableElement[] getLocalVariableTable()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(hasLocalVariableTable(), "should only be called if table is present");
    }
    LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()];
    long offset = offsetOfLocalVariableTable();
    for (int i = 0; i < ret.length; i++)
    {
      ret[i] = new LocalVariableTableElement(getHandle(), offset);
      offset += localVariableTableElementSize;
    }
    return ret;
  }
  
  public boolean hasCheckedExceptions()
  {
    return (getFlags() & HAS_CHECKED_EXCEPTIONS) != 0;
  }
  
  public CheckedExceptionElement[] getCheckedExceptions()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(hasCheckedExceptions(), "should only be called if table is present");
    }
    CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()];
    long offset = offsetOfCheckedExceptions();
    for (int i = 0; i < ret.length; i++)
    {
      ret[i] = new CheckedExceptionElement(getHandle(), offset);
      offset += checkedExceptionElementSize;
    }
    return ret;
  }
  
  private boolean isNative()
  {
    return getMethod().isNative();
  }
  
  private long offsetOfCodeEnd()
  {
    return bytecodeOffset + getCodeSize();
  }
  
  private long offsetOfCompressedLineNumberTable()
  {
    return offsetOfCodeEnd() + (isNative() ? 2L * VM.getVM().getAddressSize() : 0L);
  }
  
  private long offsetOfLastU2Element()
  {
    return getObjectSize() - 2L;
  }
  
  private long offsetOfCheckedExceptionsLength()
  {
    return offsetOfLastU2Element();
  }
  
  private int getCheckedExceptionsLength()
  {
    if (hasCheckedExceptions()) {
      return (int)getHandle().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2L, true);
    }
    return 0;
  }
  
  private long offsetOfCheckedExceptions()
  {
    long offset = offsetOfCheckedExceptionsLength();
    long length = getCheckedExceptionsLength();
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(length > 0L, "should only be called if table is present");
    }
    offset -= length * checkedExceptionElementSize;
    return offset;
  }
  
  private int getLineNumberTableLength()
  {
    int len = 0;
    if (hasLineNumberTable())
    {
      CompressedLineNumberReadStream stream = new CompressedLineNumberReadStream(getHandle(), (int)offsetOfCompressedLineNumberTable());
      while (stream.readPair()) {
        len++;
      }
    }
    return len;
  }
  
  private int getLocalVariableTableLength()
  {
    if (hasLocalVariableTable()) {
      return (int)getHandle().getCIntegerAt(offsetOfLocalVariableTableLength(), 2L, true);
    }
    return 0;
  }
  
  private long offsetOfLocalVariableTableLength()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(hasLocalVariableTable(), "should only be called if table is present");
    }
    if (hasCheckedExceptions()) {
      return offsetOfCheckedExceptions() - 2L;
    }
    return offsetOfLastU2Element();
  }
  
  private long offsetOfLocalVariableTable()
  {
    long offset = offsetOfLocalVariableTableLength();
    long length = getLocalVariableTableLength();
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(length > 0L, "should only be called if table is present");
    }
    offset -= length * localVariableTableElementSize;
    return offset;
  }
}

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

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

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;

public class ConstMethodKlass
  extends Klass
{
  private static long headerSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConstMethodKlass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("constMethodKlass");
    headerSize = type.getSize() + Oop.getHeaderSize();
  }
  
  ConstMethodKlass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public long getObjectSize()
  {
    return alignObjectSize(headerSize);
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("ConstMethodKlass");
  }
}

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

public class DefaultHeapVisitor
  implements HeapVisitor
{
  public void prologue(long usedSize) {}
  
  public boolean doObj(Oop obj)
  {
    return false;
  }
  
  public void epilogue() {}
}

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

public class DefaultOopVisitor
  implements OopVisitor
{
  private Oop obj;
  
  public void prologue() {}
  
  public void epilogue() {}
  
  public void setObj(Oop obj)
  {
    this.obj = obj;
  }
  
  public Oop getObj()
  {
    return obj;
  }
  
  public void doOop(OopField field, boolean isVMField) {}
  
  public void doOop(NarrowOopField field, boolean isVMField) {}
  
  public void doByte(ByteField field, boolean isVMField) {}
  
  public void doChar(CharField field, boolean isVMField) {}
  
  public void doBoolean(BooleanField field, boolean isVMField) {}
  
  public void doShort(ShortField field, boolean isVMField) {}
  
  public void doInt(IntField field, boolean isVMField) {}
  
  public void doLong(LongField field, boolean isVMField) {}
  
  public void doFloat(FloatField field, boolean isVMField) {}
  
  public void doDouble(DoubleField field, boolean isVMField) {}
  
  public void doCInt(CIntField field, boolean isVMField) {}
}

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

import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.types.JDoubleField;

public class DoubleField
  extends Field
{
  public DoubleField(FieldIdentifier id, long offset, boolean isVMField)
  {
    super(id, offset, isVMField);
  }
  
  public DoubleField(JDoubleField vmField, long startOffset)
  {
    super(new NamedFieldIdentifier(vmField.getName()), vmField.getOffset() + startOffset, true);
  }
  
  public DoubleField(InstanceKlass holder, int fieldArrayIndex)
  {
    super(holder, fieldArrayIndex);
  }
  
  public double getValue(Oop obj)
  {
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