sa-jdi

l
  implements ClassObjectReference
{
  private ReferenceType reflectedType;
  
  ClassObjectReferenceImpl(VirtualMachine vm, Instance oRef)
  {
    super(vm, oRef);
  }
  
  public ReferenceType reflectedType()
  {
    if (reflectedType == null)
    {
      Klass k = OopUtilities.classOopToKlass(ref());
      reflectedType = vm.referenceType(k);
    }
    return reflectedType;
  }
  
  public String toString()
  {
    return "instance of " + referenceType().name() + "(reflected class=" + reflectedType().name() + ", " + "id=" + uniqueID() + ")";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.jdi.ClassObjectReferenceImpl
 * 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.ClassType;
import com.sun.jdi.Field;
import com.sun.jdi.IncompatibleThreadStateException;
import com.sun.jdi.InterfaceType;
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.Value;
import com.sun.jdi.VirtualMachine;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Symbol;

public class ClassTypeImpl
  extends ReferenceTypeImpl
  implements ClassType
{
  private SoftReference interfacesCache = null;
  private SoftReference allInterfacesCache = null;
  private SoftReference subclassesCache = null;
  
  protected ClassTypeImpl(VirtualMachine aVm, InstanceKlass aRef)
  {
    super(aVm, aRef);
  }
  
  public ClassType superclass()
  {
    InstanceKlass kk = (InstanceKlass)ref().getSuper();
    if (kk == null) {
      return null;
    }
    return (ClassType)vm.referenceType(kk);
  }
  
  public List interfaces()
  {
    List interfaces = interfacesCache != null ? (List)interfacesCache.get() : null;
    if (interfaces == null)
    {
      checkPrepared();
      interfaces = Collections.unmodifiableList(getInterfaces());
      interfacesCache = new SoftReference(interfaces);
    }
    return interfaces;
  }
  
  void addInterfaces(List list)
  {
    List immediate = interfaces();
    
    HashSet hashList = new HashSet(list);
    hashList.addAll(immediate);
    list.clear();
    list.addAll(hashList);
    
    Iterator iter = immediate.iterator();
    while (iter.hasNext())
    {
      InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
      interfaze.addSuperinterfaces(list);
    }
    ClassTypeImpl superclass = (ClassTypeImpl)superclass();
    if (superclass != null) {
      superclass.addInterfaces(list);
    }
  }
  
  public List allInterfaces()
  {
    List allinterfaces = allInterfacesCache != null ? (List)allInterfacesCache.get() : null;
    if (allinterfaces == null)
    {
      checkPrepared();
      allinterfaces = new ArrayList();
      addInterfaces(allinterfaces);
      allinterfaces = Collections.unmodifiableList(allinterfaces);
      allInterfacesCache = new SoftReference(allinterfaces);
    }
    return allinterfaces;
  }
  
  public List subclasses()
  {
    List subclasses = subclassesCache != null ? (List)subclassesCache.get() : null;
    if (subclasses == null)
    {
      List all = vm.allClasses();
      subclasses = new ArrayList(0);
      Iterator iter = all.iterator();
      while (iter.hasNext())
      {
        ReferenceType refType = (ReferenceType)iter.next();
        if ((refType instanceof ClassType))
        {
          ClassType clazz = (ClassType)refType;
          ClassType superclass = clazz.superclass();
          if ((superclass != null) && (superclass.equals(this))) {
            subclasses.add(refType);
          }
        }
      }
      subclasses = Collections.unmodifiableList(subclasses);
      subclassesCache = new SoftReference(subclasses);
    }
    return subclasses;
  }
  
  public Method concreteMethodByName(String name, String signature)
  {
    checkPrepared();
    List methods = visibleMethods();
    Method method = null;
    Iterator iter = methods.iterator();
    while (iter.hasNext())
    {
      Method candidate = (Method)iter.next();
      if ((candidate.name().equals(name)) && (candidate.signature().equals(signature)) && (!candidate.isAbstract()))
      {
        method = candidate;
        break;
      }
    }
    return method;
  }
  
  List getAllMethods()
  {
    ArrayList list = new ArrayList(methods());
    ClassType clazz = superclass();
    while (clazz != null)
    {
      list.addAll(clazz.methods());
      clazz = clazz.superclass();
    }
    Iterator iter = allInterfaces().iterator();
    while (iter.hasNext())
    {
      InterfaceType interfaze = (InterfaceType)iter.next();
      list.addAll(interfaze.methods());
    }
    return list;
  }
  
  List inheritedTypes()
  {
    List inherited = new ArrayList(interfaces());
    if (superclass() != null) {
      inherited.add(0, superclass());
    }
    return inherited;
  }
  
  public boolean isEnum()
  {
    ClassTypeImpl superclass = (ClassTypeImpl)superclass();
    if (superclass != null) {
      return superclass.typeNameAsSymbol().equals(vm.javaLangEnum());
    }
    return false;
  }
  
  public void setValue(Field field, Value value)
    throws InvalidTypeException, ClassNotLoadedException
  {
    vm.throwNotReadOnlyException("ClassType.setValue(...)");
  }
  
  public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List arguments, int options)
    throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException
  {
    vm.throwNotReadOnlyException("ClassType.invokeMethod(...)");
    return null;
  }
  
  public ObjectReference newInstance(ThreadReference threadIntf, Method methodIntf, List arguments, int options)
    throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException
  {
    vm.throwNotReadOnlyException("ClassType.newInstance(...)");
    return null;
  }
  
  void addVisibleMethods(Map methodMap)
  {
    Iterator iter = interfaces().iterator();
    while (iter.hasNext())
    {
      InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
      interfaze.addVisibleMethods(methodMap);
    }
    ClassTypeImpl clazz = (ClassTypeImpl)superclass();
    if (clazz != null) {
      clazz.addVisibleMethods(methodMap);
    }
    addToMethodMap(methodMap, methods());
  }
  
  boolean isAssignableTo(ReferenceType type)
  {
    ClassTypeImpl superclazz = (ClassTypeImpl)superclass();
    if (equals(type)) {
      return true;
    }
    if ((superclazz != null) && (superclazz.isAssignableTo(type))) {
      return true;
    }
    List interfaces = interfaces();
    Iterator iter = interfaces.iterator();
    while (iter.hasNext())
    {
      InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
      if (interfaze.isAssignableTo(type)) {
        return true;
      }
    }
    return false;
  }
  
  public String toString()
  {
    return "class " + name() + "(" + loaderString() + ")";
  }
}

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

import java.util.Collections;
import java.util.List;
import java.util.Map;

class ConcreteMethodImpl$SoftLocationXRefs
{
  final String stratumID;
  final Map lineMapper;
  final List lineLocations;
  final int lowestLine;
  final int highestLine;
  
  ConcreteMethodImpl$SoftLocationXRefs(String stratumID, Map lineMapper, List lineLocations, int lowestLine, int highestLine)
  {
    this.stratumID = stratumID;
    this.lineMapper = Collections.unmodifiableMap(lineMapper);
    this.lineLocations = Collections.unmodifiableList(lineLocations);
    
    this.lowestLine = lowestLine;
    this.highestLine = highestLine;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.jdi.ConcreteMethodImpl.SoftLocationXRefs
 * 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.LocalVariable;
import com.sun.jdi.Location;
import com.sun.jdi.VirtualMachine;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.oops.ConstantPool;
import sun.jvm.hotspot.oops.LineNumberTableElement;
import sun.jvm.hotspot.oops.LocalVariableTableElement;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.Symbol;

public class ConcreteMethodImpl
  extends MethodImpl
{
  private SoftReference softBaseLocationXRefsRef;
  private SoftReference softOtherLocationXRefsRef;
  
  private static class SoftLocationXRefs
  {
    final String stratumID;
    final Map lineMapper;
    final List lineLocations;
    final int lowestLine;
    final int highestLine;
    
    SoftLocationXRefs(String stratumID, Map lineMapper, List lineLocations, int lowestLine, int highestLine)
    {
      this.stratumID = stratumID;
      this.lineMapper = Collections.unmodifiableMap(lineMapper);
      this.lineLocations = Collections.unmodifiableList(lineLocations);
      
      this.lowestLine = lowestLine;
      this.highestLine = highestLine;
    }
  }
  
  private SoftReference variablesRef = null;
  private int firstIndex = -1;
  private int lastIndex = -1;
  private Location location;
  private SoftReference bytecodesRef = null;
  
  ConcreteMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, Method saMethod)
  {
    super(vm, declaringType, saMethod);
  }
  
  int argSlotCount()
    throws AbsentInformationException
  {
    return (int)saMethod.getSizeOfParameters();
  }
  
  private SoftLocationXRefs getLocations(SDE.Stratum stratum)
  {
    if (stratum.isJava()) {
      return getBaseLocations();
    }
    String stratumID = stratum.id();
    SoftLocationXRefs info = softOtherLocationXRefsRef == null ? null : (SoftLocationXRefs)softOtherLocationXRefsRef.get();
    if ((info != null) && (stratumID.equals(stratumID))) {
      return info;
    }
    List lineLocations = new ArrayList();
    Map lineMapper = new HashMap();
    int lowestLine = -1;
    int highestLine = -1;
    SDE.LineStratum lastLineStratum = null;
    SDE.Stratum baseStratum = declaringType.stratum("Java");
    
    Iterator it = getBaseLocationslineLocations.iterator();
    while (it.hasNext())
    {
      LocationImpl loc = (LocationImpl)it.next();
      int baseLineNumber = loc.lineNumber(baseStratum);
      SDE.LineStratum lineStratum = stratum.lineStratum(declaringType, baseLineNumber);
      if (lineStratum != null)
      {
        int lineNumber = lineStratum.lineNumber();
        if ((lineNumber != -1) && (!lineStratum.equals(lastLineStratum)))
        {
          lastLineStratum = lineStratum;
          if (lineNumber > highestLine) {
            highestLine = lineNumber;
          }
          if ((lineNumber < lowestLine) || (lowestLine == -1)) {
            lowestLine = lineNumber;
          }
          loc.addStratumLineInfo(new StratumLineInfo(stratumID, lineNumber, lineStratum.sourceName(), lineStratum.sourcePath()));
          
          lineLocations.add(loc);
          
          Integer key = new Integer(lineNumber);
          List mappedLocs = (List)lineMapper.get(key);
          if (mappedLocs == null)
          {
            mappedLocs = new ArrayList(1);
            lineMapper.put(key, mappedLocs);
          }
          mappedLocs.add(loc);
        }
      }
    }
    info = new SoftLocationXRefs(stratumID, lineMapper, lineLocations, lowestLine, highestLine);
    
    softOtherLocationXRefsRef = new SoftReference(info);
    return info;
  }
  
  private SoftLocationXRefs getBaseLocations()
  {
    SoftLocationXRefs info = softBaseLocationXRefsRef == null ? null : (SoftLocationXRefs)softBaseLocationXRefsRef.get();
    if (info != null) {
      return info;
    }
    byte[] codeBuf = bytecodes();
    firstIndex = 0;
    lastIndex = (codeBuf.length - 1);
    
    location = new LocationImpl(virtualMachine(), this, 0L);
    
    boolean hasLineInfo = saMethod.hasLineNumberTable();
    LineNumberTableElement[] lntab = null;
    int count;
    int count;
    if (hasLineInfo)
    {
      lntab = saMethod.getLineNumberTable();
      count = lntab.length;
    }
    else
    {
      count = 0;
    }
    List lineLocations = new ArrayList(count);
    Map lineMapper = new HashMap();
    int lowestLine = -1;
    int highestLine = -1;
    for (int i = 0; i < count; i++)
    {
      long bci = lntab[i].getStartBCI();
      int lineNumber = lntab[i].getLineNumber();
      if ((i + 1 == count) || (bci != lntab[(i + 1)].getStartBCI()))
      {
        if (lineNumber > highestLine) {
          highestLine = lineNumber;
        }
        if ((lineNumber < lowestLine) || (lowestLine == -1)) {
          lowestLine = lineNumber;
        }
        LocationImpl loc = new LocationImpl(virtualMachine(), this, bci);
        
        loc.addBaseLineInfo(new BaseLineInfo(lineNumber, declaringType));
        
        lineLocations.add(loc);
        
        Integer key = new Integer(lineNumber);
        List mappedLocs = (List)lineMapper.get(key);
        if (mappedLocs == null)
        {
          mappedLocs = new ArrayList(1);
          lineMapper.put(key, mappedLocs);
        }
        mappedLocs.add(loc);
      }
    }
    info = new SoftLocationXRefs("Java", lineMapper, lineLocations, lowestLine, highestLine);
    
    softBaseLocationXRefsRef = new SoftReference(info);
    return info;
  }
  
  List sourceNameFilter(List list, SDE.Stratum stratum, String sourceName)
    throws AbsentInformationException
  {
    if (sourceName == null) {
      return list;
    }
    List locs = new ArrayList();
    Iterator it = list.iterator();
    while (it.hasNext())
    {
      LocationImpl loc = (LocationImpl)it.next();
      if (loc.sourceName(stratum).equals(sourceName)) {
        locs.add(loc);
      }
    }
    return locs;
  }
  
  public List allLineLocations(SDE.Stratum stratum, String sourceName)
    throws AbsentInformationException
  {
    List lineLocations = getLocationslineLocations;
    if (lineLocations.size() == 0) {
      throw new AbsentInformationException();
    }
    return Collections.unmodifiableList(sourceNameFilter(lineLocations, stratum, sourceName));
  }
  
  public List locationsOfLine(SDE.Stratum stratum, String sourceName, int lineNumber)
    throws AbsentInformationException
  {
    SoftLocationXRefs info = getLocations(stratum);
    if (lineLocations.size() == 0) {
      throw new AbsentInformationException();
    }
    List list = (List)lineMapper.get(new Integer(lineNumber));
    if (list == null) {
      list = new ArrayList(0);
    }
    return Collections.unmodifiableList(sourceNameFilter(list, stratum, sourceName));
  }
  
  LineInfo codeIndexToLineInfo(SDE.Stratum stratum, long codeIndex)
  {
    if (firstIndex == -1) {
      getBaseLocations();
    }
    if ((codeIndex < firstIndex) || (codeIndex > lastIndex)) {
      throw new InternalError("Location with invalid code index");
    }
    List lineLocations = getLocationslineLocations;
    if (lineLocations.size() == 0) {
      return super.codeIndexToLineInfo(stratum, codeIndex);
    }
    Iterator iter = lineLocations.iterator();
    
    LocationImpl bestMatch = (LocationImpl)iter.next();
    while (iter.hasNext())
    {
      LocationImpl current = (LocationImpl)iter.next();
      if (current.codeIndex() > codeIndex) {
        break;
      }
      bestMatch = current;
    }
    return bestMatch.getLineInfo(stratum);
  }
  
  public Location locationOfCodeIndex(long codeIndex)
  {
    if (firstIndex == -1) {
      getBaseLocations();
    }
    if ((codeIndex < firstIndex) || (codeIndex > lastIndex)) {
      return null;
    }
    return new LocationImpl(virtualMachine(), this, codeIndex);
  }
  
  public List variables()
    throws AbsentInformationException
  {
    return getVariables();
  }
  
  public List variablesByName(String name)
    throws AbsentInformationException
  {
    List variables = getVariables();
    
    List retList = new ArrayList(2);
    Iterator iter = variables.iterator();
    while (iter.hasNext())
    {
      LocalVariable variable = (LocalVariable)iter.next();
      if (variable.name().equals(name)) {
        retList.add(variable);
      }
    }
    return retList;
  }
  
  public List arguments()
    throws AbsentInformationException
  {
    if (argumentTypeNames().size() == 0) {
      return new ArrayList(0);
    }
    List variables = getVariables();
    List retList = new ArrayList(variables.size());
    Iterator iter = variables.iterator();
    while (iter.hasNext())
    {
      LocalVariable variable = (LocalVariable)iter.next();
      if (variable.isArgument()) {
        retList.add(variable);
      }
    }
    return retList;
  }
  
  public byte[] bytecodes()
  {
    byte[] bytecodes = bytecodesRef == null ? null : (byte[])bytecodesRef.get();
    if (bytecodes == null)
    {
      bytecodes = saMethod.getByteCode();
      bytecodesRef = new SoftReference(bytecodes);
    }
    return (byte[])bytecodes.clone();
  }
  
  public Location location()
  {
    if (location == null) {
      getBaseLocations();
    }
    return location;
  }
  
  private List getVariables()
    throws AbsentInformationException
  {
    List variables = variablesRef == null ? null : (List)variablesRef.get();
    if (variables != null) {
      return variables;
    }
    if (saMethod.getMaxLocals() == 0L)
    {
      variables = Collections.unmodifiableList(new ArrayList(0));
      variablesRef = new SoftReference(variables);
      return variables;
    }
    if (!saMethod.hasLocalVariableTable()) {
      throw new AbsentInformationException();
    }
    LocalVariableTableElement[] locals = saMethod.getLocalVariableTable();
    int localCount = locals.length;
    variables = new ArrayList(localCount);
    for (int ii = 0; ii < localCount; ii++)
    {
      String name = saMethod.getConstants().getSymbolAt(locals[ii].getNameCPIndex()).asString();
      
      boolean isInternalName = (name.startsWith("this")) && ((name.length() == 4) || (name.charAt(4) == '$') || (!Character.isJavaIdentifierPart(name.charAt(4))));
      if (!isInternalName)
      {
        int slot = locals[ii].getSlot();
        long codeIndex = locals[ii].getStartBCI();
        int length = locals[ii].getLength();
        Location scopeStart = new LocationImpl(virtualMachine(), this, codeIndex);
        
        Location scopeEnd = new LocationImpl(virtualMachine(), this, codeIndex + length - 1L);
        
        String signature = saMethod.getConstants().getSymbolAt(locals[ii].getDescriptorCPIndex()).asString();
        
        int genericSigIndex = locals[ii].getSignatureCPIndex();
        String genericSignature = null;
        if (genericSigIndex != 0) {
          genericSignature = saMethod.getConstants().getSymbolAt(genericSigIndex).asString();
        }
        LocalVariable variable = new LocalVariableImpl(virtualMachine(), this, slot, scopeStart, scopeEnd, name, signature, genericSignature);
        
        variables.add(variable);
      }
    }
    variables = Collections.unmodifiableList(variables);
    variablesRef = new SoftReference(variables);
    return variables;
  }
}

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;

final class ConnectorImpl$1
  implements Observer
{
  private final Object val$vm;
  
  ConnectorImpl$1(Object paramObject) {}
  
  public void update(Observable o, Object data)
  {
    if (ConnectorImpl.DEBUG) {
      System.out.println("got VM.dispose notification");
    }
    ConnectorImpl.access$000(val$vm.getClass());
  }
}

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

import com.sun.jdi.InternalException;
import com.sun.jdi.connect.Connector.Argument;
import java.io.Serializable;

abstract class ConnectorImpl$ArgumentImpl
  implements Connector.Argument, Cloneable, Serializable
{
  private String name;
  private String label;
  private String description;
  private String value;
  private boolean mustSpecify;
  private final ConnectorImpl this$0;
  
  ConnectorImpl$ArgumentImpl(ConnectorImpl paramConnectorImpl, String name, String label, String description, String value, boolean mustSpecify)
  {
    this.name = name;
    this.label = label;
    this.description = description;
    this.value = value;
    this.mustSpecify = mustSpecify;
  }
  
  public abstract boolean isValid(String paramString);
  
  public String name()
  {
    return name;
  }
  
  public String label()
  {
    return label;
  }
  
  public String description()
  {
    return description;
  }
  
  public String value()
  {
    return value;
  }
  
  public void setValue(String value)
  {
    if (value == null) {
      throw new NullPointerException("Can't set null value");
    }
    this.value = value;
  }
  
  public boolean mustSpecify()
  {
    return mustSpecify;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj != null) && ((obj instanceof Connector.Argument)))
    {
      Connector.Argument other = (Connector.Argument)obj;
      return (name().equals(other.name())) && (description().equals(other.description())) && (mustSpecify() == other.mustSpecify()) && (value().equals(other.value()));
    }
    return false;
  }
  
  public int hashCode()
  {
    return description().hashCode();
  }
  
  public Object clone()
  {
    try
    {
      return super.clone();
    }
    catch (CloneNotSupportedException e)
    {
      throw ((InternalException)new InternalException().initCause(e));
    }
  }
  
  public String toString()
  {
    return name() + "=" + value();
  }
}

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

import com.sun.jdi.connect.Connector.BooleanArgument;

class ConnectorImpl$BooleanArgumentImpl
  extends ConnectorImpl.ArgumentImpl
  implements Connector.BooleanArgument
{
  private final ConnectorImpl this$0;
  
  ConnectorImpl$BooleanArgumentImpl(ConnectorImpl paramConnectorImpl, String name, String label, String description, boolean value, boolean mustSpecify)
  {
    super(paramConnectorImpl, name, label, description, null, mustSpecify);
    if (ConnectorImpl.trueString == null)
    {
      ConnectorImpl.trueString = paramConnectorImpl.getString("true");
      ConnectorImpl.falseString = paramConnectorImpl.getString("false");
    }
    setValue(value);
  }
  
  public void setValue(boolean value)
  {
    setValue(stringValueOf(value));
  }
  
  public boolean isValid(String value)
  {
    return (value.equals(ConnectorImpl.trueString)) || (value.equals(ConnectorImpl.falseString));
  }
  
  public String stringValueOf(boolean value)
  {
    return value ? ConnectorImpl.trueString : ConnectorImpl.falseString;
  }
  
  public boolean booleanValue()
  {
    return value().equals(ConnectorImpl.trueString);
  }
}

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

import com.sun.jdi.connect.Connector.IntegerArgument;

class ConnectorImpl$IntegerArgumentImpl
  extends ConnectorImpl.ArgumentImpl
  implements Connector.IntegerArgument
{
  private final int min;
  private final int max;
  private final ConnectorImpl this$0;
  
  ConnectorImpl$IntegerArgumentImpl(ConnectorImpl paramConnectorImpl, String name, String label, String description, String value, boolean mustSpecify, int min, int max)
  {
    super(paramConnectorImpl, name, label, description, value, mustSpecify);
    this.min = min;
    this.max = max;
  }
  
  public void setValue(int value)
  {
    setValue(stringValueOf(value));
  }
  
  public boolean isValid(String value)
  {
    if (value == null) {
      return false;
    }
    try
    {
      return isValid(Integer.decode(value).intValue());
    }
    catch (NumberFormatException exc) {}
    return false;
  }
  
  public boolean isValid(int value)
  {
    return (min <= value) && (value <= max);
  }
  
  public String stringValueOf(int value)
  {
    return "" + value;
  }
  
  public int intValue()
  {
    if (value() == null) {
      return 0;
    }
    try
    {
      return Integer.decode(value()).intValue();
    }
    catch (NumberFormatException exc) {}
    return 0;
  }
  
  public int max()
  {
    return max;
  }
  
  public int min()
  {
    return min;
  }
}

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

import com.sun.jdi.connect.Connector.SelectedArgument;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class ConnectorImpl$SelectedArgumentImpl
  extends ConnectorImpl.ArgumentImpl
  implements Connector.SelectedArgument
{
  private final List choices;
  private final ConnectorImpl this$0;
  
  ConnectorImpl$SelectedArgumentImpl(ConnectorImpl paramConnectorImpl, String name, String label, String description, String value, boolean mustSpecify, List choices)
  {
    super(paramConnectorImpl, name, label, description, value, mustSpecify);
    this.choices = Collections.unmodifiableList(new ArrayList(choices));
  }
  
  public List choices()
  {
    return choices;
  }
  
  public boolean isValid(String value)
  {
    return choices.contains(value);
  }
}

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

import com.sun.jdi.connect.Connector.StringArgument;

class ConnectorImpl$StringArgumentImpl
  extends ConnectorImpl.ArgumentImpl
  implements Connector.StringArgument
{
  private final ConnectorImpl this$0;
  
  ConnectorImpl$StringArgumentImpl(ConnectorImpl paramConnectorImpl, String name, String label, String description, String value, boolean mustSpecify)
  {
    super(paramConnectorImpl, name, label, description, value, mustSpecify);
  }
  
  public boolean isValid(String value)
  {
    return true;
  }
}

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

import com.sun.jdi.InternalException;
import com.sun.jdi.connect.Connector;
import com.sun.jdi.connect.Connector.Argument;
import com.sun.jdi.connect.Connector.BooleanArgument;
import com.sun.jdi.connect.Connector.IntegerArgument;
import com.sun.jdi.connect.Connector.SelectedArgument;
import com.sun.jdi.connect.Connector.StringArgument;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import java.io.File;
import java.io.PrintStream;
import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;

abstract class ConnectorImpl
  implements Connector
{
  ConnectorImpl()
  {
    defaultArguments = new LinkedHashMap();
  }
  
  static String trueString = null;
  private static ClassLoader myLoader = ConnectorImpl.class.getClassLoader();
  private static List freeVMClasses = new ArrayList(0);
  protected static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.jdi.ConnectorImpl.DEBUG") != null;
  Map defaultArguments;
  static String falseString;
  
  private static synchronized void addFreeVMImplClass(Class clazz)
  {
    if (DEBUG) {
      System.out.println("adding free VirtualMachineImpl class");
    }
    freeVMClasses.add(new SoftReference(clazz));
  }
  
  private static synchronized Class getFreeVMImplClass()
  {
    while (!freeVMClasses.isEmpty())
    {
      SoftReference ref = (SoftReference)freeVMClasses.remove(0);
      Object o = ref.get();
      if (o != null)
      {
        if (DEBUG) {
          System.out.println("re-using loaded VirtualMachineImpl");
        }
        return (Class)o;
      }
    }
    return null;
  }
  
  private static Class getVMImplClassFrom(ClassLoader cl)
    throws ClassNotFoundException
  {
    return Class.forName("sun.jvm.hotspot.jdi.VirtualMachineImpl", true, cl);
  }
  
  protected static Class loadVirtualMachineImplClass()
    throws ClassNotFoundException
  {
    Class vmImplClass = getFreeVMImplClass();
    if (vmImplClass == null)
    {
      ClassLoader cl = new SAJDIClassLoader(myLoader);
      vmImplClass = getVMImplClassFrom(cl);
    }
    return vmImplClass;
  }
  
  private static String getSAClassPathForVM(String vmVersion)
  {
    String prefix = "sun.jvm.hotspot.jdi.";
    
    String jvmHome = System.getProperty("sun.jvm.hotspot.jdi." + vmVersion);
    if (DEBUG) {
      System.out.println("looking for System property sun.jvm.hotspot.jdi." + vmVersion);
    }
    if (jvmHome == null)
    {
      int index = vmVersion.indexOf('-');
      if (index != -1)
      {
        vmVersion = vmVersion.substring(0, index);
        if (DEBUG) {
          System.out.println("looking for System property sun.jvm.hotspot.jdi." + vmVersion);
        }
        jvmHome = System.getProperty("sun.jvm.hotspot.jdi." + vmVersion);
      }
      if (jvmHome == null)
      {
        if (DEBUG) {
          System.out.println("can't locate JDK home for " + vmVersion);
        }
        return null;
      }
    }
    if (DEBUG) {
      System.out.println("JDK home for " + vmVersion + " is " + jvmHome);
    }
    StringBuffer buf = new StringBuffer();
    buf.append(jvmHome);
    buf.append(File.separatorChar);
    buf.append("lib");
    buf.append(File.separatorChar);
    buf.append("sa-jdi.jar");
    return buf.toString();
  }
  
  protected static Class loadVirtualMachineImplClass(String vmVersion)
    throws ClassNotFoundException
  {
    if (DEBUG) {
      System.out.println("attemping to load sa-jdi.jar for version " + vmVersion);
    }
    String classPath = getSAClassPathForVM(vmVersion);
    if (classPath != null)
    {
      ClassLoader cl = new SAJDIClassLoader(myLoader, classPath);
      return getVMImplClassFrom(cl);
    }
    return null;
  }
  
  private static boolean isVMVersionMismatch(Throwable throwable)
  {
    String className = throwable.getClass().getName();
    return className.equals("sun.jvm.hotspot.runtime.VMVersionMismatchException");
  }
  
  private static String getVMVersion(Throwable throwable)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
  {
    Class expClass = throwable.getClass();
    Method targetVersionMethod = expClass.getMethod("getTargetVersion", new Class[0]);
    return (String)targetVersionMethod.invoke(throwable, null);
  }
  
  protected static Class handleVMVersionMismatch(InvocationTargetException ite)
  {
    Throwable cause = ite.getCause();
    if (DEBUG) {
      System.out.println("checking for version mismatch...");
    }
    while (cause != null)
    {
      try
      {
        if (isVMVersionMismatch(cause))
        {
          if (DEBUG) {
            System.out.println("Triggering cross VM version support...");
          }
          return loadVirtualMachineImplClass(getVMVersion(cause));
        }
      }
      catch (Exception exp)
      {
        if (DEBUG)
        {
          System.out.println("failed to load VirtualMachineImpl class");
          exp.printStackTrace();
        }
        return null;
      }
      cause = cause.getCause();
    }
    return null;
  }
  
  protected void checkNativeLink(SecurityManager sm, String os)
  {
    if ((os.equals("SunOS")) || (os.equals("Linux"))) {
      sm.checkLink("saproc");
    } else if (os.startsWith("Windows")) {
      sm.checkLink("sawindbg");
    } else {
      throw new RuntimeException(os + " is not yet supported");
    }
  }
  
  protected static void setVMDisposeObserver(Object vm)
  {
    try
    {
      Method setDisposeObserverMethod = vm.getClass().getDeclaredMethod("setDisposeObserver", new Class[] { Observer.class });
      
      setDisposeObserverMethod.setAccessible(true);
      setDisposeObserverMethod.invoke(vm, new Object[] { new Observer()
      {
        private final Object val$vm;
        
        public void update(Observable o, Object data)
        {
          if (ConnectorImpl.DEBUG) {
            System.out.println("got VM.dispose notification");
          }
          ConnectorImpl.addFreeVMImplClass(val$vm.getClass());
        }
      } });
    }
    catch (Exception exp)
    {
      if (DEBUG)
      {
        System.out.println("setVMDisposeObserver() got an exception:");
        exp.printStackTrace();
      }
    }
  }
  
  public Map defaultArguments()
  {
    Map defaults = new LinkedHashMap();
    Collection values = defaultArguments.values();
    
    Iterator iter = values.iterator();
    while (iter.hasNext())
    {
      ArgumentImpl argument = (ArgumentImpl)iter.next();
      defaults.put(argument.name(), argument.clone());
    }
    return defaults;
  }
  
  void addStringArgument(String name, String label, String description, String defaultValue, boolean mustSpecify)
  {
    defaultArguments.put(name, new StringArgumentImpl(name, label, description, defaultValue, mustSpecify));
  }
  
  void addBooleanArgument(String name, String label, String description, boolean defaultValue, boolean mustSpecify)
  {
    defaultArguments.put(name, new BooleanArgumentImpl(name, label, description, defaultValue, mustSpecify));
  }
  
  void addIntegerArgument(String name, String label, String description, String defaultValue, boolean mustSpecify, int min, int max)
  {
    defaultArguments.put(name, new IntegerArgumentImpl(name, label, description, defaultValue, mustSpecify, min, max));
  }
  
  void addSelectedArgument(String name, String label, String description, String defaultValue, boolean mustSpecify, List list)
  {
    defaultArguments.put(name, new SelectedArgumentImpl(name, label, description, defaultValue, mustSpecify, list));
  }
  
  ArgumentImpl argument(String name, Map arguments)
    throws IllegalConnectorArgumentsException
  {
    ArgumentImpl argument = (ArgumentImpl)arguments.get(name);
    if (argument == null) {
      throw new IllegalConnectorArgumentsException("Argument missing", name);
    }
    String value = argument.value();
    if ((value == null) || (value.length() == 0))
    {
      if (argument.mustSpecify()) {
        throw new IllegalConnectorArgumentsException("Argument unspecified", name);
      }
    }
    else if (!argument.isValid(value)) {
      throw new IllegalConnectorArgumentsException("Argument invalid", name);
    }
    return argument;
  }
  
  String getString(String key)
  {
    return key;
  }
  
  public String toString()
  {
    String string = name() + " (defaults: ";
    Iterator iter = defaultArguments().values().iterator();
    boolean first = true;
    while (iter.hasNext())
    {
      ArgumentImpl argument = (ArgumentImpl)iter.next();
      if (!first) {
        string = string + ", ";
      }
      string = string + argument.toString();
      first = false;
    }
    return string + ")";
  }
  
  abstract class ArgumentImpl
    implements Connector.Argument, Cloneable, Serializable
  {
    private String name;
    private String label;
    private String description;
    private String value;
    private boolean mustSpecify;
    
    ArgumentImpl(String name, String label, String description, String value, boolean mustSpecify)
    {
      this.name = name;
      this.label = label;
      this.description = description;
      this.value = value;
      this.mustSpecify = mustSpecify;
    }
    
    public abstract boolean isValid(String paramString);
    
    public String name()
    {
      return name;
    }
    
    public String label()
    {
      return label;
    }
    
    public String description()
    {
      return description;
    }
    
    public String value()
    {
      return value;
    }
    
    public void setValue(String value)
    {
      if (value == null) {
        throw new NullPointerException("Can't set null value");
      }
      this.value = value;
    }
    
    public boolean mustSpecify()
    {
      return mustSpecify;
    }
    
    public boolean equals(Object obj)
    {
      if ((obj != null) && ((obj instanceof Connector.Argument)))
      {
        Connector.Argument other = (Connector.Argument)obj;
        return (name().equals(other.name())) && (description().equals(other.description())) && (mustSpecify() == other.mustSpecify()) && (value().equals(other.value()));
      }
      return false;
    }
    
    public int hashCode()
    {
      return description().hashCode();
    }
    
    public Object clone()
    {
      try
      {
        return super.clone();
      }
      catch (CloneNotSupportedException e)
      {
        throw ((InternalException)new InternalException().initCause(e));
      }
    }
    
    public String toString()
    {
      return name() + "=" + value();
    }
  }
  
  class BooleanArgumentImpl
    extends ConnectorImpl.ArgumentImpl
    implements Connector.BooleanArgument
  {
    BooleanArgumentImpl(String name, String label, String description, boolean value, boolean mustSpecify)
    {
      super(name, label, description, null, mustSpecify);
      if (ConnectorImpl.trueString == null)
      {
        ConnectorImpl.trueString = getString("true");
        ConnectorImpl.falseString = getString("false");
      }
      setValue(value);
    }
    
    public void setValue(boolean value)
    {
      setValue(stringValueOf(value));
    }
    
    public boolean isValid(String value)
    {
      return (value.equals(ConnectorImpl.trueString)) || (value.equals(ConnectorImpl.falseString));
    }
    
    public String stringValueOf(boolean value)
    {
      return value ? ConnectorImpl.trueString : ConnectorImpl.falseString;
    }
    
    public boolean booleanValue()
    {
      return value().equals(ConnectorImpl.trueString);
    }
  }
  
  class IntegerArgumentImpl
    extends ConnectorImpl.ArgumentImpl
    implements Connector.IntegerArgument
  {
    private final int min;
    private final int max;
    
    IntegerArgumentImpl(String name, String label, String description, String value, boolean mustSpecify, int min, int max)
    {
      super(name, label, description, value, mustSpecify);
      this.min = min;
      this.max = max;
    }
    
    public void setValue(int value)
    {
      setValue(stringValueOf(value));
    }
    
    public boolean isValid(String value)
    {
      if (value == null) {
        return false;
      }
      try
      {
        return isValid(Integer.decode(value).intValue());
      }
      catch (NumberFormatException exc) {}
      return false;
    }
    
    public boolean isValid(int value)
    {
      return (min <= value) && (value <= max);
    }
    
    public String stringValueOf(int value)
    {
      return "" + value;
    }
    
    public int intValue()
    {
      if (value() == null) {
        return 0;
      }
      try
      {
        return Integer.decode(value()).intValue();
      }
      catch (NumberFormatExcept
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