sa-jdi

IGH_OFFSET;
  public static int GENERIC_SIGNATURE_INDEX_OFFSET;
  public static int NEXT_OFFSET;
  public static int IMPLEMENTORS_LIMIT;
  private static int CLASS_STATE_UNPARSABLE_BY_GC;
  private static int CLASS_STATE_ALLOCATED;
  private static int CLASS_STATE_LOADED;
  private static int CLASS_STATE_LINKED;
  private static int CLASS_STATE_BEING_INITIALIZED;
  private static int CLASS_STATE_FULLY_INITIALIZED;
  private static int CLASS_STATE_INITIALIZATION_ERROR;
  private static OopField arrayKlasses;
  private static OopField methods;
  private static OopField methodOrdering;
  private static OopField localInterfaces;
  private static OopField transitiveInterfaces;
  private static CIntField nofImplementors;
  private static OopField[] implementors;
  private static OopField fields;
  private static OopField constants;
  private static OopField classLoader;
  private static OopField protectionDomain;
  private static OopField signers;
  private static OopField sourceFileName;
  private static OopField sourceDebugExtension;
  private static OopField innerClasses;
  private static CIntField nonstaticFieldSize;
  private static CIntField staticFieldSize;
  private static CIntField staticOopFieldSize;
  private static CIntField nonstaticOopMapSize;
  private static CIntField isMarkedDependent;
  private static CIntField initState;
  private static CIntField vtableLen;
  private static CIntField itableLen;
  private static AddressField breakpoints;
  private static OopField genericSignature;
  private static CIntField majorVersion;
  private static CIntField minorVersion;
  private static long headerSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        InstanceKlass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("instanceKlass");
    arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
    methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
    methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
    localInterfaces = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
    transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
    nofImplementors = new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
    IMPLEMENTORS_LIMIT = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();
    implementors = new OopField[IMPLEMENTORS_LIMIT];
    for (int i = 0; i < IMPLEMENTORS_LIMIT; i++)
    {
      long arrayOffset = Oop.getHeaderSize() + i * db.getAddressSize();
      implementors[i] = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
    }
    fields = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
    constants = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
    classLoader = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
    protectionDomain = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
    signers = new OopField(type.getOopField("_signers"), Oop.getHeaderSize());
    sourceFileName = new OopField(type.getOopField("_source_file_name"), Oop.getHeaderSize());
    sourceDebugExtension = new OopField(type.getOopField("_source_debug_extension"), Oop.getHeaderSize());
    innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
    nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
    staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
    staticOopFieldSize = new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
    nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
    isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
    initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
    vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
    itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize());
    breakpoints = type.getAddressField("_breakpoints");
    genericSignature = new OopField(type.getOopField("_generic_signature"), Oop.getHeaderSize());
    majorVersion = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize());
    minorVersion = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize());
    headerSize = alignObjectOffset(Oop.getHeaderSize() + type.getSize());
    
    ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue();
    NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue();
    SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::signature_index_offset").intValue();
    INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue();
    LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue();
    HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue();
    GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue();
    NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue();
    
    CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
    CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
    CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
    CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
    CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("instanceKlass::being_initialized").intValue();
    CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
    CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("instanceKlass::initialization_error").intValue();
  }
  
  InstanceKlass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public static abstract interface InnerClassAttributeOffset
  {
    public static final int innerClassInnerClassInfoOffset = 0;
    public static final int innerClassOuterClassInfoOffset = 1;
    public static final int innerClassInnerNameOffset = 2;
    public static final int innerClassAccessFlagsOffset = 3;
    public static final int innerClassNextOffset = 4;
  }
  
  public static class ClassState
  {
    public static final ClassState UNPARSABLE_BY_GC = new ClassState("unparsable_by_gc");
    public static final ClassState ALLOCATED = new ClassState("allocated");
    public static final ClassState LOADED = new ClassState("loaded");
    public static final ClassState LINKED = new ClassState("linked");
    public static final ClassState BEING_INITIALIZED = new ClassState("beingInitialized");
    public static final ClassState FULLY_INITIALIZED = new ClassState("fullyInitialized");
    public static final ClassState INITIALIZATION_ERROR = new ClassState("initializationError");
    private String value;
    
    private ClassState(String value)
    {
      this.value = value;
    }
    
    public String toString()
    {
      return value;
    }
  }
  
  private int getInitStateAsInt()
  {
    return (int)initState.getValue(this);
  }
  
  public ClassState getInitState()
  {
    int state = getInitStateAsInt();
    if (state == CLASS_STATE_UNPARSABLE_BY_GC) {
      return ClassState.UNPARSABLE_BY_GC;
    }
    if (state == CLASS_STATE_ALLOCATED) {
      return ClassState.ALLOCATED;
    }
    if (state == CLASS_STATE_LOADED) {
      return ClassState.LOADED;
    }
    if (state == CLASS_STATE_LINKED) {
      return ClassState.LINKED;
    }
    if (state == CLASS_STATE_BEING_INITIALIZED) {
      return ClassState.BEING_INITIALIZED;
    }
    if (state == CLASS_STATE_FULLY_INITIALIZED) {
      return ClassState.FULLY_INITIALIZED;
    }
    if (state == CLASS_STATE_INITIALIZATION_ERROR) {
      return ClassState.INITIALIZATION_ERROR;
    }
    throw new RuntimeException("should not reach here");
  }
  
  public boolean isLoaded()
  {
    return getInitStateAsInt() >= CLASS_STATE_LOADED;
  }
  
  public boolean isLinked()
  {
    return getInitStateAsInt() >= CLASS_STATE_LINKED;
  }
  
  public boolean isInitialized()
  {
    return getInitStateAsInt() == CLASS_STATE_FULLY_INITIALIZED;
  }
  
  public boolean isNotInitialized()
  {
    return getInitStateAsInt() < CLASS_STATE_BEING_INITIALIZED;
  }
  
  public boolean isBeingInitialized()
  {
    return getInitStateAsInt() == CLASS_STATE_BEING_INITIALIZED;
  }
  
  public boolean isInErrorState()
  {
    return getInitStateAsInt() == CLASS_STATE_INITIALIZATION_ERROR;
  }
  
  public int getClassStatus()
  {
    int result = 0;
    if (isLinked()) {
      result |= 0x3;
    }
    if (isInitialized())
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(isLinked(), "Class status is not consistent");
      }
      result |= 0x4;
    }
    if (isInErrorState()) {
      result |= 0x8;
    }
    return result;
  }
  
  public static long getHeaderSize()
  {
    return headerSize;
  }
  
  public Klass getArrayKlasses()
  {
    return (Klass)arrayKlasses.getValue(this);
  }
  
  public ObjArray getMethods()
  {
    return (ObjArray)methods.getValue(this);
  }
  
  public TypeArray getMethodOrdering()
  {
    return (TypeArray)methodOrdering.getValue(this);
  }
  
  public ObjArray getLocalInterfaces()
  {
    return (ObjArray)localInterfaces.getValue(this);
  }
  
  public ObjArray getTransitiveInterfaces()
  {
    return (ObjArray)transitiveInterfaces.getValue(this);
  }
  
  public long nofImplementors()
  {
    return nofImplementors.getValue(this);
  }
  
  public Klass getImplementor()
  {
    return (Klass)implementors[0].getValue(this);
  }
  
  public Klass getImplementor(int i)
  {
    return (Klass)implementors[i].getValue(this);
  }
  
  public TypeArray getFields()
  {
    return (TypeArray)fields.getValue(this);
  }
  
  public ConstantPool getConstants()
  {
    return (ConstantPool)constants.getValue(this);
  }
  
  public Oop getClassLoader()
  {
    return classLoader.getValue(this);
  }
  
  public Oop getProtectionDomain()
  {
    return protectionDomain.getValue(this);
  }
  
  public ObjArray getSigners()
  {
    return (ObjArray)signers.getValue(this);
  }
  
  public Symbol getSourceFileName()
  {
    return (Symbol)sourceFileName.getValue(this);
  }
  
  public Symbol getSourceDebugExtension()
  {
    return (Symbol)sourceDebugExtension.getValue(this);
  }
  
  public TypeArray getInnerClasses()
  {
    return (TypeArray)innerClasses.getValue(this);
  }
  
  public long getNonstaticFieldSize()
  {
    return nonstaticFieldSize.getValue(this);
  }
  
  public long getStaticFieldSize()
  {
    return staticFieldSize.getValue(this);
  }
  
  public long getStaticOopFieldSize()
  {
    return staticOopFieldSize.getValue(this);
  }
  
  public long getNonstaticOopMapSize()
  {
    return nonstaticOopMapSize.getValue(this);
  }
  
  public boolean getIsMarkedDependent()
  {
    return isMarkedDependent.getValue(this) != 0L;
  }
  
  public long getVtableLen()
  {
    return vtableLen.getValue(this);
  }
  
  public long getItableLen()
  {
    return itableLen.getValue(this);
  }
  
  public Symbol getGenericSignature()
  {
    return (Symbol)genericSignature.getValue(this);
  }
  
  public long majorVersion()
  {
    return majorVersion.getValue(this);
  }
  
  public long minorVersion()
  {
    return minorVersion.getValue(this);
  }
  
  public long getSizeHelper()
  {
    int lh = getLayoutHelper();
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(lh > 0, "layout helper initialized for instance class");
    }
    return lh / VM.getVM().getAddressSize();
  }
  
  public long computeModifierFlags()
  {
    long access = getAccessFlags();
    
    TypeArray innerClassList = getInnerClasses();
    int length = innerClassList == null ? 0 : (int)innerClassList.getLength();
    if (length > 0)
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(length % 4 == 0, "just checking");
      }
      for (int i = 0; i < length; i += 4)
      {
        int ioff = innerClassList.getShortAt(i + 0);
        if (ioff != 0)
        {
          Oop classInfo = getConstants().getObjAt(ioff);
          Symbol name = null;
          if ((classInfo instanceof Klass)) {
            name = ((Klass)classInfo).getName();
          } else if ((classInfo instanceof Symbol)) {
            name = (Symbol)classInfo;
          } else {
            throw new RuntimeException("should not reach here");
          }
          if (name.equals(getName()))
          {
            access = innerClassList.getShortAt(i + 3);
            
            break;
          }
        }
      }
    }
    return access & 0xFFFFFFFFFFFFFFDF & 0x7FFF;
  }
  
  public boolean isInnerClassName(Symbol sym)
  {
    return isInInnerClasses(sym, false);
  }
  
  public boolean isInnerOrLocalClassName(Symbol sym)
  {
    return isInInnerClasses(sym, true);
  }
  
  private boolean isInInnerClasses(Symbol sym, boolean includeLocals)
  {
    TypeArray innerClassList = getInnerClasses();
    int length = innerClassList == null ? 0 : (int)innerClassList.getLength();
    if (length > 0)
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(length % 4 == 0, "just checking");
      }
      for (int i = 0; i < length; i += 4)
      {
        int ioff = innerClassList.getShortAt(i + 0);
        if (ioff != 0)
        {
          Oop iclassInfo = getConstants().getObjAt(ioff);
          Symbol innerName = null;
          if ((iclassInfo instanceof Klass)) {
            innerName = ((Klass)iclassInfo).getName();
          } else if ((iclassInfo instanceof Symbol)) {
            innerName = (Symbol)iclassInfo;
          } else {
            throw new RuntimeException("should not reach here");
          }
          Symbol myname = getName();
          int ooff = innerClassList.getShortAt(i + 1);
          
          int innerNameIndex = innerClassList.getShortAt(i + 2);
          if (ooff == 0)
          {
            if (includeLocals) {
              if ((innerName.equals(sym)) && (innerName.asString().startsWith(myname.asString()))) {
                return innerNameIndex != 0;
              }
            }
          }
          else
          {
            Oop oclassInfo = getConstants().getObjAt(ooff);
            Symbol outerName = null;
            if ((oclassInfo instanceof Klass)) {
              outerName = ((Klass)oclassInfo).getName();
            } else if ((oclassInfo instanceof Symbol)) {
              outerName = (Symbol)oclassInfo;
            } else {
              throw new RuntimeException("should not reach here");
            }
            if ((outerName.equals(myname)) && (innerName.equals(sym))) {
              return true;
            }
          }
        }
      }
      return false;
    }
    return false;
  }
  
  public boolean implementsInterface(Klass k)
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(k.isInterface(), "should not reach here");
    }
    ObjArray interfaces = getTransitiveInterfaces();
    int len = (int)interfaces.getLength();
    for (int i = 0; i < len; i++) {
      if (interfaces.getObjAt(i).equals(k)) {
        return true;
      }
    }
    return false;
  }
  
  boolean computeSubtypeOf(Klass k)
  {
    if (k.isInterface()) {
      return implementsInterface(k);
    }
    return super.computeSubtypeOf(k);
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("InstanceKlass for " + getName().asString());
  }
  
  public void iterateFields(OopVisitor visitor, boolean doVMFields)
  {
    super.iterateFields(visitor, doVMFields);
    if (doVMFields)
    {
      visitor.doOop(arrayKlasses, true);
      visitor.doOop(methods, true);
      visitor.doOop(methodOrdering, true);
      visitor.doOop(localInterfaces, true);
      visitor.doOop(transitiveInterfaces, true);
      visitor.doCInt(nofImplementors, true);
      for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) {
        visitor.doOop(implementors[i], true);
      }
      visitor.doOop(fields, true);
      visitor.doOop(constants, true);
      visitor.doOop(classLoader, true);
      visitor.doOop(protectionDomain, true);
      visitor.doOop(signers, true);
      visitor.doOop(sourceFileName, true);
      visitor.doOop(innerClasses, true);
      visitor.doCInt(nonstaticFieldSize, true);
      visitor.doCInt(staticFieldSize, true);
      visitor.doCInt(staticOopFieldSize, true);
      visitor.doCInt(nonstaticOopMapSize, true);
      visitor.doCInt(isMarkedDependent, true);
      visitor.doCInt(initState, true);
      visitor.doCInt(vtableLen, true);
      visitor.doCInt(itableLen, true);
    }
    TypeArray fields = getFields();
    int length = (int)fields.getLength();
    for (int index = 0; index < length; index += NEXT_OFFSET)
    {
      short accessFlags = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
      short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
      FieldType type = new FieldType((Symbol)getConstants().getObjAt(signatureIndex));
      AccessFlags access = new AccessFlags(accessFlags);
      if (access.isStatic()) {
        visitField(visitor, type, index);
      }
    }
  }
  
  public Klass getJavaSuper()
  {
    return getSuper();
  }
  
  public void iterateNonStaticFields(OopVisitor visitor)
  {
    if (getSuper() != null) {
      ((InstanceKlass)getSuper()).iterateNonStaticFields(visitor);
    }
    TypeArray fields = getFields();
    
    int length = (int)fields.getLength();
    for (int index = 0; index < length; index += NEXT_OFFSET)
    {
      short accessFlags = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
      short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
      
      FieldType type = new FieldType((Symbol)getConstants().getObjAt(signatureIndex));
      AccessFlags access = new AccessFlags(accessFlags);
      if (!access.isStatic()) {
        visitField(visitor, type, index);
      }
    }
  }
  
  public Field findLocalField(Symbol name, Symbol sig)
  {
    TypeArray fields = getFields();
    int n = (int)fields.getLength();
    ConstantPool cp = getConstants();
    for (int i = 0; i < n; i += NEXT_OFFSET)
    {
      int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET);
      int sigIndex = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET);
      Symbol f_name = cp.getSymbolAt(nameIndex);
      Symbol f_sig = cp.getSymbolAt(sigIndex);
      if ((name.equals(f_name)) && (sig.equals(f_sig))) {
        return newField(i);
      }
    }
    return null;
  }
  
  public Field findInterfaceField(Symbol name, Symbol sig)
  {
    ObjArray interfaces = getLocalInterfaces();
    int n = (int)interfaces.getLength();
    for (int i = 0; i < n; i++)
    {
      InstanceKlass intf1 = (InstanceKlass)interfaces.getObjAt(i);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(intf1.isInterface(), "just checking type");
      }
      Field f = intf1.findLocalField(name, sig);
      if (f != null)
      {
        if (Assert.ASSERTS_ENABLED) {
          Assert.that(f.getAccessFlagsObj().isStatic(), "interface field must be static");
        }
        return f;
      }
      f = intf1.findInterfaceField(name, sig);
      if (f != null) {
        return f;
      }
    }
    return null;
  }
  
  public Field findField(Symbol name, Symbol sig)
  {
    Field f = findLocalField(name, sig);
    if (f != null) {
      return f;
    }
    f = findInterfaceField(name, sig);
    if (f != null) {
      return f;
    }
    InstanceKlass supr = (InstanceKlass)getSuper();
    if (supr != null) {
      return supr.findField(name, sig);
    }
    return null;
  }
  
  public Field findField(String name, String sig)
  {
    SymbolTable symbols = VM.getVM().getSymbolTable();
    Symbol nameSym = symbols.probe(name);
    Symbol sigSym = symbols.probe(sig);
    if ((nameSym == null) || (sigSym == null)) {
      return null;
    }
    return findField(nameSym, sigSym);
  }
  
  public Field findFieldDbg(String name, String sig)
  {
    return findField(name, sig);
  }
  
  public Field getFieldByIndex(int fieldArrayIndex)
  {
    return newField(fieldArrayIndex);
  }
  
  public List getImmediateFields()
  {
    TypeArray fields = getFields();
    
    int length = (int)fields.getLength();
    List immediateFields = new ArrayList(length / NEXT_OFFSET);
    for (int index = 0; index < length; index += NEXT_OFFSET) {
      immediateFields.add(getFieldByIndex(index));
    }
    return immediateFields;
  }
  
  public List getAllFields()
  {
    List allFields = getImmediateFields();
    
    ObjArray interfaces = getTransitiveInterfaces();
    int n = (int)interfaces.getLength();
    for (int i = 0; i < n; i++)
    {
      InstanceKlass intf1 = (InstanceKlass)interfaces.getObjAt(i);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(intf1.isInterface(), "just checking type");
      }
      allFields.addAll(intf1.getImmediateFields());
    }
    if (!isInterface())
    {
      InstanceKlass supr;
      if ((supr = (InstanceKlass)getSuper()) != null) {
        allFields.addAll(supr.getImmediateFields());
      }
    }
    return allFields;
  }
  
  public List getImmediateMethods()
  {
    ObjArray methods = getMethods();
    int length = (int)methods.getLength();
    Object[] tmp = new Object[length];
    
    TypeArray methodOrdering = getMethodOrdering();
    if (methodOrdering.getLength() != length) {
      for (int index = 0; index < length; index++) {
        tmp[index] = methods.getObjAt(index);
      }
    } else {
      for (int index = 0; index < length; index++)
      {
        int originalIndex = getMethodOrdering().getIntAt(index);
        tmp[originalIndex] = methods.getObjAt(index);
      }
    }
    return Arrays.asList(tmp);
  }
  
  public List getDirectImplementedInterfaces()
  {
    ObjArray interfaces = getLocalInterfaces();
    int length = (int)interfaces.getLength();
    List directImplementedInterfaces = new ArrayList(length);
    for (int index = 0; index < length; index++) {
      directImplementedInterfaces.add(interfaces.getObjAt(index));
    }
    return directImplementedInterfaces;
  }
  
  public long getObjectSize()
  {
    long bodySize = alignObjectOffset(getVtableLen() * getHeap().getOopSize()) + alignObjectOffset(getItableLen() * getHeap().getOopSize()) + (getStaticFieldSize() + getNonstaticOopMapSize()) * getHeap().getOopSize();
    
    return alignObjectSize(headerSize + bodySize);
  }
  
  public Klass arrayKlassImpl(boolean orNull, int n)
  {
    if (getArrayKlasses() == null) {
      return null;
    }
    ObjArrayKlass oak = (ObjArrayKlass)getArrayKlasses();
    if (orNull) {
      return oak.arrayKlassOrNull(n);
    }
    return oak.arrayKlass(n);
  }
  
  public Klass arrayKlassImpl(boolean orNull)
  {
    return arrayKlassImpl(orNull, 1);
  }
  
  public String signature()
  {
    return "L" + super.signature() + ";";
  }
  
  public Method findMethod(String name, String sig)
  {
    SymbolTable syms = VM.getVM().getSymbolTable();
    Symbol nameSym = syms.probe(name);
    Symbol sigSym = syms.probe(sig);
    if ((nameSym == null) || (sigSym == null)) {
      return null;
    }
    return findMethod(nameSym, sigSym);
  }
  
  public Method findMethod(Symbol name, Symbol sig)
  {
    return findMethod(getMethods(), name, sig);
  }
  
  public BreakpointInfo getBreakpoints()
  {
    Address addr = getHandle().getAddressAt(Oop.getHeaderSize() + breakpoints.getOffset());
    return (BreakpointInfo)VMObjectFactory.newObject(BreakpointInfo.class, addr);
  }
  
  private void visitField(OopVisitor visitor, FieldType type, int index)
  {
    Field f = newField(index);
    if (type.isOop())
    {
      visitor.doOop((OopField)f, false);
      return;
    }
    if (type.isByte())
    {
      visitor.doByte((ByteField)f, false);
      return;
    }
    if (type.isChar())
    {
      visitor.doChar((CharField)f, false);
      return;
    }
    if (type.isDouble())
    {
      visitor.doDouble((DoubleField)f, false);
      return;
    }
    if (type.isFloat())
    {
      visitor.doFloat((FloatField)f, false);
      return;
    }
    if (type.isInt())
    {
      visitor.doInt((IntField)f, false);
      return;
    }
    if (type.isLong())
    {
      visitor.doLong((LongField)f, false);
      return;
    }
    if (type.isShort())
    {
      visitor.doShort((ShortField)f, false);
      return;
    }
    if (type.isBoolean())
    {
      visitor.doBoolean((BooleanField)f, false);
      return;
    }
  }
  
  private Field newField(int index)
  {
    TypeArray fields = getFields();
    short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
    FieldType type = new FieldType((Symbol)getConstants().getObjAt(signatureIndex));
    if (type.isOop())
    {
      if (VM.getVM().isCompressedOopsEnabled()) {
        return new NarrowOopField(this, index);
      }
      return new OopField(this, index);
    }
    if (type.isByte()) {
      return new ByteField(this, index);
    }
    if (type.isChar()) {
      return new CharField(this, index);
    }
    if (type.isDouble()) {
      return new DoubleField(this, index);
    }
    if (type.isFloat()) {
      return new FloatField(this, index);
    }
    if (type.isInt()) {
      return new IntField(this, index);
    }
    if (type.isLong()) {
      return new LongField(this, index);
    }
    if (type.isShort()) {
      return new ShortField(this, index);
    }
    if (type.isBoolean()) {
      return new BooleanField(this, index);
    }
    throw new RuntimeException("Illegal field type at index " + index);
  }
  
  private static Method findMethod(ObjArray methods, Symbol name, Symbol signature)
  {
    int len = (int)methods.getLength();
    
    int l = 0;
    int h = len - 1;
    while (l <= h)
    {
      int mid = l + h >> 1;
      Method m = (Method)methods.getObjAt(mid);
      int res = m.getName().fastCompare(name);
      if (res == 0)
      {
        if (m.getSignature().equals(signature)) {
          return m;
        }
        for (int i = mid - 1; i >= l; i--)
        {
          Method m1 = (Method)methods.getObjAt(i);
          if (!m1.getName().equals(name)) {
            break;
          }
          if (m1.getSignature().equals(signature)) {
            return m1;
          }
        }
        for (i = mid + 1; i <= h; i++)
        {
          Method m1 = (Method)methods.getObjAt(i);
          if (!m1.getName().equals(name)) {
            break;
          }
          if (m1.getSignature().equals(signature)) {
            return m1;
          }
        }
        if (Assert.ASSERTS_ENABLED)
        {
          int index = linearSearch(methods, name, signature);
          if (index != -1) {
            throw new DebuggerException("binary search bug: should have found entry " + index);
          }
        }
        return null;
      }
      if (res < 0) {
        l = mid + 1;
      } else {
        h = mid - 1;
      }
    }
    if (Assert.ASSERTS_ENABLED)
    {
      int index = linearSearch(methods, name, signature);
      if (index != -1) {
        throw new DebuggerException("binary search bug: should have found entry " + index);
      }
    }
    return null;
  }
  
  private static int linearSearch(ObjArray methods, Symbol name, Symbol signature)
  {
    int len = (int)methods.getLength();
    for (int index = 0; index < len; index++)
    {
      Method m = (Method)methods.getObjAt(index);
      if ((m.getSignature().equals(signature)) && (m.getName().equals(name))) {
        return index;
      }
    }
    return -1;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.InstanceKlass
 * 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 InstanceKlassKlass$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    InstanceKlassKlass.access$000(VM.getVM().getTypeDataBase());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.InstanceKlassKlass.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 InstanceKlassKlass
  extends KlassKlass
{
  private static long headerSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        InstanceKlassKlass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("instanceKlassKlass");
    headerSize = type.getSize() + Oop.getHeaderSize();
  }
  
  InstanceKlassKlass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public long getObjectSize()
  {
    return alignObjectSize(headerSize);
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("InstanceKlassKlass");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.InstanceKlassKlass
 * 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.JIntField;

public class IntField
  extends Field
{
  public IntField(FieldIdentifier id, long offset, boolean isVMField)
  {
    super(id, offset, isVMField);
  }
  
  public IntField(JIntField vmField, long startOffset)
  {
    super(new NamedFieldIdentifier(vmField.getName()), vmField.getOffset() + startOffset, true);
  }
  
  public IntField(InstanceKlass holder, int fieldArrayIndex)
  {
    super(holder, fieldArrayIndex);
  }
  
  public int getValue(Oop obj)
  {
    return obj.getHandle().getJIntAt(getOffset());
  }
  
  public void setValue(Oop obj, int value)
    throws MutationException
  {}
}

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

public abstract interface JVMDIClassStatus
{
  public static final int VERIFIED = 1;
  public static final int PREPARED = 2;
  public static final int INITIALIZED = 4;
  public static final int ERROR = 8;
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.JVMDIClassStatus
 * 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 Klass$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    Klass.access$000(VM.getVM().getTypeDataBase());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.Klass.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.ClassConstants;
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 Klass
  extends Oop
  implements ClassConstants
{
  public static int LH_INSTANCE_SLOW_PATH_BIT;
  public static int LH_LOG2_ELEMENT_SIZE_SHIFT;
  public static int LH_ELEMENT_TYPE_SHIFT;
  public static int LH_HEADER_SIZE_SHIFT;
  public static int LH_ARRAY_TAG_SHIFT;
  public static int LH_ARRAY_TAG_TYPE_VALUE;
  public static int LH_ARRAY_TAG_OBJ_VALUE;
  private static OopField javaMirror;
  private static OopField superField;
  private static IntField layoutHelper;
  private static OopField name;
  private static CIntField accessFlags;
  private static OopField subklass;
  private static OopField nextSibling;
  private static CIntField allocCount;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        Klass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("Klass");
    javaMirror = new OopField(type.getOopField("_java_mirror"), Oop.getHeaderSize());
    superField = new OopField(type.getOopField("_super"), Oop.getHeaderSize());
    layoutHelper = new IntField(type.getJIntField("_layout_helper"), Oop.getHeaderSize());
    name = new OopField(type.getOopField("_name"), Oop.getHeaderSize());
    accessFlags = new CIntField(type.getCIntegerField("_access_flags"), Oop.getHeaderSize());
    subklass = new OopField(type.getOopField("_subklass"), Oop.getHeaderSize());
    nextSibling = new OopField(type.getOopField("_next_sibling"), Oop.getHeaderSize());
    allocCount = new CIntField(type.getCIntegerField("_alloc_count"), Oop.getHeaderSize());
    
    LH_INSTANCE_SLOW_PATH_BIT = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue();
    LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue();
    LH_ELEMENT_TYPE_SHIFT = db.lookupIntConstant("Klass::_lh_element_type_shift").intValue();
    LH_HEADER_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_header_size_shift").intValue();
    LH_ARRAY_TAG_SHIFT = db.lookupIntConstant("Klass::_lh_array_tag_shift").intValue();
    LH_ARRAY_TAG_TYPE_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_type_value").intValue();
    LH_ARRAY_TAG_OBJ_VALUE = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue();
  }
  
  Klass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public int getClassStatus()
  {
    return 0;
  }
  
  public boolean isKlass()
  {
    return true;
  }
  
  public Instance getJavaMirror()
  {
    return (Instance)javaMirror.getValue(this);
  }
  
  public Klass getSuper()
  {
    return (Klass)superField.getValue(this);
  }
  
  public Klass getJavaSuper()
  {
    return null;
  }
  
  public int getLayoutHelper()
  {
    return layoutHelper.getValue(this);
  }
  
  public Symbol getName()
  {
    return (Symbol)name.getValue(this);
  }
  
  public long getAccessFlags()
  {
    return accessFlags.getValue(this);
  }
  
  public AccessFlags getAccessFlagsObj()
  {
    return new AccessFlags(getAccessFlags());
  }
  
  public Klass getSubklassKlass()
  {
    return (Klass)subklass.getValue(this);
  }
  
  public Klass getNextSiblingKlass()
  {
    return (Klass)nextSibling.getValue(this);
  }
  
  public long getAllocCount()
  {
    return allocCount.getValue(this);
  }
  
  public long computeModifierFlags()
  {
    return 0L;
  }
  
  public final long getClassModifiers()
  {
    long flags = computeModifierFlags();
    if (isSuper()) {
      flags |= 0x20;
    }
    return flags;
  }
  
  public boolean isSubclassOf(Klass k)
  {
    if (k != null)
    {
      Klass t = this;
      while (t != null)
      {
        if (t.equals(k)) {
          return true;
        }
        t = t.getSuper();
      }
    }
    return false;
  }
  
  public boolean isSubtypeOf(Klass k)
  {
    return computeSubtypeOf(k);
  }
  
  boolean computeSubtypeOf(Klass k)
  {
    return isSubclassOf(k);
  }
  
  public Klass lca(Klass k2)
  {
    Klass k1 = this;
    for (;;)
    {
      if (k1.isSubtypeOf(k2)) {
        return k2;
      }
      if (k2.isSubtypeOf(k1)) {
        return k1;
      }
      k1 = k1.getSuper();
      k2 = k2.getSuper();
    }
  }
  
  public void printValueOn(PrintStream tty)
  {
    tty.print("Klass");
  }
  
  public void iterateFields(OopVisitor visitor, boolean doVMFields)
  {
    super.iterateFields(visitor, doVMFields);
    if (doVMFields)
    {
      visitor.doOop(javaMirror, true);
      visitor.doOop(superField, true);
      visitor.doInt(layoutHelper, true);
      visitor.doOop(name, true);
      visitor.doCInt(accessFlags, true);
      visitor.doOop(subklass, true);
      visitor.doOop(nextSibling, true);
      visitor.doCInt(allocCount, true);
    }
  }
  
  public long getObjectSize()
  {
    throw new RuntimeException("should not reach here");
  }
  
  public Klass arrayKlass(int rank)
  {
    return arrayKlassImpl(false, rank);
  }
  
  public Klass arrayKlass()
  {
    return arrayKlassImpl(false);
  }
  
  public Klass arrayKlassOrNull(int rank)
  {
    return arrayKlassImpl(true, rank);
  }
  
  public Klass arrayKlassOrNull()
  {
    return arrayKlassImpl(true);
  }
  
  public Klass arrayKlassImpl(boolean orNull, int rank)
  {
    throw new RuntimeException("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass");
  }
  
  public Klass arrayKlassImpl(boolean orNull)
  {
    throw new RuntimeException("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass");
  }
  
  public String signature()
  {
    return getName().asString();
  }
  
  public boolean isPublic()
  {
    return getAccessFlagsObj().isPublic();
  }
  
  public boolean isFinal()
  {
    return getAccessFlagsObj().isFinal();
  }
  
  public boolean isInterface()
  {
    return getAccessFlagsObj().isInterface();
  }
  
  public boolean isAbstract()
  {
    return getAccessFlagsObj().isAbstract();
  }
  
  public boolean isSuper()
  {
    return getAccessFlagsObj().isSuper();
  }
  
  public boolean isSynthetic()
  {
    return getAccessFlagsObj().isSynthetic();
  }
  
  public boolean hasFinalizer()
  {
    return getAccessFlagsObj().hasFinalizer();
  }
  
  public boolean isCloneable()
  {
    return getAccessFlagsObj().isCloneable();
  }
  
  public boolean hasVanillaConstructor()
  {
    return getAccessFlagsObj().hasVanillaConstructor();
  }
  
  public boolean hasMirandaMethods()
  {
    return getAccessFlagsObj().hasMirandaMethods();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.Klass
 * 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 KlassKlass$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    KlassKlass.access$000(VM.getVM().getTypeDataBase());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.oops.KlassKlass.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 KlassKlass
  extends Klass
{
  private static long headerSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        KlassKlass.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
    throws WrongTypeException
  {
    Type type = db.lookupType("klassKlass");
    headerSize = type.getSize() + Oop.getHeaderSize();
  }
  
  KlassKlass(OopHandle handle, ObjectHeap heap)
  {
    super(handle, heap);
  }
  
  public long getObjectSize()
  {
    
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