sa-jdi

     
          public void epilogue() {}
        });
      }
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    catch (Exception exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  public String genHTML(final CodeBlob blob)
  {
    try
    {
      final Formatter buf = new Formatter(genHTML);
      buf.genHTMLPrologue(genCodeBlobTitle(blob));
      buf.h3("CodeBlob");
      
      buf.h3("Compiled Code");
      sun.jvm.hotspot.debugger.Address codeBegin = blob.codeBegin();
      int codeSize = blob.getCodeSize();
      final long startPc = addressToLong(codeBegin);
      byte[] code = new byte[codeSize];
      for (int i = 0; i < code.length; i++) {
        code[i] = codeBegin.getJByteAt(i);
      }
      final SymbolFinder symFinder = createSymbolFinder();
      Disassembler disasm = createDisassembler(startPc, code);
      
      disasm.decode(new InstructionVisitor()
      {
        OopMapSet maps;
        OopMap curMap;
        int curMapIndex;
        long curMapOffset;
        
        public void prologue()
        {
          maps = blob.getOopMaps();
          if ((maps != null) && (maps.getSize() > 0L))
          {
            curMap = maps.getMapAt(0);
            if (curMap != null) {
              curMapOffset = curMap.getOffset();
            }
          }
        }
        
        public void visit(long currentPc, Instruction instr)
        {
          String href = null;
          if (instr.isCall())
          {
            CallInstruction call = (CallInstruction)instr;
            sun.jvm.hotspot.asm.Address addr = call.getBranchDestination();
            href = genPCHref(currentPc, addr);
          }
          buf.append("0x");
          buf.append(Long.toHexString(currentPc));
          buf.append(':');
          buf.append(tab);
          if (href != null) {
            buf.link(href, instr.asString(currentPc, symFinder));
          } else {
            buf.append(instr.asString(currentPc, symFinder));
          }
          buf.br();
          if (curMap != null)
          {
            long curOffset = currentPc - startPc;
            if (curOffset == curMapOffset)
            {
              buf.append(genOopMapInfo(curMap));
              if (++curMapIndex >= maps.getSize())
              {
                curMap = null;
              }
              else
              {
                curMap = maps.getMapAt(curMapIndex);
                if (curMap != null) {
                  curMapOffset = curMap.getOffset();
                }
              }
            }
          }
        }
        
        public void epilogue() {}
      });
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    catch (Exception exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  protected String genInterpreterCodeletTitle(InterpreterCodelet codelet)
  {
    Formatter buf = new Formatter(genHTML);
    buf.append("Interpreter codelet [");
    buf.append(codelet.codeBegin().toString());
    buf.append(',');
    buf.append(codelet.codeEnd().toString());
    buf.append(") - ");
    buf.append(codelet.getDescription());
    return buf.toString();
  }
  
  protected String genInterpreterCodeletLinkPageHref(StubQueue stubq)
  {
    return genBaseHref() + "interp_codelets";
  }
  
  public String genInterpreterCodeletLinksPage()
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue("Interpreter Codelets");
    buf.beginTag("ul");
    
    Interpreter interp = VM.getVM().getInterpreter();
    StubQueue code = interp.getCode();
    InterpreterCodelet stub = (InterpreterCodelet)code.getFirst();
    while (stub != null)
    {
      buf.beginTag("li");
      sun.jvm.hotspot.debugger.Address addr = stub.codeBegin();
      buf.link(genPCHref(addressToLong(addr)), stub.getDescription() + " @" + addr);
      buf.endTag("li");
      stub = (InterpreterCodelet)code.getNext(stub);
    }
    buf.endTag("ul");
    buf.genHTMLEpilogue();
    return buf.toString();
  }
  
  public String genHTML(InterpreterCodelet codelet)
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue(genInterpreterCodeletTitle(codelet));
    Interpreter interp = VM.getVM().getInterpreter();
    StubQueue stubq = interp.getCode();
    if (genHTML)
    {
      buf.beginTag("h3");
      buf.link(genInterpreterCodeletLinkPageHref(stubq), "View links for all codelets");
      buf.endTag("h3");
      buf.br();
    }
    Stub prev = stubq.getPrev(codelet);
    if (prev != null) {
      if (genHTML)
      {
        buf.beginTag("h3");
        buf.link(genPCHref(addressToLong(prev.codeBegin())), "View Previous Codelet");
        buf.endTag("h3");
        buf.br();
      }
      else
      {
        buf.h3("Previous Codelet = 0x" + Long.toHexString(addressToLong(prev.codeBegin())));
      }
    }
    buf.h3("Code");
    long stubStartPc = addressToLong(codelet.codeBegin());
    long stubEndPc = addressToLong(codelet.codeEnd());
    int range = (int)(stubEndPc - stubStartPc);
    byte[] stubCode = readBuffer(codelet.codeBegin(), range);
    Disassembler disasm = createDisassembler(stubStartPc, stubCode);
    disasm.decode(new RawCodeVisitor(buf));
    
    Stub next = stubq.getNext(codelet);
    if (next != null) {
      if (genHTML)
      {
        buf.beginTag("h3");
        buf.link(genPCHref(addressToLong(next.codeBegin())), "View Next Codelet");
        buf.endTag("h3");
      }
      else
      {
        buf.h3("Next Codelet = 0x" + Long.toHexString(addressToLong(next.codeBegin())));
      }
    }
    buf.genHTMLEpilogue();
    return buf.toString();
  }
  
  protected String genDumpKlassesTitle(InstanceKlass[] klasses)
  {
    return klasses.length == 1 ? "Create .class for this class" : "Create .class for all classes";
  }
  
  protected String genDumpKlassesHref(InstanceKlass[] klasses)
  {
    StringBuffer buf = new StringBuffer(genBaseHref());
    buf.append("jcore_multiple=");
    for (int k = 0; k < klasses.length; k++)
    {
      buf.append(klasses[k].getHandle().toString());
      buf.append(',');
    }
    return buf.toString();
  }
  
  protected String genDumpKlassesLink(InstanceKlass[] klasses)
  {
    if (!genHTML) {
      return "";
    }
    Formatter buf = new Formatter(genHTML);
    buf.link(genDumpKlassesHref(klasses), genDumpKlassesTitle(klasses));
    return buf.toString();
  }
  
  public String genHTMLForKlassNames(InstanceKlass[] klasses)
  {
    try
    {
      Formatter buf = new Formatter(genHTML);
      buf.genHTMLPrologue();
      buf.h3(genDumpKlassesLink(klasses));
      
      buf.append(genHTMLListForKlassNames(klasses));
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    catch (Exception exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  protected String genHTMLListForKlassNames(InstanceKlass[] klasses)
  {
    Formatter buf = new Formatter(genHTML);
    buf.beginTable(0);
    for (int i = 0; i < klasses.length; i++)
    {
      InstanceKlass ik = klasses[i];
      buf.beginTag("tr");
      buf.cell(genKlassLink(ik));
      buf.endTag("tr");
    }
    buf.endTable();
    return buf.toString();
  }
  
  public String genHTMLForMethodNames(InstanceKlass klass)
  {
    try
    {
      Formatter buf = new Formatter(genHTML);
      buf.genHTMLPrologue();
      buf.append(genHTMLListForMethods(klass));
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    catch (Exception exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  protected String genHTMLListForMethods(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    ObjArray methods = klass.getMethods();
    int numMethods = (int)methods.getLength();
    if (numMethods != 0)
    {
      buf.h3("Methods");
      buf.beginTag("ul");
      for (int m = 0; m < numMethods; m++)
      {
        Method mtd = (Method)methods.getObjAt(m);
        buf.li(genMethodLink(mtd) + ";");
      }
      buf.endTag("ul");
    }
    return buf.toString();
  }
  
  protected String genHTMLListForInterfaces(InstanceKlass klass)
  {
    try
    {
      Formatter buf = new Formatter(genHTML);
      ObjArray interfaces = klass.getLocalInterfaces();
      int numInterfaces = (int)interfaces.getLength();
      if (numInterfaces != 0)
      {
        buf.h3("Interfaces");
        buf.beginTag("ul");
        for (int i = 0; i < numInterfaces; i++)
        {
          InstanceKlass inf = (InstanceKlass)interfaces.getObjAt(i);
          buf.li(genKlassLink(inf));
        }
        buf.endTag("ul");
      }
      return buf.toString();
    }
    catch (Exception exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  protected String genFieldModifierString(AccessFlags acc)
  {
    Formatter buf = new Formatter(genHTML);
    if (acc.isPrivate()) {
      buf.append("private ");
    } else if (acc.isProtected()) {
      buf.append("protected ");
    } else if (acc.isPublic()) {
      buf.append("public ");
    }
    if (acc.isStatic()) {
      buf.append("static ");
    }
    if (acc.isFinal()) {
      buf.append("final ");
    }
    if (acc.isVolatile()) {
      buf.append("volatile ");
    }
    if (acc.isTransient()) {
      buf.append("transient ");
    }
    if (acc.isSynthetic()) {
      buf.append("[synthetic] ");
    }
    return buf.toString();
  }
  
  public String genHTMLForFieldNames(InstanceKlass klass)
  {
    try
    {
      Formatter buf = new Formatter(genHTML);
      buf.genHTMLPrologue();
      buf.append(genHTMLListForFields(klass));
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    catch (Exception exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  protected String genHTMLListForFields(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    TypeArray fields = klass.getFields();
    int numFields = (int)fields.getLength();
    ConstantPool cp = klass.getConstants();
    if (numFields != 0)
    {
      buf.h3("Fields");
      buf.beginList();
      for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET)
      {
        Field field = klass.getFieldByIndex(f);
        String f_name = ((NamedFieldIdentifier)field.getID()).getName();
        Symbol f_sig = field.getSignature();
        Symbol f_genSig = field.getGenericSignature();
        AccessFlags acc = field.getAccessFlagsObj();
        
        buf.beginListItem();
        buf.append(genFieldModifierString(acc));
        buf.append(' ');
        Formatter sigBuf = new Formatter(genHTML);
        new SignatureConverter(f_sig, sigBuf.getBuffer()).dispatchField();
        buf.append(sigBuf.toString().replace('/', '.'));
        buf.append(' ');
        buf.append(f_name);
        buf.append(';');
        if (f_genSig != null)
        {
          buf.append(" [signature ");
          buf.append(escapeHTMLSpecialChars(f_genSig.asString()));
          buf.append("] ");
        }
        buf.append(" (offset = " + field.getOffset() + ")");
        buf.endListItem();
      }
      buf.endList();
    }
    return buf.toString();
  }
  
  protected String genKlassHierarchyHref(InstanceKlass klass)
  {
    return genBaseHref() + "hierarchy=" + klass.getHandle();
  }
  
  protected String genKlassHierarchyTitle(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    buf.append("Class Hierarchy of ");
    buf.append(genKlassTitle(klass));
    return buf.toString();
  }
  
  protected String genKlassHierarchyLink(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    buf.link(genKlassHierarchyHref(klass), genKlassHierarchyTitle(klass));
    return buf.toString();
  }
  
  protected String genHTMLListForSubKlasses(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    Klass subklass = klass.getSubklassKlass();
    if (subklass != null)
    {
      buf.beginList();
      while (subklass != null)
      {
        if ((subklass instanceof InstanceKlass)) {
          buf.li(genKlassLink((InstanceKlass)subklass));
        }
        subklass = subklass.getNextSiblingKlass();
      }
      buf.endList();
    }
    return buf.toString();
  }
  
  public String genHTMLForKlassHierarchy(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue(genKlassHierarchyTitle(klass));
    
    buf.beginTag("pre");
    buf.append(genKlassLink(klass));
    buf.br();
    StringBuffer tabs = new StringBuffer(tab);
    InstanceKlass superKlass = klass;
    while ((superKlass = (InstanceKlass)superKlass.getSuper()) != null)
    {
      buf.append(tabs);
      buf.append(genKlassLink(superKlass));
      tabs.append(tab);
      buf.br();
    }
    buf.endTag("pre");
    
    Klass subklass = klass.getSubklassKlass();
    if (subklass != null)
    {
      buf.h3("Direct Subclasses");
      buf.append(genHTMLListForSubKlasses(klass));
    }
    buf.genHTMLEpilogue();
    return buf.toString();
  }
  
  protected String genDumpKlassHref(InstanceKlass klass)
  {
    return genBaseHref() + "jcore=" + klass.getHandle();
  }
  
  protected String genDumpKlassLink(InstanceKlass klass)
  {
    if (!genHTML) {
      return "";
    }
    Formatter buf = new Formatter(genHTML);
    buf.link(genDumpKlassHref(klass), "Create .class File");
    return buf.toString();
  }
  
  public String genHTML(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue(genKlassTitle(klass));
    InstanceKlass superKlass = (InstanceKlass)klass.getSuper();
    if (genHTML)
    {
      buf.beginTag("h3");
      buf.link(genKlassHierarchyHref(klass), "View Class Hierarchy");
      buf.endTag("h3");
    }
    buf.h3(genDumpKlassLink(klass));
    if (superKlass != null)
    {
      buf.h3("Super Class");
      buf.append(genKlassLink(superKlass));
    }
    buf.append(genHTMLListForInterfaces(klass));
    
    buf.append(genHTMLListForFields(klass));
    
    buf.append(genHTMLListForMethods(klass));
    
    buf.h3("Constant Pool");
    buf.append(genConstantPoolLink(klass.getConstants()));
    
    buf.genHTMLEpilogue();
    return buf.toString();
  }
  
  protected sun.jvm.hotspot.debugger.Address parseAddress(String address)
  {
    VM vm = VM.getVM();
    sun.jvm.hotspot.debugger.Address addr = vm.getDebugger().parseAddress(address);
    return addr;
  }
  
  protected long addressToLong(sun.jvm.hotspot.debugger.Address addr)
  {
    return VM.getVM().getDebugger().getAddressValue(addr);
  }
  
  protected sun.jvm.hotspot.debugger.Address longToAddress(long addr)
  {
    return parseAddress("0x" + Long.toHexString(addr));
  }
  
  protected Oop getOopAtAddress(sun.jvm.hotspot.debugger.Address addr)
  {
    OopHandle oopHandle = addr.addOffsetToAsOopHandle(0L);
    return VM.getVM().getObjectHeap().newOop(oopHandle);
  }
  
  protected Oop getOopAtAddress(String address)
  {
    sun.jvm.hotspot.debugger.Address addr = parseAddress(address);
    return getOopAtAddress(addr);
  }
  
  private void dumpKlass(InstanceKlass kls)
    throws IOException
  {
    String klassName = kls.getName().asString();
    klassName = klassName.replace('/', File.separatorChar);
    int index = klassName.lastIndexOf(File.separatorChar);
    File dir = null;
    if (index != -1)
    {
      String dirName = klassName.substring(0, index);
      dir = new File(".", dirName);
    }
    else
    {
      dir = new File(".");
    }
    dir.mkdirs();
    File f = new File(dir, klassName.substring(klassName.lastIndexOf(File.separatorChar) + 1) + ".class");
    
    f.createNewFile();
    FileOutputStream fis = new FileOutputStream(f);
    ClassWriter cw = new ClassWriter(kls, fis);
    cw.write();
  }
  
  public String genDumpKlass(InstanceKlass kls)
  {
    try
    {
      dumpKlass(kls);
      Formatter buf = new Formatter(genHTML);
      buf.genHTMLPrologue(genKlassTitle(kls));
      buf.append(".class created for ");
      buf.append(genKlassLink(kls));
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    catch (IOException exp)
    {
      return genHTMLErrorMessage(exp);
    }
  }
  
  protected String genJavaStackTraceTitle(JavaThread thread)
  {
    Formatter buf = new Formatter(genHTML);
    buf.append("Java Stack Trace for ");
    buf.append(thread.getThreadName());
    return buf.toString();
  }
  
  public String genHTMLForJavaStackTrace(JavaThread thread)
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue(genJavaStackTraceTitle(thread));
    
    buf.append("Thread state = ");
    buf.append(thread.getThreadState().toString());
    buf.br();
    buf.beginTag("pre");
    for (JavaVFrame vf = thread.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender())
    {
      Method method = vf.getMethod();
      buf.append(" - ");
      buf.append(genMethodLink(method));
      buf.append(" @bci = " + vf.getBCI());
      
      int lineNumber = method.getLineNumberFromBCI(vf.getBCI());
      if (lineNumber != -1)
      {
        buf.append(", line = ");
        buf.append(lineNumber);
      }
      sun.jvm.hotspot.debugger.Address pc = vf.getFrame().getPC();
      if (pc != null)
      {
        buf.append(", pc = ");
        buf.link(genPCHref(addressToLong(pc)), pc.toString());
      }
      if (vf.isCompiledFrame()) {
        buf.append(" (Compiled");
      } else if (vf.isInterpretedFrame()) {
        buf.append(" (Interpreted");
      }
      if (vf.mayBeImpreciseDbg()) {
        buf.append("; information may be imprecise");
      }
      buf.append(")");
      buf.br();
    }
    buf.endTag("pre");
    buf.genHTMLEpilogue();
    return buf.toString();
  }
  
  public String genHTMLForHyperlink(String href)
  {
    if (href.startsWith("klass="))
    {
      href = href.substring(href.indexOf('=') + 1);
      Oop obj = getOopAtAddress(href);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!");
      }
      return genHTML((InstanceKlass)obj);
    }
    if (href.startsWith("method="))
    {
      href = href.substring(href.indexOf('=') + 1);
      Oop obj = getOopAtAddress(href);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(obj instanceof Method, "method= href with improper Method!");
      }
      return genHTML((Method)obj);
    }
    if (href.startsWith("nmethod="))
    {
      String addr = href.substring(href.indexOf('=') + 1);
      Object obj = VMObjectFactory.newObject(NMethod.class, parseAddress(addr));
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(obj instanceof NMethod, "nmethod= href with improper NMethod!");
      }
      return genHTML((NMethod)obj);
    }
    if (href.startsWith("pc="))
    {
      String address = href.substring(href.indexOf('=') + 1);
      return genHTML(parseAddress(address));
    }
    if (href.startsWith("pc_multiple="))
    {
      int indexOfComma = href.indexOf(',');
      if (indexOfComma == -1)
      {
        String firstPC = href.substring(href.indexOf('=') + 1);
        return genHTMLForRawDisassembly(parseAddress(firstPC), null);
      }
      String firstPC = href.substring(href.indexOf('=') + 1, indexOfComma);
      return genHTMLForRawDisassembly(parseAddress(firstPC), href.substring(indexOfComma + 1));
    }
    if (href.startsWith("interp_codelets")) {
      return genInterpreterCodeletLinksPage();
    }
    if (href.startsWith("hierarchy="))
    {
      href = href.substring(href.indexOf('=') + 1);
      Oop obj = getOopAtAddress(href);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!");
      }
      return genHTMLForKlassHierarchy((InstanceKlass)obj);
    }
    if (href.startsWith("cpool="))
    {
      href = href.substring(href.indexOf('=') + 1);
      Oop obj = getOopAtAddress(href);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(obj instanceof ConstantPool, "cpool= href with improper ConstantPool!");
      }
      return genHTML((ConstantPool)obj);
    }
    if (href.startsWith("jcore="))
    {
      href = href.substring(href.indexOf('=') + 1);
      Oop obj = getOopAtAddress(href);
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(obj instanceof InstanceKlass, "jcore= href with improper InstanceKlass!");
      }
      return genDumpKlass((InstanceKlass)obj);
    }
    if (href.startsWith("jcore_multiple="))
    {
      href = href.substring(href.indexOf('=') + 1);
      Formatter buf = new Formatter(genHTML);
      buf.genHTMLPrologue();
      StringTokenizer st = new StringTokenizer(href, ",");
      while (st.hasMoreTokens())
      {
        Oop obj = getOopAtAddress(st.nextToken());
        if (Assert.ASSERTS_ENABLED) {
          Assert.that(obj instanceof InstanceKlass, "jcore_multiple= href with improper InstanceKlass!");
        }
        InstanceKlass kls = (InstanceKlass)obj;
        try
        {
          dumpKlass(kls);
          buf.append(".class created for ");
          buf.append(genKlassLink(kls));
        }
        catch (Exception exp)
        {
          buf.bold("can't .class for " + genKlassTitle(kls) + " : " + exp.getMessage());
        }
        buf.br();
      }
      buf.genHTMLEpilogue();
      return buf.toString();
    }
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(false, "unknown href link!");
    }
    return null;
  }
}

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

import java.io.ByteArrayOutputStream;
import javax.swing.JTextArea;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import sun.jvm.hotspot.CommandProcessor;

final class CommandProcessorPanel$1$1
  implements Runnable
{
  private final CommandProcessorPanel.1 this$1;
  
  CommandProcessorPanel$1$1(CommandProcessorPanel.1 param1, String paramString) {}
  
  public void run()
  {
    CommandProcessorPanel.access$100(CommandProcessorPanel.1.access$500(this$1));
    try
    {
      CommandProcessorPanel.access$600(CommandProcessorPanel.1.access$500(this$1)).executeCommand(val$ln);
      CommandProcessorPanel.access$600(CommandProcessorPanel.1.access$500(this$1)).printPrompt();
      Document d = CommandProcessorPanel.access$200(CommandProcessorPanel.1.access$500(this$1)).getDocument();
      try
      {
        d.insertString(d.getLength(), access$500this$1).baos.toString(), null);
      }
      catch (BadLocationException ble)
      {
        ble.printStackTrace();
      }
      access$500this$1).baos.reset();
      CommandProcessorPanel.access$200(CommandProcessorPanel.1.access$500(this$1)).setCaretPosition(CommandProcessorPanel.access$200(CommandProcessorPanel.1.access$500(this$1)).getDocument().getLength());
      CommandProcessorPanel.1.access$500(this$1).setMark();
    }
    finally
    {
      CommandProcessorPanel.access$700(CommandProcessorPanel.1.access$500(this$1));
    }
  }
}

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

import java.io.ByteArrayOutputStream;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import sun.jvm.hotspot.CommandProcessor;

final class CommandProcessorPanel$1
  implements DocumentListener
{
  private final CommandProcessorPanel this$0;
  
  CommandProcessorPanel$1(CommandProcessorPanel paramCommandProcessorPanel) {}
  
  public void changedUpdate(DocumentEvent e) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    if (CommandProcessorPanel.access$000(this$0)) {
      return;
    }
    CommandProcessorPanel.access$100(this$0);
    CommandProcessorPanel.access$200(this$0).setCaretPosition(CommandProcessorPanel.access$200(this$0).getDocument().getLength());
    if (CommandProcessorPanel.access$300(this$0, e, '\n'))
    {
      String cmd = this$0.getMarkedText();
      if ((cmd.length() == 0) || (cmd.charAt(cmd.length() - 1) != '\\'))
      {
        final String ln = CommandProcessorPanel.access$400(this$0, cmd);
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            CommandProcessorPanel.access$100(this$0);
            try
            {
              CommandProcessorPanel.access$600(this$0).executeCommand(ln);
              CommandProcessorPanel.access$600(this$0).printPrompt();
              Document d = CommandProcessorPanel.access$200(this$0).getDocument();
              try
              {
                d.insertString(d.getLength(), this$0.baos.toString(), null);
              }
              catch (BadLocationException ble)
              {
                ble.printStackTrace();
              }
              this$0.baos.reset();
              CommandProcessorPanel.access$200(this$0).setCaretPosition(CommandProcessorPanel.access$200(this$0).getDocument().getLength());
              this$0.setMark();
            }
            finally
            {
              CommandProcessorPanel.access$700(this$0);
            }
          }
        });
      }
    }
    else
    {
      CommandProcessorPanel.access$700(this$0);
    }
  }
  
  public void removeUpdate(DocumentEvent e) {}
}

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

import javax.swing.JTextArea;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.Document;

final class CommandProcessorPanel$2
  implements CaretListener
{
  private final CommandProcessorPanel this$0;
  
  CommandProcessorPanel$2(CommandProcessorPanel paramCommandProcessorPanel) {}
  
  public void caretUpdate(CaretEvent e)
  {
    int len = CommandProcessorPanel.access$200(this$0).getDocument().getLength();
    if (e.getDot() > len) {
      CommandProcessorPanel.access$200(this$0).setCaretPosition(len);
    }
  }
}

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class CommandProcessorPanel$3
  implements ActionListener
{
  private final CommandProcessorPanel this$0;
  
  CommandProcessorPanel$3(CommandProcessorPanel paramCommandProcessorPanel) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.clear();
  }
}

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

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

final class CommandProcessorPanel$4
  extends WindowAdapter
{
  public void windowClosing(WindowEvent e)
  {
    System.exit(0);
  }
}

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

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import javax.swing.SwingUtilities;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import sun.jvm.hotspot.CommandProcessor;

public class CommandProcessorPanel
  extends JPanel
{
  private CommandProcessor commands;
  private JTextArea editor;
  private boolean updating;
  private int mark;
  private String curText;
  private static final boolean DEBUGGING = false;
  ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
  
  public CommandProcessorPanel(CommandProcessor cp)
  {
    commands = cp;
    
    setLayout(new BorderLayout());
    
    editor = new JTextArea();
    editor.setDocument(new EditableAtEndDocument());
    editor.setFont(GraphicsUtilities.lookupFont("Courier"));
    JScrollPane scroller = new JScrollPane();
    scroller.getViewport().add(editor);
    add(scroller, "Center");
    
    PrintStream o = new PrintStream(baos, true);
    cp.setOutput(o);
    cp.setErr(o);
    
    editor.getDocument().addDocumentListener(new DocumentListener()
    {
      public void changedUpdate(DocumentEvent e) {}
      
      public void insertUpdate(DocumentEvent e)
      {
        if (updating) {
          return;
        }
        CommandProcessorPanel.this.beginUpdate();
        editor.setCaretPosition(editor.getDocument().getLength());
        if (CommandProcessorPanel.this.insertContains(e, '\n'))
        {
          String cmd = getMarkedText();
          if ((cmd.length() == 0) || (cmd.charAt(cmd.length() - 1) != '\\'))
          {
            final String ln = CommandProcessorPanel.this.trimContinuations(cmd);
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                CommandProcessorPanel.this.beginUpdate();
                try
                {
                  commands.executeCommand(ln);
                  commands.printPrompt();
                  Document d = editor.getDocument();
                  try
                  {
                    d.insertString(d.getLength(), baos.toString(), null);
                  }
                  catch (BadLocationException ble)
                  {
                    ble.printStackTrace();
                  }
                  baos.reset();
                  editor.setCaretPosition(editor.getDocument().getLength());
                  setMark();
                }
                finally
                {
                  CommandProcessorPanel.this.endUpdate();
                }
              }
            });
          }
        }
        else
        {
          CommandProcessorPanel.this.endUpdate();
        }
      }
      
      public void removeUpdate(DocumentEvent e) {}
    });
    editor.addCaretListener(new CaretListener()
    {
      public void caretUpdate(CaretEvent e)
      {
        int len = editor.getDocument().getLength();
        if (e.getDot() > len) {
          editor.setCaretPosition(len);
        }
      }
    });
    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createGlue());
    JButton button = new JButton("Clear Saved Text");
    button.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        clear();
      }
    });
    hbox.add(button);
    hbox.add(Box.createGlue());
    add(hbox, "South");
    
    clear();
  }
  
  public void requestFocus()
  {
    editor.requestFocus();
  }
  
  public void clear()
  {
    EditableAtEndDocument d = (EditableAtEndDocument)editor.getDocument();
    d.clear();
    commands.executeCommand("");
    setMark();
    editor.requestFocus();
  }
  
  public void setMark()
  {
    ((EditableAtEndDocument)editor.getDocument()).setMark();
  }
  
  public String getMarkedText()
  {
    try
    {
      String s = ((EditableAtEndDocument)editor.getDocument()).getMarkedText();
      int i = s.length();
      while ((i > 0) && (s.charAt(i - 1) == '\n')) {
        i--;
      }
      return s.substring(0, i);
    }
    catch (BadLocationException e)
    {
      e.printStackTrace();
    }
    return null;
  }
  
  private void beginUpdate()
  {
    updating = true;
  }
  
  private void endUpdate()
  {
    updating = false;
  }
  
  private boolean insertContains(DocumentEvent e, char c)
  {
    String s = null;
    try
    {
      s = editor.getText(e.getOffset(), e.getLength());
      for (int i = 0; i < e.getLength(); i++) {
        if (s.charAt(i) == c) {
          return true;
        }
      }
    }
    catch (BadLocationException ex)
    {
      ex.printStackTrace();
    }
    return false;
  }
  
  private String trimContinuations(String text)
  {
    int i;
    while ((i = text.indexOf("\\\n")) >= 0) {
      text = text.substring(0, i) + text.substring(i + 2, text.length());
    }
    return text;
  }
  
  public static void main(String[] args)
  {
    JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout());
    CommandProcessorPanel panel = new CommandProcessorPanel(null);
    frame.getContentPane().add(panel, "Center");
    frame.addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent e)
      {
        System.exit(0);
      }
    });
    frame.setSize(500, 500);
    frame.setVisible(true);
    panel.requestFocus();
  }
}

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

import java.awt.BorderLayout;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import sun.jvm.hotspot.runtime.DeadlockDetector;

public class DeadlockDetectionPanel
  extends JPanel
{
  public DeadlockDetectionPanel()
  {
    setLayout(new BorderLayout());
    
    JScrollPane scroller = new JScrollPane();
    JTextArea textArea = new JTextArea();
    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    scroller.getViewport().add(textArea);
    add(scroller, "Center");
    
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    PrintStream tty = new PrintStream(bos);
    printDeadlocks(tty);
    textArea.setText(bos.toString());
  }
  
  private void printDeadlocks(PrintStream tty)
  {
    DeadlockDetector.print(tty);
  }
}

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

final class DebuggerConsolePanel$1$1
  implements Runnable
{
  private final DebuggerConsolePanel.1 this$1;
  
  DebuggerConsolePanel$1$1(DebuggerConsolePanel.1 param1, String paramString) {}
  
  public void run()
  {
    DebuggerConsolePanel.access$700(DebuggerConsolePanel.1.access$600(this$1), val$result);
    DebuggerConsolePanel.access$800(DebuggerConsolePanel.1.access$600(this$1));
    DebuggerConsolePanel.1.access$600(this$1).setMark();
    DebuggerConsolePanel.access$900(DebuggerConsolePanel.1.access$600(this$1));
  }
}

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

import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import sun.jvm.hotspot.debugger.Debugger;

final class DebuggerConsolePanel$1
  implements DocumentListener
{
  private final DebuggerConsolePanel this$0;
  
  DebuggerConsolePanel$1(DebuggerConsolePanel paramDebuggerConsolePanel) {}
  
  public void changedUpdate(DocumentEvent e) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    if (DebuggerConsolePanel.access$000(this$0)) {
      return;
    }
    DebuggerConsolePanel.access$100(this$0);
    DebuggerConsolePanel.access$200(this$0).setCaretPosition(DebuggerConsolePanel.access$200(this$0).getDocument().getLength());
    if (DebuggerConsolePanel.access$300(this$0, e, '\n'))
    {
      String cmd = this$0.getMarkedText();
      if ((cmd.length() == 0) || (cmd.charAt(cmd.length() - 1) != '\\'))
      {
        cmd = DebuggerConsolePanel.access$400(this$0, cmd);
        
        final String result = DebuggerConsolePanel.access$500(this$0).consoleExecuteCommand(cmd);
        
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            DebuggerConsolePanel.access$700(this$0, result);
            DebuggerConsolePanel.access$800(this$0);
            this$0.setMark();
            DebuggerConsolePanel.access$900(this$0);
          }
        });
      }
    }
    else
    {
      DebuggerConsolePanel.access$900(this$0);
    }
  }
  
  public void removeUpdate(DocumentEvent e) {}
}

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

import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;

final class DebuggerConsolePanel$2
  implements CaretListener
{
  private final DebuggerConsolePanel this$0;
  
  DebuggerConsolePanel$2(DebuggerConsolePanel paramDebuggerConsolePanel) {}
  
  public void caretUpdate(CaretEvent e)
  {
    int len = DebuggerConsolePanel.access$200(this$0).getDocument().getLength();
    if (e.getDot() > len) {
      DebuggerConsolePanel.access$200(this$0).setCaretPosition(len);
    }
  }
}

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class DebuggerConsolePanel$3
  implements ActionListener
{
  private final DebuggerConsolePanel this$0;
  
  DebuggerConsolePanel$3(DebuggerConsolePanel paramDebuggerConsolePanel) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.clear();
  }
}

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

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

final class DebuggerConsolePanel$4
  extends WindowAdapter
{
  public void windowClosing(WindowEvent e)
  {
    System.exit(0);
  }
}

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

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import javax.swing.SwingUtilities;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import sun.jvm.hotspot.debugger.Debugger;
import sun.jvm.hotspot.utilities.Assert;

public class DebuggerConsolePanel
  extends JPanel
{
  private Debugger debugger;
  private JTextComponent editor;
  private boolean updating;
  private int mark;
  private String curText;
  private static final boolean DEBUGGING = false;
  
  public DebuggerConsolePanel(Debugger debugger)
  {
    this.debugger = debugger;
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(debugger.hasConsole(), "should not create a DebuggerConsolePanel for non-console debuggers");
    }
    setLayout(new BorderLayout());
    
    editor = new JTextArea();
    editor.setDocument(new EditableAtEndDocument());
    editor.setFont(GraphicsUtilities.lookupFont("Courier"));
    JScrollPane scroller = new JScrollPa
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