sa-jdi

n("Attempt to use non-static field with ReferenceType: " + fieldImpl.name());
      }
      map.put(fieldImpl, fieldImpl.getValue());
    }
    return map;
  }
  
  void validateFieldAccess(com.sun.jdi.Field field)
  {
    ReferenceTypeImpl declType = (ReferenceTypeImpl)field.declaringType();
    if (!declType.isAssignableFrom(this)) {
      throw new IllegalArgumentException("Invalid field");
    }
  }
  
  public ClassObjectReference classObject()
  {
    return vm.classObjectMirror(ref().getJavaMirror());
  }
  
  SDE.Stratum stratum(String stratumID)
  {
    SDE sde = sourceDebugExtensionInfo();
    if (!sde.isValid()) {
      sde = NO_SDE_INFO_MARK;
    }
    return sde.stratum(stratumID);
  }
  
  public String sourceName()
    throws AbsentInformationException
  {
    return (String)sourceNames(vm.getDefaultStratum()).get(0);
  }
  
  public List sourceNames(String stratumID)
    throws AbsentInformationException
  {
    SDE.Stratum stratum = stratum(stratumID);
    if (stratum.isJava())
    {
      List result = new ArrayList(1);
      result.add(baseSourceName());
      return result;
    }
    return stratum.sourceNames(this);
  }
  
  public List sourcePaths(String stratumID)
    throws AbsentInformationException
  {
    SDE.Stratum stratum = stratum(stratumID);
    if (stratum.isJava())
    {
      List result = new ArrayList(1);
      result.add(baseSourceDir() + baseSourceName());
      return result;
    }
    return stratum.sourcePaths(this);
  }
  
  String baseSourceName()
    throws AbsentInformationException
  {
    if ((saKlass instanceof ArrayKlass)) {
      throw new AbsentInformationException();
    }
    Symbol sym = ((InstanceKlass)saKlass).getSourceFileName();
    if (sym != null) {
      return sym.asString();
    }
    throw new AbsentInformationException();
  }
  
  String baseSourcePath()
    throws AbsentInformationException
  {
    return baseSourceDir() + baseSourceName();
  }
  
  String baseSourceDir()
  {
    String typeName = name();
    StringBuffer sb = new StringBuffer(typeName.length() + 10);
    int index = 0;
    int nextIndex;
    while ((nextIndex = typeName.indexOf('.', index)) > 0)
    {
      sb.append(typeName.substring(index, nextIndex));
      sb.append(File.separatorChar);
      index = nextIndex + 1;
    }
    return sb.toString();
  }
  
  public String sourceDebugExtension()
    throws AbsentInformationException
  {
    if (!vm.canGetSourceDebugExtension()) {
      throw new UnsupportedOperationException();
    }
    SDE sde = sourceDebugExtensionInfo();
    if (sde == NO_SDE_INFO_MARK) {
      throw new AbsentInformationException();
    }
    return sourceDebugExtension;
  }
  
  private SDE sourceDebugExtensionInfo()
  {
    if (!vm.canGetSourceDebugExtension()) {
      return NO_SDE_INFO_MARK;
    }
    SDE sde = null;
    sde = sdeRef == null ? null : (SDE)sdeRef.get();
    if (sde == null)
    {
      String extension = null;
      if ((saKlass instanceof InstanceKlass))
      {
        Symbol sdeSym = ((InstanceKlass)saKlass).getSourceDebugExtension();
        extension = sdeSym != null ? sdeSym.asString() : null;
      }
      if (extension == null) {
        sde = NO_SDE_INFO_MARK;
      } else {
        sde = new SDE(extension);
      }
      sdeRef = new SoftReference(sde);
    }
    return sde;
  }
  
  public List availableStrata()
  {
    SDE sde = sourceDebugExtensionInfo();
    if (sde.isValid()) {
      return sde.availableStrata();
    }
    List strata = new ArrayList();
    strata.add("Java");
    return strata;
  }
  
  public String defaultStratum()
  {
    SDE sdei = sourceDebugExtensionInfo();
    if (sdei.isValid()) {
      return defaultStratumId;
    }
    return "Java";
  }
  
  public final int modifiers()
  {
    if (modifiers == -1) {
      modifiers = getModifiers();
    }
    return modifiers;
  }
  
  public List instances(long maxInstances)
  {
    if (!vm.canGetInstanceInfo()) {
      throw new UnsupportedOperationException("target does not support getting instances");
    }
    if (maxInstances < 0L) {
      throw new IllegalArgumentException("maxInstances is less than zero: " + maxInstances);
    }
    final List objects = new ArrayList(0);
    if ((isAbstract()) || ((this instanceof InterfaceType))) {
      return objects;
    }
    final Klass givenKls = ref();
    final long max = maxInstances;
    vm.saObjectHeap().iterate(new DefaultHeapVisitor()
    {
      private long instCount = 0L;
      
      public boolean doObj(Oop oop)
      {
        if (givenKls.equals(oop.getKlass()))
        {
          objects.add(vm.objectMirror(oop));
          instCount += 1L;
        }
        if ((max > 0L) && (instCount >= max)) {
          return true;
        }
        return false;
      }
    });
    return objects;
  }
  
  int getModifiers()
  {
    return (int)saKlass.getClassModifiers();
  }
  
  public List allLineLocations()
    throws AbsentInformationException
  {
    return allLineLocations(vm.getDefaultStratum(), null);
  }
  
  public List allLineLocations(String stratumID, String sourceName)
    throws AbsentInformationException
  {
    checkPrepared();
    boolean someAbsent = false;
    SDE.Stratum stratum = stratum(stratumID);
    List list = new ArrayList();
    for (Iterator iter = methods().iterator(); iter.hasNext();)
    {
      MethodImpl method = (MethodImpl)iter.next();
      try
      {
        list.addAll(method.allLineLocations(stratum.id(), sourceName));
      }
      catch (AbsentInformationException exc)
      {
        someAbsent = true;
      }
    }
    if ((someAbsent) && (list.size() == 0)) {
      throw new AbsentInformationException();
    }
    return list;
  }
  
  public List locationsOfLine(int lineNumber)
    throws AbsentInformationException
  {
    return locationsOfLine(vm.getDefaultStratum(), null, lineNumber);
  }
  
  public List locationsOfLine(String stratumID, String sourceName, int lineNumber)
    throws AbsentInformationException
  {
    checkPrepared();
    
    boolean someAbsent = false;
    
    boolean somePresent = false;
    List methods = methods();
    SDE.Stratum stratum = stratum(stratumID);
    
    List list = new ArrayList();
    
    Iterator iter = methods.iterator();
    while (iter.hasNext())
    {
      MethodImpl method = (MethodImpl)iter.next();
      if ((!method.isAbstract()) && (!method.isNative())) {
        try
        {
          list.addAll(method.locationsOfLine(stratum.id(), sourceName, lineNumber));
          
          somePresent = true;
        }
        catch (AbsentInformationException exc)
        {
          someAbsent = true;
        }
      }
    }
    if ((someAbsent) && (!somePresent)) {
      throw new AbsentInformationException();
    }
    return list;
  }
  
  Klass ref()
  {
    return saKlass;
  }
  
  abstract boolean isAssignableTo(ReferenceType paramReferenceType);
  
  boolean isAssignableFrom(ReferenceType type)
  {
    return ((ReferenceTypeImpl)type).isAssignableTo(this);
  }
  
  boolean isAssignableFrom(ObjectReference object)
  {
    return (object == null) || (isAssignableFrom(object.referenceType()));
  }
  
  int indexOf(com.sun.jdi.Method method)
  {
    return methods().indexOf(method);
  }
  
  int indexOf(com.sun.jdi.Field field)
  {
    return fields().indexOf(field);
  }
  
  private static boolean isPrimitiveArray(String signature)
  {
    int i = signature.lastIndexOf('[');
    boolean isPA;
    boolean isPA;
    if (i < 0)
    {
      isPA = false;
    }
    else
    {
      char c = signature.charAt(i + 1);
      isPA = c != 'L';
    }
    return isPA;
  }
  
  Type findType(String signature)
    throws ClassNotLoadedException
  {
    Type type;
    Type type;
    if (signature.length() == 1)
    {
      char sig = signature.charAt(0);
      Type type;
      if (sig == 'V') {
        type = vm.theVoidType();
      } else {
        type = vm.primitiveTypeMirror(sig);
      }
    }
    else
    {
      ClassLoaderReferenceImpl loader = (ClassLoaderReferenceImpl)classLoader();
      Type type;
      if ((loader == null) || (isPrimitiveArray(signature))) {
        type = vm.findBootType(signature);
      } else {
        type = loader.findType(signature);
      }
    }
    return type;
  }
  
  String loaderString()
  {
    if (classLoader() != null) {
      return "loaded by " + classLoader().toString();
    }
    return "loaded by bootstrap loader";
  }
  
  long uniqueID()
  {
    return vm.getAddressValue(ref());
  }
  
  public int majorVersion()
  {
    if (!vm.canGetClassFileVersion()) {
      throw new UnsupportedOperationException("Cannot get class file version");
    }
    return (int)((InstanceKlass)saKlass).majorVersion();
  }
  
  public int minorVersion()
  {
    if (!vm.canGetClassFileVersion()) {
      throw new UnsupportedOperationException("Cannot get class file version");
    }
    return (int)((InstanceKlass)saKlass).minorVersion();
  }
  
  public int constantPoolCount()
  {
    if (!vm.canGetConstantPool()) {
      throw new UnsupportedOperationException("Cannot get constant pool");
    }
    if ((saKlass instanceof ArrayKlass)) {
      return 0;
    }
    return ((InstanceKlass)saKlass).getConstants().getLength();
  }
  
  public byte[] constantPool()
  {
    if (!vm.canGetConstantPool()) {
      throw new UnsupportedOperationException("Cannot get constant pool");
    }
    if (((this instanceof ArrayType)) || ((this instanceof PrimitiveType)))
    {
      byte[] bytes = new byte[0];
      return bytes;
    }
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    try
    {
      ((InstanceKlass)saKlass).getConstants().writeBytes(bs);
    }
    catch (IOException ex)
    {
      ex.printStackTrace();
      return new byte[0];
    }
    return bs.toByteArray();
  }
}

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

import com.sun.jdi.connect.Transport;

final class SACoreAttachingConnector$1
  implements Transport
{
  private final SACoreAttachingConnector this$0;
  
  SACoreAttachingConnector$1(SACoreAttachingConnector paramSACoreAttachingConnector) {}
  
  public String name()
  {
    return "filesystem";
  }
}

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

import com.sun.jdi.Bootstrap;
import com.sun.jdi.VirtualMachine;
import com.sun.jdi.VirtualMachineManager;
import com.sun.jdi.connect.AttachingConnector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import com.sun.jdi.connect.Transport;
import com.sun.tools.jdi.VirtualMachineManagerService;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;

public class SACoreAttachingConnector
  extends ConnectorImpl
  implements AttachingConnector
{
  static final String ARG_COREFILE = "core";
  static final String ARG_JAVA_EXECUTABLE = "javaExecutable";
  private Transport transport;
  
  public SACoreAttachingConnector(VirtualMachineManagerService ignored)
  {
    this();
  }
  
  public SACoreAttachingConnector()
  {
    addStringArgument("javaExecutable", "Java Executable", "Pathname of Java Executable", "", true);
    
    addStringArgument("core", "Corefile", "Pathname of a corefile from a Java Process", "core", false);
    
    transport = new Transport()
    {
      public String name()
      {
        return "filesystem";
      }
    };
  }
  
  private void checkCoreAttach(String corefile)
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      try
      {
        checkNativeLink(sm, System.getProperty("os.name"));
        
        sm.checkRead(corefile);
      }
      catch (SecurityException se)
      {
        throw new SecurityException("permission denied to attach to " + corefile);
      }
    }
  }
  
  private VirtualMachine createVirtualMachine(Class vmImplClass, String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
  {
    Method connectByCoreMethod = vmImplClass.getMethod("createVirtualMachineForCorefile", new Class[] { VirtualMachineManager.class, String.class, String.class, Integer.TYPE });
    
    return (VirtualMachine)connectByCoreMethod.invoke(null, new Object[] { Bootstrap.virtualMachineManager(), javaExec, corefile, new Integer(0) });
  }
  
  public VirtualMachine attach(Map arguments)
    throws IOException, IllegalConnectorArgumentsException
  {
    String javaExec = argument("javaExecutable", arguments).value();
    if ((javaExec == null) || (javaExec.equals(""))) {
      throw new IllegalConnectorArgumentsException("javaExec should be non-null and non-empty", "javaExecutable");
    }
    String corefile = argument("core", arguments).value();
    if ((corefile == null) || (corefile.equals(""))) {
      throw new IllegalConnectorArgumentsException("corefile should be non-null and non-empty", "core");
    }
    checkCoreAttach(corefile);
    
    VirtualMachine myVM = null;
    try
    {
      try
      {
        Class vmImplClass = loadVirtualMachineImplClass();
        myVM = createVirtualMachine(vmImplClass, javaExec, corefile);
      }
      catch (InvocationTargetException ite)
      {
        Class vmImplClass = handleVMVersionMismatch(ite);
        if (vmImplClass != null) {
          return createVirtualMachine(vmImplClass, javaExec, corefile);
        }
        throw ite;
      }
    }
    catch (Exception ee)
    {
      if (DEBUG)
      {
        System.out.println("VirtualMachineImpl() got an exception:");
        ee.printStackTrace();
        System.out.println("coreFile = " + corefile + ", javaExec = " + javaExec);
      }
      throw ((IOException)new IOException().initCause(ee));
    }
    setVMDisposeObserver(myVM);
    return myVM;
  }
  
  public String name()
  {
    return "sun.jvm.hotspot.jdi.SACoreAttachingConnector";
  }
  
  public String description()
  {
    return getString("This connector allows you to attach to a core file using the Serviceability Agent");
  }
  
  public Transport transport()
  {
    return transport;
  }
}

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

import java.io.PrintStream;
import sun.jvm.hotspot.DebugServer;

public final class SADebugServer
{
  private static void usage()
  {
    PrintStream out = System.out;
    out.println("Usage: jsadebugd [options] <pid> [server-id]");
    out.println("\t\t(to connect to a live java process)");
    out.println("   or  jsadebugd [options] <executable> <core> [server-id]");
    out.println("\t\t(to connect to a core file produced by <executable>)");
    out.println("\t\tserver-id is an optional unique id for this debug server, needed ");
    out.println("\t\tif multiple debug servers are run on the same machine");
    out.println("where options include:");
    out.println("   -h | -help\tto print this help message");
    System.exit(1);
  }
  
  public static void main(String[] args)
  {
    if ((args.length < 1) || (args.length > 3)) {
      usage();
    }
    if (args[0].startsWith("-")) {
      usage();
    }
    System.setProperty("sun.jvm.hotspot.debugger.useProcDebugger", "true");
    System.setProperty("sun.jvm.hotspot.debugger.useWindbgDebugger", "true");
    
    DebugServer.main(args);
  }
}

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

import com.sun.jdi.connect.Transport;

final class SADebugServerAttachingConnector$1
  implements Transport
{
  private final SADebugServerAttachingConnector this$0;
  
  SADebugServerAttachingConnector$1(SADebugServerAttachingConnector paramSADebugServerAttachingConnector) {}
  
  public String name()
  {
    return "RMI";
  }
}

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

import com.sun.jdi.Bootstrap;
import com.sun.jdi.VirtualMachine;
import com.sun.jdi.VirtualMachineManager;
import com.sun.jdi.connect.AttachingConnector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import com.sun.jdi.connect.Transport;
import com.sun.tools.jdi.VirtualMachineManagerService;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;

public class SADebugServerAttachingConnector
  extends ConnectorImpl
  implements AttachingConnector
{
  static final String ARG_DEBUG_SERVER_NAME = "debugServerName";
  private Transport transport;
  
  public SADebugServerAttachingConnector(VirtualMachineManagerService ignored)
  {
    this();
  }
  
  public SADebugServerAttachingConnector()
  {
    addStringArgument("debugServerName", "Debug Server", "Name of a remote SA Debug Server", "", true);
    
    transport = new Transport()
    {
      public String name()
      {
        return "RMI";
      }
    };
  }
  
  private VirtualMachine createVirtualMachine(Class vmImplClass, String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
  {
    Method connectByServerMethod = vmImplClass.getMethod("createVirtualMachineForServer", new Class[] { VirtualMachineManager.class, String.class, Integer.TYPE });
    
    return (VirtualMachine)connectByServerMethod.invoke(null, new Object[] { Bootstrap.virtualMachineManager(), debugServerName, new Integer(0) });
  }
  
  public VirtualMachine attach(Map arguments)
    throws IOException, IllegalConnectorArgumentsException
  {
    String debugServerName = argument("debugServerName", arguments).value();
    if ((debugServerName == null) || (debugServerName.equals(""))) {
      throw new IllegalConnectorArgumentsException("debugServerName should be non-null and non-empty", "debugServerName");
    }
    VirtualMachine myVM;
    try
    {
      try
      {
        Class vmImplClass = loadVirtualMachineImplClass();
        myVM = createVirtualMachine(vmImplClass, debugServerName);
      }
      catch (InvocationTargetException ite)
      {
        Class vmImplClass = handleVMVersionMismatch(ite);
        if (vmImplClass != null) {
          return createVirtualMachine(vmImplClass, debugServerName);
        }
        throw ite;
      }
    }
    catch (Exception ee)
    {
      if (DEBUG)
      {
        System.out.println("VirtualMachineImpl() got an exception:");
        ee.printStackTrace();
        System.out.println("debug server name = " + debugServerName);
      }
      throw ((IOException)new IOException().initCause(ee));
    }
    setVMDisposeObserver(myVM);
    return myVM;
  }
  
  public String name()
  {
    return "sun.jvm.hotspot.jdi.SADebugServerAttachingConnector";
  }
  
  public String description()
  {
    return getString("This connector allows you to attach to a Java Process via a debug server with the Serviceability Agent");
  }
  
  public Transport transport()
  {
    return transport;
  }
}

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

import java.io.File;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;

class SAJDIClassLoader
  extends URLClassLoader
{
  private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.jdi.SAJDIClassLoader.DEBUG") != null;
  private ClassLoader parent;
  private boolean classPathSet;
  
  SAJDIClassLoader(ClassLoader parent)
  {
    super(new URL[0], parent);
    this.parent = parent;
  }
  
  SAJDIClassLoader(ClassLoader parent, String classPath)
  {
    this(parent);
    classPathSet = true;
    try
    {
      addURL(new File(classPath).toURI().toURL());
    }
    catch (MalformedURLException mue)
    {
      throw new RuntimeException(mue);
    }
  }
  
  public synchronized Class loadClass(String name)
    throws ClassNotFoundException
  {
    Class c = findLoadedClass(name);
    if (c == null)
    {
      if ((name.startsWith("sun.jvm.hotspot.")) && (!name.startsWith("sun.jvm.hotspot.debugger."))) {
        return findClass(name);
      }
      if (parent != null) {
        c = parent.loadClass(name);
      } else {
        c = findSystemClass(name);
      }
    }
    return c;
  }
  
  protected Class findClass(String name)
    throws ClassNotFoundException
  {
    if (DEBUG) {
      System.out.println("SA/JDI loader: about to load " + name);
    }
    if (classPathSet) {
      return super.findClass(name);
    }
    byte[] b = null;
    try
    {
      InputStream in = getResourceAsStream(name.replace('.', '/') + ".class");
      
      b = new byte['?'];
      int total = 0;
      int len = 0;
      while ((len = in.read(b, total, b.length - total)) != -1)
      {
        total += len;
        if (total >= b.length)
        {
          byte[] tmp = new byte[total * 2];
          System.arraycopy(b, 0, tmp, 0, total);
          b = tmp;
        }
      }
      if (total != b.length)
      {
        byte[] tmp = new byte[total];
        System.arraycopy(b, 0, tmp, 0, total);
        b = tmp;
      }
    }
    catch (Exception exp)
    {
      throw ((ClassNotFoundException)new ClassNotFoundException().initCause(exp));
    }
    return defineClass(name, b, 0, b.length);
  }
}

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

import com.sun.jdi.connect.Transport;

final class SAPIDAttachingConnector$1
  implements Transport
{
  private final SAPIDAttachingConnector this$0;
  
  SAPIDAttachingConnector$1(SAPIDAttachingConnector paramSAPIDAttachingConnector) {}
  
  public String name()
  {
    return "local process";
  }
}

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

import com.sun.jdi.Bootstrap;
import com.sun.jdi.VirtualMachine;
import com.sun.jdi.VirtualMachineManager;
import com.sun.jdi.connect.AttachingConnector;
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
import com.sun.jdi.connect.Transport;
import com.sun.tools.jdi.VirtualMachineManagerService;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;

public class SAPIDAttachingConnector
  extends ConnectorImpl
  implements AttachingConnector
{
  static final String ARG_PID = "pid";
  private Transport transport;
  
  public SAPIDAttachingConnector(VirtualMachineManagerService ignored)
  {
    this();
  }
  
  public SAPIDAttachingConnector()
  {
    addStringArgument("pid", "PID", "PID of a Java process", "", true);
    
    transport = new Transport()
    {
      public String name()
      {
        return "local process";
      }
    };
  }
  
  private void checkProcessAttach(int pid)
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    {
      String os = System.getProperty("os.name");
      try
      {
        checkNativeLink(sm, os);
        if ((os.equals("SunOS")) || (os.equals("Linux"))) {
          sm.checkRead("/proc/" + pid);
        }
      }
      catch (SecurityException se)
      {
        throw new SecurityException("permission denied to attach to " + pid);
      }
    }
  }
  
  private VirtualMachine createVirtualMachine(Class virtualMachineImplClass, int pid)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
  {
    Method createByPIDMethod = virtualMachineImplClass.getMethod("createVirtualMachineForPID", new Class[] { VirtualMachineManager.class, Integer.TYPE, Integer.TYPE });
    
    return (VirtualMachine)createByPIDMethod.invoke(null, new Object[] { Bootstrap.virtualMachineManager(), new Integer(pid), new Integer(0) });
  }
  
  public VirtualMachine attach(Map arguments)
    throws IOException, IllegalConnectorArgumentsException
  {
    int pid = 0;
    try
    {
      pid = Integer.parseInt(argument("pid", arguments).value());
    }
    catch (NumberFormatException nfe)
    {
      throw ((IllegalConnectorArgumentsException)new IllegalConnectorArgumentsException(nfe.getMessage(), "pid").initCause(nfe));
    }
    checkProcessAttach(pid);
    
    VirtualMachine myVM = null;
    try
    {
      try
      {
        Class vmImplClass = loadVirtualMachineImplClass();
        myVM = createVirtualMachine(vmImplClass, pid);
      }
      catch (InvocationTargetException ite)
      {
        Class vmImplClass = handleVMVersionMismatch(ite);
        if (vmImplClass != null) {
          return createVirtualMachine(vmImplClass, pid);
        }
        throw ite;
      }
    }
    catch (Exception ee)
    {
      if (DEBUG)
      {
        System.out.println("VirtualMachineImpl() got an exception:");
        ee.printStackTrace();
        System.out.println("pid = " + pid);
      }
      throw ((IOException)new IOException().initCause(ee));
    }
    setVMDisposeObserver(myVM);
    return myVM;
  }
  
  public String name()
  {
    return "sun.jvm.hotspot.jdi.SAPIDAttachingConnector";
  }
  
  public String description()
  {
    return getString("This connector allows you to attach to a Java process using the Serviceability Agent");
  }
  
  public Transport transport()
  {
    return transport;
  }
}

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

class SDE$1 {}

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

import java.io.File;

class SDE$FileTableRecord
{
  int fileId;
  String sourceName;
  String sourcePath;
  
  SDE$FileTableRecord(SDE x0, SDE.1 x1)
  {
    this(x0);
  }
  
  boolean isConverted = false;
  private final SDE this$0;
  
  String getSourcePath(ReferenceTypeImpl refType)
  {
    if (!isConverted)
    {
      if (sourcePath == null)
      {
        sourcePath = (refType.baseSourceDir() + sourceName);
      }
      else
      {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < sourcePath.length(); i++)
        {
          char ch = sourcePath.charAt(i);
          if (ch == '/') {
            buf.append(File.separatorChar);
          } else {
            buf.append(ch);
          }
        }
        sourcePath = buf.toString();
      }
      isConverted = true;
    }
    return sourcePath;
  }
  
  private SDE$FileTableRecord(SDE paramSDE) {}
}

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

class SDE$LineStratum
{
  private final int sti;
  private final int lti;
  private final ReferenceTypeImpl refType;
  private final int jplsLine;
  
  SDE$LineStratum(SDE x0, int x1, int x2, ReferenceTypeImpl x3, int x4, SDE.1 x5)
  {
    this(x0, x1, x2, x3, x4);
  }
  
  private String sourceName = null;
  private String sourcePath = null;
  private final SDE this$0;
  
  private SDE$LineStratum(SDE paramSDE, int sti, int lti, ReferenceTypeImpl refType, int jplsLine)
  {
    this.sti = sti;
    this.lti = lti;
    this.refType = refType;
    this.jplsLine = jplsLine;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj != null) && ((obj instanceof LineStratum)))
    {
      LineStratum other = (LineStratum)obj;
      return (lti == lti) && (sti == sti) && (lineNumber() == other.lineNumber()) && (refType.equals(refType));
    }
    return false;
  }
  
  int lineNumber()
  {
    return SDE.access$500(this$0, sti, lti, jplsLine);
  }
  
  void getSourceInfo()
  {
    if (sourceName != null) {
      return;
    }
    int fti = SDE.access$600(this$0, sti, lti);
    if (fti == -1) {
      throw new InternalError("Bad SourceDebugExtension, no matching source id " + access$700this$0)[lti].fileId + " jplsLine: " + jplsLine);
    }
    SDE.FileTableRecord ftr = SDE.access$200(this$0)[fti];
    sourceName = sourceName;
    sourcePath = ftr.getSourcePath(refType);
  }
  
  String sourceName()
  {
    getSourceInfo();
    return sourceName;
  }
  
  String sourcePath()
  {
    getSourceInfo();
    return sourcePath;
  }
}

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

class SDE$LineTableRecord
{
  int jplsStart;
  int jplsEnd;
  int jplsLineInc;
  int njplsStart;
  int njplsEnd;
  int fileId;
  private final SDE this$0;
  
  private SDE$LineTableRecord(SDE paramSDE) {}
  
  SDE$LineTableRecord(SDE x0, SDE.1 x1)
  {
    this(x0);
  }
}

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

import java.util.ArrayList;
import java.util.List;

class SDE$Stratum
{
  private final int sti;
  private final SDE this$0;
  
  SDE$Stratum(SDE x0, int x1, SDE.1 x2)
  {
    this(x0, x1);
  }
  
  private SDE$Stratum(SDE paramSDE, int sti)
  {
    this.sti = sti;
  }
  
  String id()
  {
    return access$000this$0)[sti].id;
  }
  
  boolean isJava()
  {
    return sti == SDE.access$100(this$0);
  }
  
  List sourceNames(ReferenceTypeImpl refType)
  {
    int fileIndexStart = access$000this$0)[sti].fileIndex;
    
    int fileIndexEnd = access$000this$0)[(sti + 1)].fileIndex;
    List result = new ArrayList(fileIndexEnd - fileIndexStart);
    for (int i = fileIndexStart; i < fileIndexEnd; i++) {
      result.add(access$200this$0)[i].sourceName);
    }
    return result;
  }
  
  List sourcePaths(ReferenceTypeImpl refType)
  {
    int fileIndexStart = access$000this$0)[sti].fileIndex;
    
    int fileIndexEnd = access$000this$0)[(sti + 1)].fileIndex;
    List result = new ArrayList(fileIndexEnd - fileIndexStart);
    for (int i = fileIndexStart; i < fileIndexEnd; i++) {
      result.add(SDE.access$200(this$0)[i].getSourcePath(refType));
    }
    return result;
  }
  
  SDE.LineStratum lineStratum(ReferenceTypeImpl refType, int jplsLine)
  {
    int lti = SDE.access$300(this$0, sti, jplsLine);
    if (lti < 0) {
      return null;
    }
    return new SDE.LineStratum(this$0, sti, lti, refType, jplsLine, null);
  }
}

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

class SDE$StratumTableRecord
{
  String id;
  int fileIndex;
  int lineIndex;
  private final SDE this$0;
  
  private SDE$StratumTableRecord(SDE paramSDE) {}
  
  SDE$StratumTableRecord(SDE x0, SDE.1 x1)
  {
    this(x0);
  }
}

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

import java.io.File;
import java.util.ArrayList;
import java.util.List;

class SDE
{
  private static final int INIT_SIZE_FILE = 3;
  private static final int INIT_SIZE_LINE = 100;
  private static final int INIT_SIZE_STRATUM = 3;
  static final String BASE_STRATUM_NAME = "Java";
  static final String NullString = null;
  
  private class FileTableRecord
  {
    int fileId;
    String sourceName;
    String sourcePath;
    
    FileTableRecord(SDE.1 x1)
    {
      this();
    }
    
    boolean isConverted = false;
    
    String getSourcePath(ReferenceTypeImpl refType)
    {
      if (!isConverted)
      {
        if (sourcePath == null)
        {
          sourcePath = (refType.baseSourceDir() + sourceName);
        }
        else
        {
          StringBuffer buf = new StringBuffer();
          for (int i = 0; i < sourcePath.length(); i++)
          {
            char ch = sourcePath.charAt(i);
            if (ch == '/') {
              buf.append(File.separatorChar);
            } else {
              buf.append(ch);
            }
          }
          sourcePath = buf.toString();
        }
        isConverted = true;
      }
      return sourcePath;
    }
    
    private FileTableRecord() {}
  }
  
  private class LineTableRecord
  {
    int jplsStart;
    int jplsEnd;
    int jplsLineInc;
    int njplsStart;
    int njplsEnd;
    int fileId;
    
    private LineTableRecord() {}
    
    LineTableRecord(SDE.1 x1)
    {
      this();
    }
  }
  
  private class StratumTableRecord
  {
    String id;
    int fileIndex;
    int lineIndex;
    
    private StratumTableRecord() {}
    
    StratumTableRecord(SDE.1 x1)
    {
      this();
    }
  }
  
  class Stratum
  {
    private final int sti;
    
    Stratum(int x1, SDE.1 x2)
    {
      this(x1);
    }
    
    private Stratum(int sti)
    {
      this.sti = sti;
    }
    
    String id()
    {
      return stratumTable[sti].id;
    }
    
    boolean isJava()
    {
      return sti == baseStratumIndex;
    }
    
    List sourceNames(ReferenceTypeImpl refType)
    {
      int fileIndexStart = stratumTable[sti].fileIndex;
      
      int fileIndexEnd = stratumTable[(sti + 1)].fileIndex;
      List result = new ArrayList(fileIndexEnd - fileIndexStart);
      for (int i = fileIndexStart; i < fileIndexEnd; i++) {
        result.add(fileTable[i].sourceName);
      }
      return result;
    }
    
    List sourcePaths(ReferenceTypeImpl refType)
    {
      int fileIndexStart = stratumTable[sti].fileIndex;
      
      int fileIndexEnd = stratumTable[(sti + 1)].fileIndex;
      List result = new ArrayList(fileIndexEnd - fileIndexStart);
      for (int i = fileIndexStart; i < fileIndexEnd; i++) {
        result.add(fileTable[i].getSourcePath(refType));
      }
      return result;
    }
    
    SDE.LineStratum lineStratum(ReferenceTypeImpl refType, int jplsLine)
    {
      int lti = SDE.this.stiLineTableIndex(sti, jplsLine);
      if (lti < 0) {
        return null;
      }
      return new SDE.LineStratum(SDE.this, sti, lti, refType, jplsLine, null);
    }
  }
  
  class LineStratum
  {
    private final int sti;
    private final int lti;
    private final ReferenceTypeImpl refType;
    private final int jplsLine;
    
    LineStratum(int x1, int x2, ReferenceTypeImpl x3, int x4, SDE.1 x5)
    {
      this(x1, x2, x3, x4);
    }
    
    private String sourceName = null;
    private String sourcePath = null;
    
    private LineStratum(int sti, int lti, ReferenceTypeImpl refType, int jplsLine)
    {
      this.sti = sti;
      this.lti = lti;
      this.refType = refType;
      this.jplsLine = jplsLine;
    }
    
    public boolean equals(Object obj)
    {
      if ((obj != null) && ((obj instanceof LineStratum)))
      {
        LineStratum other = (LineStratum)obj;
        return (lti == lti) && (sti == sti) && (lineNumber() == other.lineNumber()) && (refType.equals(refType));
      }
      return false;
    }
    
    int lineNumber()
    {
      return SDE.this.stiLineNumber(sti, lti, jplsLine);
    }
    
    void getSourceInfo()
    {
      if (sourceName != null) {
        return;
      }
      int fti = SDE.this.stiFileTableIndex(sti, lti);
      if (fti == -1) {
        throw new InternalError("Bad SourceDebugExtension, no matching source id " + lineTable[lti].fileId + " jplsLine: " + jplsLine);
      }
      SDE.FileTableRecord ftr = fileTable[fti];
      sourceName = sourceName;
      sourcePath = ftr.getSourcePath(refType);
    }
    
    String sourceName()
    {
      getSourceInfo();
      return sourceName;
    }
    
    String sourcePath()
    {
      getSourceInfo();
      return sourcePath;
    }
  }
  
  private FileTableRecord[] fileTable = null;
  private LineTableRecord[] lineTable = null;
  private StratumTableRecord[] stratumTable = null;
  private int fileIndex = 0;
  private int lineIndex = 0;
  private int stratumIndex = 0;
  private int currentFileId = 0;
  private int defaultStratumIndex = -1;
  private int baseStratumIndex = -2;
  private int sdePos = 0;
  final String sourceDebugExtension;
  String jplsFilename = null;
  String defaultStratumId = null;
  boolean isValid = false;
  
  SDE(String sourceDebugExtension)
  {
    this.sourceDebugExtension = sourceDebugExtension;
    decode();
  }
  
  SDE()
  {
    sourceDebugExtension = null;
    createProxyForAbsentSDE();
  }
  
  char sdePeek()
  {
    if (sdePos >= sourceDebugExtension.length()) {
      syntax();
    }
    return sourceDebugExtension.charAt(sdePos);
  }
  
  char sdeRead()
  {
    if (sdePos >= sourceDebugExtension.length()) {
      syntax();
    }
    return sourceDebugExtension.charAt(sdePos++);
  }
  
  void sdeAdvance()
  {
    sdePos += 1;
  }
  
  void syntax()
  {
    throw new InternalError("bad SourceDebugExtension syntax - position " + sdePos);
  }
  
  void syntax(String msg)
  {
    throw new InternalError("bad SourceDebugExtension syntax: " + msg);
  }
  
  void assureLineTableSize()
  {
    int len = lineTable == null ? 0 : lineTable.length;
    if (lineIndex >= len)
    {
      int newLen = len == 0 ? 100 : len * 2;
      LineTableRecord[] newTable = new LineTableRecord[newLen];
      for (int i = 0; i < len; i++) {
        newTable[i] = lineTable[i];
      }
      for (; i < newLen; i++) {
        newTable[i] = new LineTableRecord(null);
      }
      lineTable = newTable;
    }
  }
  
  void assureFileTableSize()
  {
    int len = fileTable == null ? 0 : fileTable.length;
    if (fileIndex >= len)
    {
      int newLen = len == 0 ? 3 : len * 2;
      FileTableRecord[] newTable = new FileTableRecord[newLen];
      for (int i = 0; i < len; i++) {
        newTable[i] = fileTable[i];
      }
      for (; i < newLen; i++) {
        newTable[i] = new FileTableRecord(null);
      }
      fileTable = newTable;
    }
  }
  
  void assureStratumTableSize()
  {
    int len = stratumTable == null ? 0 : stratumTable.length;
    if (stratumIndex >= len)
    {
      int newLen = len == 0 ? 3 : len * 2;
      StratumTableRecord[] newTable = new StratumTableRecord[newLen];
      for (int i = 0; i < len; i++) {
        newTable[i] = stratumTable[i];
      }
      for (; i < newLen; i++) {
        newTable[i] = new StratumTableRecord(null);
      }
      stratumTable = newTable;
    }
  }
  
  String readLine()
  {
    StringBuffer sb = new StringBuffer();
    
    ignoreWhite();
    char ch;
    while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
      sb.append(ch);
    }
    if ((ch == '\r') && (sdePeek() == '\n')) {
      sdeRead();
    }
    ignoreWhite();
    return sb.toString();
  }
  
  private int defaultStratumTableIndex()
  {
    if ((defaultStratumIndex == -1) && (defaultStratumId != null)) {
      defaultStratumIndex = stratumTableIndex(defaultStratumId);
    }
    return defaultStratumIndex;
  }
  
  int stratumTableIndex(String stratumId)
  {
    if (stratumId == null) {
      return defaultStratumTableIndex();
    }
    for (int i = 0; i < stratumIndex - 1; i++) {
      if (stratumTable[i].id.equals(stratumId)) {
        return i;
      }
    }
    return defaultStratumTableIndex();
  }
  
  Stratum stratum(String stratumID)
  {
    int sti = stratumTableIndex(stratumID);
    return new Stratum(sti, null);
  }
  
  List availableStrata()
  {
    List strata = new ArrayList();
    for (int i = 0; i < stratumIndex - 1; i++)
    {
      StratumTableRecord rec = stratumTable[i];
      strata.add(id);
    }
    return strata;
  }
  
  void ignore
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