sa-jdi

)value;
  }
  
  public char charValue()
  {
    return (char)(int)value;
  }
  
  public short shortValue()
  {
    return (short)(int)value;
  }
  
  public int intValue()
  {
    return (int)value;
  }
  
  public long longValue()
  {
    return value;
  }
  
  public float floatValue()
  {
    return (float)value;
  }
  
  public double doubleValue()
  {
    return value;
  }
  
  byte checkedByteValue()
    throws InvalidTypeException
  {
    if ((value > 127L) || (value < -128L)) {
      throw new InvalidTypeException("Can't convert " + value + " to byte");
    }
    return super.checkedByteValue();
  }
  
  char checkedCharValue()
    throws InvalidTypeException
  {
    if ((value > 65535L) || (value < 0L)) {
      throw new InvalidTypeException("Can't convert " + value + " to char");
    }
    return super.checkedCharValue();
  }
  
  short checkedShortValue()
    throws InvalidTypeException
  {
    if ((value > 32767L) || (value < -32768L)) {
      throw new InvalidTypeException("Can't convert " + value + " to short");
    }
    return super.checkedShortValue();
  }
  
  int checkedIntValue()
    throws InvalidTypeException
  {
    if ((value > 2147483647L) || (value < -2147483648L)) {
      throw new InvalidTypeException("Can't convert " + value + " to int");
    }
    return super.checkedIntValue();
  }
  
  public String toString()
  {
    return "" + value;
  }
}

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

import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.ClassNotLoadedException;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.Type;
import com.sun.jdi.VirtualMachine;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import sun.jvm.hotspot.oops.AccessFlags;
import sun.jvm.hotspot.oops.Symbol;

public abstract class MethodImpl
  extends TypeComponentImpl
  implements com.sun.jdi.Method
{
  private JNITypeParser signatureParser;
  protected sun.jvm.hotspot.oops.Method saMethod;
  
  abstract int argSlotCount()
    throws AbsentInformationException;
  
  abstract List allLineLocations(SDE.Stratum paramStratum, String paramString)
    throws AbsentInformationException;
  
  abstract List locationsOfLine(SDE.Stratum paramStratum, String paramString, int paramInt)
    throws AbsentInformationException;
  
  static MethodImpl createMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, sun.jvm.hotspot.oops.Method saMethod)
  {
    if ((saMethod.isNative()) || (saMethod.isAbstract())) {
      return new NonConcreteMethodImpl(vm, declaringType, saMethod);
    }
    return new ConcreteMethodImpl(vm, declaringType, saMethod);
  }
  
  MethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, sun.jvm.hotspot.oops.Method saMethod)
  {
    super(vm, declaringType);
    this.saMethod = saMethod;
    getParser();
  }
  
  private JNITypeParser getParser()
  {
    if (signatureParser == null)
    {
      Symbol sig1 = saMethod.getSignature();
      signature = sig1.asString();
      signatureParser = new JNITypeParser(signature);
    }
    return signatureParser;
  }
  
  sun.jvm.hotspot.oops.Method ref()
  {
    return saMethod;
  }
  
  public String genericSignature()
  {
    Symbol genSig = saMethod.getGenericSignature();
    return genSig != null ? genSig.asString() : null;
  }
  
  public String returnTypeName()
  {
    return getParser().typeName();
  }
  
  public Type returnType()
    throws ClassNotLoadedException
  {
    return findType(getParser().signature());
  }
  
  private Type findType(String signature)
    throws ClassNotLoadedException
  {
    ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
    return enclosing.findType(signature);
  }
  
  public List argumentTypeNames()
  {
    return getParser().argumentTypeNames();
  }
  
  List argumentSignatures()
  {
    return getParser().argumentSignatures();
  }
  
  Type argumentType(int index)
    throws ClassNotLoadedException
  {
    ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
    String signature = (String)argumentSignatures().get(index);
    return enclosing.findType(signature);
  }
  
  public List argumentTypes()
    throws ClassNotLoadedException
  {
    int size = argumentSignatures().size();
    ArrayList types = new ArrayList(size);
    for (int i = 0; i < size; i++)
    {
      Type type = argumentType(i);
      types.add(type);
    }
    return types;
  }
  
  public boolean isAbstract()
  {
    return saMethod.isAbstract();
  }
  
  public boolean isBridge()
  {
    return saMethod.isBridge();
  }
  
  public boolean isSynchronized()
  {
    return saMethod.isSynchronized();
  }
  
  public boolean isNative()
  {
    return saMethod.isNative();
  }
  
  public boolean isVarArgs()
  {
    return saMethod.isVarArgs();
  }
  
  public boolean isConstructor()
  {
    return saMethod.isConstructor();
  }
  
  public boolean isStaticInitializer()
  {
    return saMethod.isStaticInitializer();
  }
  
  public boolean isObsolete()
  {
    return saMethod.isObsolete();
  }
  
  public final List allLineLocations()
    throws AbsentInformationException
  {
    return allLineLocations(vm.getDefaultStratum(), null);
  }
  
  public List allLineLocations(String stratumID, String sourceName)
    throws AbsentInformationException
  {
    return allLineLocations(declaringType.stratum(stratumID), sourceName);
  }
  
  public final List locationsOfLine(int lineNumber)
    throws AbsentInformationException
  {
    return locationsOfLine(vm.getDefaultStratum(), null, lineNumber);
  }
  
  public List locationsOfLine(String stratumID, String sourceName, int lineNumber)
    throws AbsentInformationException
  {
    return locationsOfLine(declaringType.stratum(stratumID), sourceName, lineNumber);
  }
  
  LineInfo codeIndexToLineInfo(SDE.Stratum stratum, long codeIndex)
  {
    if (stratum.isJava()) {
      return new BaseLineInfo(-1, declaringType);
    }
    return new StratumLineInfo(stratum.id(), -1, null, null);
  }
  
  public boolean equals(Object obj)
  {
    if ((obj != null) && ((obj instanceof MethodImpl)))
    {
      MethodImpl other = (MethodImpl)obj;
      return (declaringType().equals(other.declaringType())) && (ref().equals(other.ref())) && (super.equals(obj));
    }
    return false;
  }
  
  public int compareTo(Object object)
  {
    com.sun.jdi.Method method = (com.sun.jdi.Method)object;
    ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();
    int rc = declaringType.compareTo(method.declaringType());
    if (rc == 0) {
      rc = declaringType.indexOf(this) - declaringType.indexOf(method);
    }
    return rc;
  }
  
  public String toString()
  {
    StringBuffer sb = new StringBuffer();
    sb.append(declaringType().name());
    sb.append(".");
    sb.append(name());
    sb.append("(");
    boolean first = true;
    for (Iterator it = argumentTypeNames().iterator(); it.hasNext();)
    {
      if (!first) {
        sb.append(", ");
      }
      sb.append((String)it.next());
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }
  
  public String name()
  {
    Symbol myName = saMethod.getName();
    return myName.asString();
  }
  
  public int modifiers()
  {
    return saMethod.getAccessFlagsObj().getStandardFlags();
  }
  
  public boolean isPackagePrivate()
  {
    return saMethod.isPackagePrivate();
  }
  
  public boolean isPrivate()
  {
    return saMethod.isPrivate();
  }
  
  public boolean isProtected()
  {
    return saMethod.isProtected();
  }
  
  public boolean isPublic()
  {
    return saMethod.isPublic();
  }
  
  public boolean isStatic()
  {
    return saMethod.isStatic();
  }
  
  public boolean isSynthetic()
  {
    return saMethod.isSynthetic();
  }
  
  public boolean isFinal()
  {
    return saMethod.isFinal();
  }
  
  public int hashCode()
  {
    return saMethod.hashCode();
  }
}

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

import com.sun.jdi.Mirror;
import com.sun.jdi.VirtualMachine;

abstract class MirrorImpl
  implements Mirror
{
  protected VirtualMachineImpl vm;
  
  MirrorImpl(VirtualMachine aVm)
  {
    vm = ((VirtualMachineImpl)aVm);
  }
  
  public VirtualMachine virtualMachine()
  {
    return vm;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj != null) && ((obj instanceof Mirror)))
    {
      Mirror other = (Mirror)obj;
      return vm.equals(other.virtualMachine());
    }
    return false;
  }
  
  public int hashCode()
  {
    return vm.hashCode();
  }
}

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

import com.sun.jdi.InvalidStackFrameException;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.VirtualMachine;

public class MonitorInfoImpl
  extends MirrorImpl
{
  private boolean isValid = true;
  ObjectReference monitor;
  ThreadReference thread;
  int stack_depth;
  
  MonitorInfoImpl(VirtualMachine vm, ObjectReference mon, ThreadReference thread, int dpth)
  {
    super(vm);
    monitor = mon;
    this.thread = thread;
    stack_depth = dpth;
  }
  
  private void validateMonitorInfo()
  {
    if (!isValid) {
      throw new InvalidStackFrameException("Thread has been resumed");
    }
  }
  
  public ObjectReference monitor()
  {
    validateMonitorInfo();
    return monitor;
  }
  
  public int stackDepth()
  {
    validateMonitorInfo();
    return stack_depth;
  }
  
  public ThreadReference thread()
  {
    validateMonitorInfo();
    return thread;
  }
}

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

import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.InternalException;
import com.sun.jdi.Location;
import com.sun.jdi.VirtualMachine;
import java.util.ArrayList;
import java.util.List;
import sun.jvm.hotspot.oops.Method;

public class NonConcreteMethodImpl
  extends MethodImpl
{
  private Location location = null;
  
  NonConcreteMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, Method saMethod)
  {
    super(vm, declaringType, saMethod);
  }
  
  public Location location()
  {
    if (isAbstract()) {
      return null;
    }
    if (location == null) {
      location = new LocationImpl(vm, this, -1L);
    }
    return location;
  }
  
  public List allLineLocations(String stratumID, String sourceName)
  {
    return new ArrayList(0);
  }
  
  public List allLineLocations(SDE.Stratum stratum, String sourceName)
  {
    return new ArrayList(0);
  }
  
  public List locationsOfLine(String stratumID, String sourceName, int lineNumber)
  {
    return new ArrayList(0);
  }
  
  public List locationsOfLine(SDE.Stratum stratum, String sourceName, int lineNumber)
  {
    return new ArrayList(0);
  }
  
  public Location locationOfCodeIndex(long codeIndex)
  {
    return null;
  }
  
  LineInfo codeIndexToLineInfo(SDE.Stratum stratum, long codeIndex)
  {
    if (stratum.isJava()) {
      return new BaseLineInfo(-1, declaringType);
    }
    return new StratumLineInfo(stratum.id(), -1, null, null);
  }
  
  public List variables()
    throws AbsentInformationException
  {
    throw new AbsentInformationException();
  }
  
  public List variablesByName(String name)
    throws AbsentInformationException
  {
    throw new AbsentInformationException();
  }
  
  public List arguments()
    throws AbsentInformationException
  {
    throw new AbsentInformationException();
  }
  
  public byte[] bytecodes()
  {
    return new byte[0];
  }
  
  int argSlotCount()
    throws AbsentInformationException
  {
    throw new InternalException("should not get here");
  }
}

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

import com.sun.jdi.Field;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
import java.util.List;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.Oop;

final class ObjectReferenceImpl$1
  extends DefaultHeapVisitor
{
  private long refCount = 0L;
  private final ObjectReferenceImpl this$0;
  
  ObjectReferenceImpl$1(ObjectReferenceImpl paramObjectReferenceImpl, ObjectReference paramObjectReference, List paramList, long paramLong) {}
  
  public boolean doObj(Oop oop)
  {
    try
    {
      ObjectReference objref = this$0.vm.objectMirror(oop);
      List fields = objref.referenceType().allFields();
      for (int i = 0; i < fields.size(); i++)
      {
        Field fld = (Field)fields.get(i);
        if ((objref.getValue(fld).equals(val$obj)) && (!val$objects.contains(objref)))
        {
          val$objects.add(objref);
          refCount += 1L;
        }
      }
      if ((val$max > 0L) && (refCount >= val$max)) {
        return true;
      }
    }
    catch (RuntimeException x) {}
    return false;
  }
}

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

import com.sun.jdi.ClassNotLoadedException;
import com.sun.jdi.Field;
import com.sun.jdi.IncompatibleThreadStateException;
import com.sun.jdi.InvalidTypeException;
import com.sun.jdi.InvocationException;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.Type;
import com.sun.jdi.Value;
import com.sun.jdi.VirtualMachine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Mark;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.BasicLock;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.JavaVFrame;
import sun.jvm.hotspot.runtime.MonitorInfo;
import sun.jvm.hotspot.runtime.ObjectMonitor;
import sun.jvm.hotspot.runtime.Threads;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.Assert;

public class ObjectReferenceImpl
  extends ValueImpl
  implements ObjectReference
{
  private Oop saObject;
  private long myID;
  private boolean monitorInfoCached = false;
  private ThreadReferenceImpl owningThread = null;
  private List waitingThreads = null;
  private int entryCount = 0;
  private static long nextID = 0L;
  
  private static synchronized long nextID()
  {
    return nextID++;
  }
  
  ObjectReferenceImpl(VirtualMachine aVm, Oop oRef)
  {
    super(aVm);
    saObject = oRef;
    myID = nextID();
  }
  
  protected Oop ref()
  {
    return saObject;
  }
  
  public Type type()
  {
    return referenceType();
  }
  
  public ReferenceType referenceType()
  {
    Klass myKlass = ref().getKlass();
    return vm.referenceType(myKlass);
  }
  
  public Value getValue(Field sig)
  {
    List list = new ArrayList(1);
    list.add(sig);
    Map map = getValues(list);
    return (Value)map.get(sig);
  }
  
  public Map getValues(List theFields)
  {
    List staticFields = new ArrayList(0);
    int size = theFields.size();
    List instanceFields = new ArrayList(size);
    for (int i = 0; i < size; i++)
    {
      FieldImpl field = (FieldImpl)theFields.get(i);
      
      ((ReferenceTypeImpl)referenceType()).validateFieldAccess(field);
      if (field.isStatic()) {
        staticFields.add(field);
      } else {
        instanceFields.add(field);
      }
    }
    Map map;
    Map map;
    if (staticFields.size() > 0) {
      map = referenceType().getValues(staticFields);
    } else {
      map = new HashMap(size);
    }
    size = instanceFields.size();
    for (int ii = 0; ii < size; ii++)
    {
      FieldImpl fieldImpl = (FieldImpl)instanceFields.get(ii);
      map.put(fieldImpl, fieldImpl.getValue(saObject));
    }
    return map;
  }
  
  public void setValue(Field field, Value value)
    throws InvalidTypeException, ClassNotLoadedException
  {
    vm.throwNotReadOnlyException("ObjectReference.setValue(...)");
  }
  
  public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List arguments, int options)
    throws InvalidTypeException, IncompatibleThreadStateException, InvocationException, ClassNotLoadedException
  {
    vm.throwNotReadOnlyException("ObjectReference.invokeMethod(...)");
    return null;
  }
  
  public void disableCollection()
  {
    vm.throwNotReadOnlyException("ObjectReference.disableCollection()");
  }
  
  public void enableCollection()
  {
    vm.throwNotReadOnlyException("ObjectReference.enableCollection()");
  }
  
  public boolean isCollected()
  {
    vm.throwNotReadOnlyException("ObjectReference.isCollected()");
    return false;
  }
  
  public long uniqueID()
  {
    return myID;
  }
  
  public List waitingThreads()
    throws IncompatibleThreadStateException
  {
    if (!vm.canGetMonitorInfo()) {
      throw new UnsupportedOperationException();
    }
    if (!monitorInfoCached) {
      computeMonitorInfo();
    }
    return waitingThreads;
  }
  
  public ThreadReference owningThread()
    throws IncompatibleThreadStateException
  {
    if (!vm.canGetMonitorInfo()) {
      throw new UnsupportedOperationException();
    }
    if (!monitorInfoCached) {
      computeMonitorInfo();
    }
    return owningThread;
  }
  
  public int entryCount()
    throws IncompatibleThreadStateException
  {
    if (!vm.canGetMonitorInfo()) {
      throw new UnsupportedOperationException();
    }
    if (!monitorInfoCached) {
      computeMonitorInfo();
    }
    return entryCount;
  }
  
  public List referringObjects(long maxReferrers)
  {
    if (!vm.canGetInstanceInfo()) {
      throw new UnsupportedOperationException("target does not support getting instances");
    }
    if (maxReferrers < 0L) {
      throw new IllegalArgumentException("maxReferrers is less than zero: " + maxReferrers);
    }
    final ObjectReference obj = this;
    final List objects = new ArrayList(0);
    final long max = maxReferrers;
    vm.saObjectHeap().iterate(new DefaultHeapVisitor()
    {
      private long refCount = 0L;
      
      public boolean doObj(Oop oop)
      {
        try
        {
          ObjectReference objref = vm.objectMirror(oop);
          List fields = objref.referenceType().allFields();
          for (int i = 0; i < fields.size(); i++)
          {
            Field fld = (Field)fields.get(i);
            if ((objref.getValue(fld).equals(obj)) && (!objects.contains(objref)))
            {
              objects.add(objref);
              refCount += 1L;
            }
          }
          if ((max > 0L) && (refCount >= max)) {
            return true;
          }
        }
        catch (RuntimeException x) {}
        return false;
      }
    });
    return objects;
  }
  
  private int countLockedObjects(JavaThread jt, Oop obj)
  {
    int res = 0;
    JavaVFrame frame = jt.getLastJavaVFrameDbg();
    while (frame != null)
    {
      List monitors = frame.getMonitors();
      OopHandle givenHandle = obj.getHandle();
      for (Iterator itr = monitors.iterator(); itr.hasNext();)
      {
        MonitorInfo mi = (MonitorInfo)itr.next();
        if ((!mi.eliminated()) || (!frame.isCompiledFrame())) {
          if (givenHandle.equals(mi.owner())) {
            res++;
          }
        }
      }
      frame = frame.javaSender();
    }
    return res;
  }
  
  private List getPendingThreads(ObjectMonitor mon)
  {
    return vm.saVM().getThreads().getPendingThreads(mon);
  }
  
  private List getWaitingThreads(ObjectMonitor mon)
  {
    return vm.saVM().getThreads().getWaitingThreads(mon);
  }
  
  private JavaThread owningThreadFromMonitor(Address addr)
  {
    return vm.saVM().getThreads().owningThreadFromMonitor(addr);
  }
  
  private void computeMonitorInfo()
  {
    monitorInfoCached = true;
    Mark mark = saObject.getMark();
    ObjectMonitor mon = null;
    Address owner = null;
    if (!mark.hasMonitor())
    {
      if (mark.hasLocker()) {
        owner = mark.locker().getAddress();
      }
    }
    else
    {
      mon = mark.monitor();
      
      owner = mon.owner();
    }
    if (owner != null) {
      owningThread = vm.threadMirror(owningThreadFromMonitor(owner));
    }
    if (owningThread != null) {
      if (owningThread.getJavaThread().getAddress().equals(owner))
      {
        if (Assert.ASSERTS_ENABLED) {
          Assert.that(false, "must have heavyweight monitor with JavaThread * owner");
        }
        entryCount = ((int)mark.monitor().recursions() + 1);
      }
      else
      {
        entryCount = countLockedObjects(owningThread.getJavaThread(), saObject);
      }
    }
    waitingThreads = new ArrayList();
    Iterator itrWait;
    if (mon != null)
    {
      List pendingThreads = getPendingThreads(mon);
      for (Iterator itrPend = pendingThreads.iterator(); itrPend.hasNext();) {
        waitingThreads.add(vm.threadMirror((JavaThread)itrPend.next()));
      }
      List objWaitingThreads = getWaitingThreads(mon);
      for (itrWait = objWaitingThreads.iterator(); itrWait.hasNext();) {
        waitingThreads.add(vm.threadMirror((JavaThread)itrWait.next()));
      }
    }
  }
  
  public boolean equals(Object obj)
  {
    if ((obj != null) && ((obj instanceof ObjectReferenceImpl)))
    {
      ObjectReferenceImpl other = (ObjectReferenceImpl)obj;
      return (ref().equals(other.ref())) && (super.equals(obj));
    }
    return false;
  }
  
  public int hashCode()
  {
    return saObject.hashCode();
  }
  
  public String toString()
  {
    return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")";
  }
}

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

import com.sun.jdi.InvalidTypeException;
import com.sun.jdi.PrimitiveType;
import com.sun.jdi.PrimitiveValue;
import com.sun.jdi.VirtualMachine;

abstract class PrimitiveTypeImpl
  extends TypeImpl
  implements PrimitiveType
{
  PrimitiveTypeImpl(VirtualMachine vm)
  {
    super(vm);
  }
  
  abstract PrimitiveValue convert(PrimitiveValue paramPrimitiveValue)
    throws InvalidTypeException;
  
  public String toString()
  {
    return name();
  }
}

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

import com.sun.jdi.BooleanValue;
import com.sun.jdi.InvalidTypeException;
import com.sun.jdi.PrimitiveValue;
import com.sun.jdi.VirtualMachine;

public abstract class PrimitiveValueImpl
  extends ValueImpl
  implements PrimitiveValue
{
  PrimitiveValueImpl(VirtualMachine aVm)
  {
    super(aVm);
  }
  
  public abstract boolean booleanValue();
  
  public abstract byte byteValue();
  
  public abstract char charValue();
  
  public abstract short shortValue();
  
  public abstract int intValue();
  
  public abstract long longValue();
  
  public abstract float floatValue();
  
  public abstract double doubleValue();
  
  byte checkedByteValue()
    throws InvalidTypeException
  {
    return byteValue();
  }
  
  char checkedCharValue()
    throws InvalidTypeException
  {
    return charValue();
  }
  
  short checkedShortValue()
    throws InvalidTypeException
  {
    return shortValue();
  }
  
  int checkedIntValue()
    throws InvalidTypeException
  {
    return intValue();
  }
  
  long checkedLongValue()
    throws InvalidTypeException
  {
    return longValue();
  }
  
  float checkedFloatValue()
    throws InvalidTypeException
  {
    return floatValue();
  }
  
  final boolean checkedBooleanValue()
    throws InvalidTypeException
  {
    if ((this instanceof BooleanValue)) {
      return booleanValue();
    }
    throw new InvalidTypeException("Can't convert non-boolean value to boolean");
  }
  
  final double checkedDoubleValue()
    throws InvalidTypeException
  {
    return doubleValue();
  }
}

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

import java.util.List;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Oop;

final class ReferenceTypeImpl$1
  extends DefaultHeapVisitor
{
  private long instCount = 0L;
  private final ReferenceTypeImpl this$0;
  
  ReferenceTypeImpl$1(ReferenceTypeImpl paramReferenceTypeImpl, Klass paramKlass, List paramList, long paramLong) {}
  
  public boolean doObj(Oop oop)
  {
    if (val$givenKls.equals(oop.getKlass()))
    {
      val$objects.add(this$0.vm.objectMirror(oop));
      instCount += 1L;
    }
    if ((val$max > 0L) && (instCount >= val$max)) {
      return true;
    }
    return false;
  }
}

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

import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.ArrayType;
import com.sun.jdi.ClassLoaderReference;
import com.sun.jdi.ClassNotLoadedException;
import com.sun.jdi.ClassNotPreparedException;
import com.sun.jdi.ClassObjectReference;
import com.sun.jdi.InterfaceType;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.PrimitiveType;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.Type;
import com.sun.jdi.Value;
import com.sun.jdi.VirtualMachine;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.ArrayKlass;
import sun.jvm.hotspot.oops.ConstantPool;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.Instance;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.utilities.Assert;

public abstract class ReferenceTypeImpl
  extends TypeImpl
  implements ReferenceType
{
  protected Klass saKlass;
  protected Symbol typeNameSymbol;
  private int modifiers = -1;
  private String signature = null;
  private SoftReference sdeRef = null;
  private SoftReference fieldsCache;
  private SoftReference allFieldsCache;
  private SoftReference methodsCache;
  private SoftReference allMethodsCache;
  private SoftReference nestedTypesCache;
  static final SDE NO_SDE_INFO_MARK = new SDE();
  static Object prev;
  
  protected ReferenceTypeImpl(VirtualMachine aVm, Klass klass)
  {
    super(aVm);
    saKlass = klass;
    typeNameSymbol = saKlass.getName();
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(typeNameSymbol != null, "null type name for a Klass");
    }
  }
  
  Symbol typeNameAsSymbol()
  {
    return typeNameSymbol;
  }
  
  com.sun.jdi.Method getMethodMirror(sun.jvm.hotspot.oops.Method ref)
  {
    Iterator it = methods().iterator();
    while (it.hasNext())
    {
      MethodImpl method = (MethodImpl)it.next();
      if (ref.equals(method.ref())) {
        return method;
      }
    }
    throw new IllegalArgumentException("Invalid method id: " + ref);
  }
  
  public boolean equals(Object obj)
  {
    if ((obj != null) && ((obj instanceof ReferenceTypeImpl)))
    {
      ReferenceTypeImpl other = (ReferenceTypeImpl)obj;
      return (ref().equals(other.ref())) && (vm.equals(other.virtualMachine()));
    }
    return false;
  }
  
  public int hashCode()
  {
    return saKlass.hashCode();
  }
  
  public int compareTo(Object object)
  {
    ReferenceTypeImpl other = (ReferenceTypeImpl)object;
    int comp = name().compareTo(other.name());
    if (comp == 0)
    {
      Oop rf1 = ref();
      Oop rf2 = other.ref();
      if (rf1.equals(rf2)) {
        comp = vm.sequenceNumber - virtualMachinesequenceNumber;
      } else {
        comp = rf1.getHandle().minus(rf2.getHandle()) < 0L ? -1 : 1;
      }
    }
    return comp;
  }
  
  public String signature()
  {
    if (signature == null) {
      signature = saKlass.signature();
    }
    return signature;
  }
  
  public String genericSignature()
  {
    if ((saKlass instanceof ArrayKlass)) {
      return null;
    }
    Symbol genSig = ((InstanceKlass)saKlass).getGenericSignature();
    return genSig != null ? genSig.asString() : null;
  }
  
  public ClassLoaderReference classLoader()
  {
    Instance xx = (Instance)((InstanceKlass)saKlass).getClassLoader();
    return vm.classLoaderMirror(xx);
  }
  
  public boolean isPublic()
  {
    return (modifiers() & 0x1) != 0;
  }
  
  public boolean isProtected()
  {
    return (modifiers() & 0x4) != 0;
  }
  
  public boolean isPrivate()
  {
    return (modifiers() & 0x2) != 0;
  }
  
  public boolean isPackagePrivate()
  {
    return (!isPublic()) && (!isPrivate()) && (!isProtected());
  }
  
  public boolean isAbstract()
  {
    return (modifiers() & 0x400) != 0;
  }
  
  public boolean isFinal()
  {
    return (modifiers() & 0x10) != 0;
  }
  
  public boolean isStatic()
  {
    return (modifiers() & 0x8) != 0;
  }
  
  public boolean isPrepared()
  {
    return (saKlass.getClassStatus() & 0x2) != 0;
  }
  
  final void checkPrepared()
    throws ClassNotPreparedException
  {
    if (!isPrepared()) {
      throw new ClassNotPreparedException();
    }
  }
  
  public boolean isVerified()
  {
    return (saKlass.getClassStatus() & 0x1) != 0;
  }
  
  public boolean isInitialized()
  {
    return (saKlass.getClassStatus() & 0x4) != 0;
  }
  
  public boolean failedToInitialize()
  {
    return (saKlass.getClassStatus() & 0x8) != 0;
  }
  
  private boolean isThrowableBacktraceField(sun.jvm.hotspot.oops.Field fld)
  {
    if ((fld.getFieldHolder().getName().equals(vm.javaLangThrowable())) && (fld.getID().getName().equals("backtrace"))) {
      return true;
    }
    return false;
  }
  
  public final List fields()
    throws ClassNotPreparedException
  {
    List fields = fieldsCache != null ? (List)fieldsCache.get() : null;
    if (fields == null)
    {
      checkPrepared();
      if ((saKlass instanceof ArrayKlass))
      {
        fields = new ArrayList(0);
      }
      else
      {
        List saFields = ((InstanceKlass)saKlass).getImmediateFields();
        
        int len = saFields.size();
        fields = new ArrayList(len);
        for (int ii = 0; ii < len; ii++)
        {
          sun.jvm.hotspot.oops.Field curField = (sun.jvm.hotspot.oops.Field)saFields.get(ii);
          if (!isThrowableBacktraceField(curField)) {
            fields.add(new FieldImpl(vm, this, curField));
          }
        }
      }
      fields = Collections.unmodifiableList(fields);
      fieldsCache = new SoftReference(fields);
    }
    return fields;
  }
  
  public final List allFields()
    throws ClassNotPreparedException
  {
    List allFields = allFieldsCache != null ? (List)allFieldsCache.get() : null;
    if (allFields == null)
    {
      checkPrepared();
      if ((saKlass instanceof ArrayKlass))
      {
        allFields = new ArrayList(0);
      }
      else
      {
        List saFields = ((InstanceKlass)saKlass).getAllFields();
        
        int len = saFields.size();
        allFields = new ArrayList(len);
        for (int ii = 0; ii < len; ii++)
        {
          sun.jvm.hotspot.oops.Field curField = (sun.jvm.hotspot.oops.Field)saFields.get(ii);
          if (!isThrowableBacktraceField(curField)) {
            allFields.add(new FieldImpl(vm, vm.referenceType(curField.getFieldHolder()), curField));
          }
        }
      }
      allFields = Collections.unmodifiableList(allFields);
      allFieldsCache = new SoftReference(allFields);
    }
    return allFields;
  }
  
  abstract List inheritedTypes();
  
  void addVisibleFields(List visibleList, Map visibleTable, List ambiguousNames)
  {
    List list = visibleFields();
    Iterator iter = list.iterator();
    while (iter.hasNext())
    {
      com.sun.jdi.Field field = (com.sun.jdi.Field)iter.next();
      String name = field.name();
      if (!ambiguousNames.contains(name))
      {
        com.sun.jdi.Field duplicate = (com.sun.jdi.Field)visibleTable.get(name);
        if (duplicate == null)
        {
          visibleList.add(field);
          visibleTable.put(name, field);
        }
        else if (!field.equals(duplicate))
        {
          ambiguousNames.add(name);
          visibleTable.remove(name);
          visibleList.remove(duplicate);
        }
      }
    }
  }
  
  public final List visibleFields()
    throws ClassNotPreparedException
  {
    checkPrepared();
    
    List visibleList = new ArrayList();
    Map visibleTable = new HashMap();
    
    List ambiguousNames = new ArrayList();
    
    List types = inheritedTypes();
    Iterator iter = types.iterator();
    while (iter.hasNext())
    {
      ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next();
      type.addVisibleFields(visibleList, visibleTable, ambiguousNames);
    }
    List retList = new ArrayList(fields());
    iter = retList.iterator();
    while (iter.hasNext())
    {
      com.sun.jdi.Field field = (com.sun.jdi.Field)iter.next();
      com.sun.jdi.Field hidden = (com.sun.jdi.Field)visibleTable.get(field.name());
      if (hidden != null) {
        visibleList.remove(hidden);
      }
    }
    retList.addAll(visibleList);
    return retList;
  }
  
  public final com.sun.jdi.Field fieldByName(String fieldName)
    throws ClassNotPreparedException
  {
    List searchList = visibleFields();
    for (int i = 0; i < searchList.size(); i++)
    {
      com.sun.jdi.Field f = (com.sun.jdi.Field)searchList.get(i);
      if (f.name().equals(fieldName)) {
        return f;
      }
    }
    return null;
  }
  
  public final List methods()
    throws ClassNotPreparedException
  {
    List methods = methodsCache != null ? (List)methodsCache.get() : null;
    if (methods == null)
    {
      checkPrepared();
      if ((saKlass instanceof ArrayKlass))
      {
        methods = new ArrayList(0);
      }
      else
      {
        List saMethods = ((InstanceKlass)saKlass).getImmediateMethods();
        
        int len = saMethods.size();
        methods = new ArrayList(len);
        for (int ii = 0; ii < len; ii++) {
          methods.add(MethodImpl.createMethodImpl(vm, this, (sun.jvm.hotspot.oops.Method)saMethods.get(ii)));
        }
      }
      methods = Collections.unmodifiableList(methods);
      methodsCache = new SoftReference(methods);
    }
    return methods;
  }
  
  abstract List getAllMethods();
  
  public final List allMethods()
    throws ClassNotPreparedException
  {
    List allMethods = allMethodsCache != null ? (List)allMethodsCache.get() : null;
    if (allMethods == null)
    {
      checkPrepared();
      allMethods = Collections.unmodifiableList(getAllMethods());
      allMethodsCache = new SoftReference(allMethods);
    }
    return allMethods;
  }
  
  void addToMethodMap(Map methodMap, List methodList)
  {
    Iterator iter = methodList.iterator();
    while (iter.hasNext())
    {
      com.sun.jdi.Method method = (com.sun.jdi.Method)iter.next();
      methodMap.put(method.name().concat(method.signature()), method);
    }
  }
  
  abstract void addVisibleMethods(Map paramMap);
  
  public final List visibleMethods()
    throws ClassNotPreparedException
  {
    checkPrepared();
    
    Map map = new HashMap();
    addVisibleMethods(map);
    
    List list = new ArrayList(allMethods());
    
    list.retainAll(map.values());
    
    return list;
  }
  
  public static String jjstr(Collection cc)
  {
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    Iterator i = cc.iterator();
    boolean hasNext = i.hasNext();
    while (hasNext)
    {
      Object o = i.next();
      if (prev == null)
      {
        prev = o;
      }
      else
      {
        System.out.println("prev == curr?" + prev.equals(o));
        System.out.println("prev == curr?" + (prev == o));
      }
      buf.append(o + "@" + o.hashCode());
      
      hasNext = i.hasNext();
      if (hasNext) {
        buf.append(", ");
      }
    }
    buf.append("]");
    return buf.toString();
  }
  
  public final List methodsByName(String name)
    throws ClassNotPreparedException
  {
    List methods = visibleMethods();
    ArrayList retList = new ArrayList(methods.size());
    Iterator iter = methods.iterator();
    while (iter.hasNext())
    {
      com.sun.jdi.Method candidate = (com.sun.jdi.Method)iter.next();
      if (candidate.name().equals(name)) {
        retList.add(candidate);
      }
    }
    retList.trimToSize();
    return retList;
  }
  
  public final List methodsByName(String name, String signature)
    throws ClassNotPreparedException
  {
    List methods = visibleMethods();
    ArrayList retList = new ArrayList(methods.size());
    Iterator iter = methods.iterator();
    while (iter.hasNext())
    {
      com.sun.jdi.Method candidate = (com.sun.jdi.Method)iter.next();
      if ((candidate.name().equals(name)) && (candidate.signature().equals(signature))) {
        retList.add(candidate);
      }
    }
    retList.trimToSize();
    return retList;
  }
  
  List getInterfaces()
  {
    List myInterfaces;
    List myInterfaces;
    if ((saKlass instanceof ArrayKlass))
    {
      myInterfaces = new ArrayList(0);
    }
    else
    {
      List saInterfaces = ((InstanceKlass)saKlass).getDirectImplementedInterfaces();
      
      int len = saInterfaces.size();
      myInterfaces = new ArrayList(len);
      for (int ii = 0; ii < len; ii++) {
        myInterfaces.add(new InterfaceTypeImpl(vm, (InstanceKlass)saInterfaces.get(ii)));
      }
    }
    return myInterfaces;
  }
  
  public final List nestedTypes()
  {
    List nestedTypes = nestedTypesCache != null ? (List)nestedTypesCache.get() : null;
    if (nestedTypes == null)
    {
      if ((saKlass instanceof ArrayKlass))
      {
        nestedTypes = new ArrayList(0);
      }
      else
      {
        ClassLoaderReference cl = classLoader();
        List classes = null;
        if (cl != null) {
          classes = cl.visibleClasses();
        } else {
          classes = vm.bootstrapClasses();
        }
        nestedTypes = new ArrayList();
        Iterator iter = classes.iterator();
        while (iter.hasNext())
        {
          ReferenceTypeImpl refType = (ReferenceTypeImpl)iter.next();
          Symbol candidateName = refType.ref().getName();
          if (((InstanceKlass)saKlass).isInnerOrLocalClassName(candidateName)) {
            nestedTypes.add(refType);
          }
        }
      }
      nestedTypes = Collections.unmodifiableList(nestedTypes);
      nestedTypesCache = new SoftReference(nestedTypes);
    }
    return nestedTypes;
  }
  
  public Value getValue(com.sun.jdi.Field sig)
  {
    List list = new ArrayList(1);
    list.add(sig);
    Map map = getValues(list);
    return (Value)map.get(sig);
  }
  
  public Map getValues(List theFields)
  {
    int size = theFields.size();
    Map map = new HashMap(size);
    for (int ii = 0; ii < size; ii++)
    {
      FieldImpl fieldImpl = (FieldImpl)theFields.get(ii);
      
      validateFieldAccess(fieldImpl);
      if (!fieldImpl.isStatic()) {
        throw new IllegalArgumentExceptio
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