boot

16:33:16.431 INFO  jd.cli.Main - Decompiling boot.jar
package org.netbeans;

import java.nio.ByteBuffer;

class Archive$Entry
{
  private final int offset;
  private final ByteBuffer master;
  
  Archive$Entry(ByteBuffer paramByteBuffer)
  {
    master = paramByteBuffer;
    offset = master.position();
    int i = master.getInt(offset + 2);
    int j = master.getChar(offset + 6);
    if (i < 0) {
      i = 0;
    }
    master.position(offset + 8 + j + i);
  }
  
  String getName()
  {
    ByteBuffer localByteBuffer = master.duplicate();
    localByteBuffer.position(offset + 6);
    return Archive.access$000(localByteBuffer);
  }
  
  int getSource()
  {
    return master.getChar(offset);
  }
  
  byte[] getContent()
  {
    int i = master.getInt(offset + 2);
    int j = master.getChar(offset + 6);
    if (i < 0) {
      return null;
    }
    ByteBuffer localByteBuffer = master.duplicate();
    localByteBuffer.position(offset + 8 + j);
    byte[] arrayOfByte = new byte[i];
    localByteBuffer.get(arrayOfByte);
    return arrayOfByte;
  }
  
  public int hashCode()
  {
    ByteBuffer localByteBuffer = master.duplicate();
    localByteBuffer.position(offset + 8);
    localByteBuffer.limit(offset + 8 + master.getChar(offset + 6));
    
    int i = '5' * master.getChar(offset);
    while (localByteBuffer.hasRemaining()) {
      i = i * 53 + localByteBuffer.get();
    }
    return i;
  }
  
  public boolean equals(Object paramObject)
  {
    if ((paramObject instanceof Archive.Template)) {
      return paramObject.equals(this);
    }
    return paramObject == this;
  }
  
  public String toString()
  {
    return "#" + getSource() + ":" + getName() + "=[" + offset + "]";
  }
}

/* Location:
 * Qualified Name:     org.netbeans.Archive.Entry
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;

class Archive$Template
{
  private int source;
  private byte[] utf;
  
  Archive$Template(int paramInt, String paramString)
  {
    try
    {
      source = paramInt;
      utf = paramString.getBytes("UTF8");
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new InternalError();
    }
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof Archive.Entry)) {
      return false;
    }
    Archive.Entry localEntry = (Archive.Entry)paramObject;
    if (source != Archive.Entry.access$200(localEntry).getChar(Archive.Entry.access$100(localEntry))) {
      return false;
    }
    if (utf.length != Archive.Entry.access$200(localEntry).getChar(Archive.Entry.access$100(localEntry) + 6)) {
      return false;
    }
    ByteBuffer localByteBuffer = Archive.Entry.access$200(localEntry).duplicate();
    localByteBuffer.position(Archive.Entry.access$100((Archive.Entry)paramObject) + 8);
    for (int k : utf) {
      if (k != localByteBuffer.get()) {
        return false;
      }
    }
    return true;
  }
  
  public int hashCode()
  {
    int i = 53 * source;
    for (int m : utf) {
      i = i * 53 + m;
    }
    return i;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.Archive.Template
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

class Archive
  implements Stamps.Updater
{
  private static final long magic = 6836742066851800321L;
  private static final Logger LOG = Logger.getLogger(Archive.class.getName());
  private volatile boolean saved;
  private final boolean prepopulated;
  private volatile boolean gathering;
  private final Object gatheringLock = new Object();
  private Map<String, Boolean> requests = new LinkedHashMap();
  private Map<String, ArchiveResources> knownSources = new HashMap();
  private volatile boolean active;
  private Map<String, Integer> sources = new HashMap();
  private Map<Entry, Entry> entries = new HashMap();
  
  public Archive()
  {
    gathering = false;
    active = false;
    prepopulated = false;
  }
  
  Archive(Stamps paramStamps)
  {
    ByteBuffer localByteBuffer = paramStamps.asByteBuffer("all-resources.dat");
    try
    {
      parse(localByteBuffer, paramStamps.lastModified());
    }
    catch (Exception localException)
    {
      sources.clear();
      entries.clear();
    }
    prepopulated = (entries.size() > 0);
    
    active = true;
    gathering = true;
  }
  
  final boolean isActive()
  {
    return active;
  }
  
  private void parse(ByteBuffer paramByteBuffer, long paramLong)
    throws Exception
  {
    if (paramByteBuffer.remaining() < 16) {
      throw new IllegalStateException("Cache invalid");
    }
    if (paramByteBuffer.getLong() != 6836742066851800321L) {
      throw new IllegalStateException("Wrong format");
    }
    if (paramByteBuffer.getLong() < paramLong) {
      throw new IllegalStateException("Cache outdated");
    }
    int i = 0;
    while (paramByteBuffer.remaining() > 0)
    {
      int j = paramByteBuffer.get();
      switch (j)
      {
      case 1: 
        String str = parseString(paramByteBuffer);
        sources.put(str, Integer.valueOf(i++));
        break;
      case 2: 
        Entry localEntry = new Entry(paramByteBuffer);
        entries.put(localEntry, localEntry);
        break;
      default: 
        throw new IllegalStateException("Cache invalid");
      }
    }
    paramByteBuffer.rewind();
  }
  
  private static String parseString(ByteBuffer paramByteBuffer)
  {
    int i = paramByteBuffer.getChar();
    byte[] arrayOfByte = new byte[i];
    paramByteBuffer.get(arrayOfByte);
    try
    {
      return new String(arrayOfByte, "UTF8");
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new InternalError();
    }
  }
  
  private static void writeString(DataOutputStream paramDataOutputStream, String paramString)
    throws UnsupportedEncodingException, IOException
  {
    byte[] arrayOfByte = paramString.getBytes("UTF8");
    paramDataOutputStream.writeChar(arrayOfByte.length);
    paramDataOutputStream.write(arrayOfByte);
  }
  
  public byte[] getData(ArchiveResources paramArchiveResources, String paramString)
    throws IOException
  {
    Entry localEntry = null;
    String str1 = paramArchiveResources.getIdentifier();
    Map localMap = entries;
    Object localObject1;
    if (active)
    {
      localObject1 = (Integer)sources.get(str1);
      if (localObject1 == null) {
        localEntry = null;
      } else {
        localEntry = (Entry)localMap.get(new Template(((Integer)localObject1).intValue(), paramString));
      }
      if ((localEntry == null) && (gathering))
      {
        StringBuilder localStringBuilder = new StringBuilder(str1.length() + paramString.length());
        String str2 = str1 + paramString;
        synchronized (gatheringLock)
        {
          if (!knownSources.containsKey(str1)) {
            knownSources.put(str1, paramArchiveResources);
          }
          if (!requests.containsKey(str2)) {
            requests.put(str2, Boolean.TRUE);
          }
        }
      }
    }
    if (localEntry == null)
    {
      localObject1 = paramArchiveResources.resource(paramString);
      
      return (byte[])localObject1;
    }
    return localEntry.getContent();
  }
  
  public void stopGathering()
  {
    gathering = false;
  }
  
  public void stopServing()
  {
    active = false;
    
    entries = null;
  }
  
  public void save(Stamps paramStamps)
    throws IOException
  {
    if (saved) {
      return;
    }
    saved = true;
    paramStamps.scheduleSave(this, "all-resources.dat", prepopulated);
  }
  
  public void flushCaches(DataOutputStream paramDataOutputStream)
    throws IOException
  {
    stopGathering();
    stopServing();
    
    assert (!gathering);
    assert (!active);
    if (!prepopulated)
    {
      paramDataOutputStream.writeLong(6836742066851800321L);
      paramDataOutputStream.writeLong(System.currentTimeMillis());
    }
    for (Iterator localIterator = requests.keySet().iterator(); localIterator.hasNext();)
    {
      str = (String)localIterator.next();
      String[] arrayOfString = str.split("(?<=!/)");
      ArchiveResources localArchiveResources = (ArchiveResources)knownSources.get(arrayOfString[0]);
      assert (localArchiveResources != null) : ("Could not find " + str + " in " + knownSources);
      byte[] arrayOfByte = localArchiveResources.resource(arrayOfString[1]);
      Integer localInteger = (Integer)sources.get(arrayOfString[0]);
      if (localInteger == null)
      {
        localInteger = Integer.valueOf(sources.size());
        sources.put(arrayOfString[0], localInteger);
        paramDataOutputStream.write(1);
        writeString(paramDataOutputStream, arrayOfString[0]);
      }
      paramDataOutputStream.write(2);
      paramDataOutputStream.writeChar(localInteger.intValue());
      paramDataOutputStream.writeInt(arrayOfByte == null ? -1 : arrayOfByte.length);
      writeString(paramDataOutputStream, arrayOfString[1]);
      if (arrayOfByte != null) {
        paramDataOutputStream.write(arrayOfByte);
      }
    }
    String str;
    paramDataOutputStream.close();
    if (LOG.isLoggable(Level.FINER)) {
      for (localIterator = requests.keySet().iterator(); localIterator.hasNext();)
      {
        str = (String)localIterator.next();
        LOG.log(Level.FINER, "archiving: {0}", str);
      }
    }
    requests = null;
    knownSources = null;
    sources = null;
  }
  
  public void cacheReady() {}
  
  private static class Entry
  {
    private final int offset;
    private final ByteBuffer master;
    
    Entry(ByteBuffer paramByteBuffer)
    {
      master = paramByteBuffer;
      offset = master.position();
      int i = master.getInt(offset + 2);
      int j = master.getChar(offset + 6);
      if (i < 0) {
        i = 0;
      }
      master.position(offset + 8 + j + i);
    }
    
    String getName()
    {
      ByteBuffer localByteBuffer = master.duplicate();
      localByteBuffer.position(offset + 6);
      return Archive.parseString(localByteBuffer);
    }
    
    int getSource()
    {
      return master.getChar(offset);
    }
    
    byte[] getContent()
    {
      int i = master.getInt(offset + 2);
      int j = master.getChar(offset + 6);
      if (i < 0) {
        return null;
      }
      ByteBuffer localByteBuffer = master.duplicate();
      localByteBuffer.position(offset + 8 + j);
      byte[] arrayOfByte = new byte[i];
      localByteBuffer.get(arrayOfByte);
      return arrayOfByte;
    }
    
    public int hashCode()
    {
      ByteBuffer localByteBuffer = master.duplicate();
      localByteBuffer.position(offset + 8);
      localByteBuffer.limit(offset + 8 + master.getChar(offset + 6));
      
      int i = '5' * master.getChar(offset);
      while (localByteBuffer.hasRemaining()) {
        i = i * 53 + localByteBuffer.get();
      }
      return i;
    }
    
    public boolean equals(Object paramObject)
    {
      if ((paramObject instanceof Archive.Template)) {
        return paramObject.equals(this);
      }
      return paramObject == this;
    }
    
    public String toString()
    {
      return "#" + getSource() + ":" + getName() + "=[" + offset + "]";
    }
  }
  
  private static class Template
  {
    private int source;
    private byte[] utf;
    
    Template(int paramInt, String paramString)
    {
      try
      {
        source = paramInt;
        utf = paramString.getBytes("UTF8");
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        throw new InternalError();
      }
    }
    
    public boolean equals(Object paramObject)
    {
      if (!(paramObject instanceof Archive.Entry)) {
        return false;
      }
      Archive.Entry localEntry = (Archive.Entry)paramObject;
      if (source != Archive.Entry.access$200(localEntry).getChar(Archive.Entry.access$100(localEntry))) {
        return false;
      }
      if (utf.length != Archive.Entry.access$200(localEntry).getChar(Archive.Entry.access$100(localEntry) + 6)) {
        return false;
      }
      ByteBuffer localByteBuffer = Archive.Entry.access$200(localEntry).duplicate();
      localByteBuffer.position(Archive.Entry.access$100((Archive.Entry)paramObject) + 8);
      for (int k : utf) {
        if (k != localByteBuffer.get()) {
          return false;
        }
      }
      return true;
    }
    
    public int hashCode()
    {
      int i = 53 * source;
      for (int m : utf) {
        i = i * 53 + m;
      }
      return i;
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.Archive
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.IOException;

public abstract interface ArchiveResources
{
  public abstract String getIdentifier();
  
  public abstract byte[] resource(String paramString)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.netbeans.ArchiveResources
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

final class CLIHandler$1
  implements Runnable
{
  CLIHandler$1(Integer paramInteger, byte[] paramArrayOfByte, DataOutputStream paramDataOutputStream) {}
  
  public void run()
  {
    SecureRandom localSecureRandom = null;
    CLIHandler.access$000(95, val$block);
    try
    {
      localSecureRandom = SecureRandom.getInstance("SHA1PRNG");
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException1)
    {
      try
      {
        localSecureRandom = SecureRandom.getInstance("IBMSecureRandom");
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException2)
      {
        CLIHandler.access$100().stopServer();
      }
    }
    CLIHandler.access$000(96, val$block);
    if (localSecureRandom != null) {
      localSecureRandom.nextBytes(val$arr);
    }
    CLIHandler.access$000(97, val$block);
    try
    {
      val$os.write(val$arr);
      val$os.flush();
      
      CLIHandler.access$000(27, val$block);
      
      byte[] arrayOfByte = InetAddress.getLocalHost().getAddress();
      if ((val$block != null) && (val$block.intValue() == 667)) {
        throw new UnknownHostException("dhcppc0");
      }
      for (int i = 0; i < arrayOfByte.length; i++) {
        val$os.write(arrayOfByte[i]);
      }
    }
    catch (UnknownHostException localUnknownHostException)
    {
      if (!"dhcppc0".equals(localUnknownHostException.getMessage())) {
        localUnknownHostException.printStackTrace();
      }
    }
    catch (IOException localIOException1)
    {
      localIOException1.printStackTrace();
    }
    try
    {
      val$os.close();
    }
    catch (IOException localIOException2) {}
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.util.Collection;

final class CLIHandler$2
  implements CLIHandler.Execute
{
  CLIHandler$2(CLIHandler.Args paramArgs, Collection paramCollection, boolean paramBoolean) {}
  
  public int exec()
  {
    return CLIHandler.notifyHandlers(val$args, val$handlers, 2, val$failOnUnknownOptions, val$failOnUnknownOptions);
  }
  
  public String toString()
  {
    return val$handlers.toString();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public final class CLIHandler$Args
{
  private String[] args;
  private final String[] argsBackup;
  private InputStream is;
  private OutputStream os;
  private OutputStream err;
  private File currentDir;
  private boolean closed;
  
  CLIHandler$Args(String[] paramArrayOfString, InputStream paramInputStream, OutputStream paramOutputStream1, OutputStream paramOutputStream2, String paramString)
  {
    argsBackup = paramArrayOfString;
    reset(false);
    is = paramInputStream;
    os = paramOutputStream1;
    err = paramOutputStream2;
    currentDir = new File(paramString);
  }
  
  void reset(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      String[] arrayOfString = args;
      if (arrayOfString == null) {
        arrayOfString = argsBackup;
      }
      ArrayList localArrayList = new ArrayList(Arrays.asList(arrayOfString));
      localArrayList.removeAll(Collections.singleton(null));
      args = ((String[])localArrayList.toArray(new String[localArrayList.size()]));
    }
    else
    {
      args = ((String[])argsBackup.clone());
    }
  }
  
  final void close()
  {
    closed = true;
  }
  
  public String[] getArguments()
  {
    return args;
  }
  
  public OutputStream getOutputStream()
  {
    return os;
  }
  
  public OutputStream getErrorStream()
  {
    return err;
  }
  
  public File getCurrentDirectory()
  {
    return currentDir;
  }
  
  public InputStream getInputStream()
  {
    return is;
  }
  
  public boolean isOpen()
  {
    return !closed;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Args
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

abstract interface CLIHandler$Execute
{
  public abstract int exec();
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Execute
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.SocketException;

class CLIHandler$Server$1ComputingAndNotifying
  extends Thread
{
  public int res;
  public boolean finished;
  
  public CLIHandler$Server$1ComputingAndNotifying()
  {
    super("Computes values in handlers");
  }
  
  public void run()
  {
    try
    {
      if (CLIHandler.access$700(val$arguments, CLIHandler.Server.access$600(this$0))) {
        res = 2;
      } else {
        res = CLIHandler.notifyHandlers(val$arguments, CLIHandler.Server.access$600(this$0), 2, CLIHandler.Server.access$800(this$0), false);
      }
      if (res == 0) {
        CLIHandler.access$000(98, CLIHandler.Server.access$900(this$0));
      } else {
        CLIHandler.access$000(99, CLIHandler.Server.access$900(this$0));
      }
    }
    finally
    {
      synchronized (this)
      {
        finished = true;
        notifyAll();
      }
    }
  }
  
  public synchronized void waitForResultAndNotifyOthers()
  {
    start();
    while (!finished) {
      try
      {
        wait(1000L);
        val$os.write(3);
        val$os.flush();
      }
      catch (SocketException localSocketException)
      {
        if (CLIHandler.Server.isClosedSocket(localSocketException))
        {
          val$arguments.close();
          
          interrupt();
        }
        else
        {
          localSocketException.printStackTrace();
        }
      }
      catch (InterruptedException localInterruptedException)
      {
        localInterruptedException.printStackTrace();
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Server.1ComputingAndNotifying
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;

final class CLIHandler$Server$IS
  extends InputStream
{
  private final DataInputStream is;
  private final DataOutputStream os;
  private final int requestedVersion;
  
  public CLIHandler$Server$IS(DataInputStream paramDataInputStream, DataOutputStream paramDataOutputStream, int paramInt)
  {
    is = paramDataInputStream;
    os = paramDataOutputStream;
    requestedVersion = paramInt;
  }
  
  public int read()
    throws IOException
  {
    byte[] arrayOfByte = new byte[1];
    if (read(arrayOfByte) == 1) {
      return arrayOfByte[0];
    }
    return -1;
  }
  
  public void close()
    throws IOException
  {
    super.close();
  }
  
  public int available()
    throws IOException
  {
    os.write(12);
    os.flush();
    
    return is.readInt();
  }
  
  public int read(byte[] paramArrayOfByte)
    throws IOException
  {
    return read(paramArrayOfByte, 0, paramArrayOfByte.length);
  }
  
  public int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    os.write(10);
    os.writeInt(paramInt2);
    os.flush();
    
    int i = requestedVersion >= 1 ? is.readInt() : is.read();
    if (i > 0) {
      return is.read(paramArrayOfByte, paramInt1, i);
    }
    return i;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Server.IS
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

final class CLIHandler$Server$OS
  extends OutputStream
{
  private DataOutputStream os;
  private int type;
  
  public CLIHandler$Server$OS(DataOutputStream paramDataOutputStream, int paramInt)
  {
    os = paramDataOutputStream;
    type = paramInt;
  }
  
  public void write(int paramInt)
    throws IOException
  {
    byte[] arrayOfByte = { (byte)paramInt };
    write(arrayOfByte);
  }
  
  public void write(byte[] paramArrayOfByte)
    throws IOException
  {
    write(paramArrayOfByte, 0, paramArrayOfByte.length);
  }
  
  public void close()
    throws IOException
  {
    super.close();
  }
  
  public void flush()
    throws IOException
  {
    os.flush();
  }
  
  public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    os.write(type);
    os.writeInt(paramInt2);
    os.write(paramArrayOfByte, paramInt1, paramInt2);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Server.OS
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;

final class CLIHandler$Server
  extends Thread
{
  private byte[] key;
  private ServerSocket socket;
  private Integer block;
  private Collection<? extends CLIHandler> handlers;
  private Socket work;
  private static volatile int counter;
  private final boolean failOnUnknownOptions;
  private static long lastReply;
  private static long failDelay = 100L;
  
  public CLIHandler$Server(byte[] paramArrayOfByte, Integer paramInteger, Collection<? extends CLIHandler> paramCollection, boolean paramBoolean)
    throws IOException
  {
    super("CLI Requests Server");
    key = paramArrayOfByte;
    setDaemon(true);
    block = paramInteger;
    handlers = paramCollection;
    failOnUnknownOptions = paramBoolean;
    
    socket = new ServerSocket(0, 50, CLIHandler.access$200());
    start();
  }
  
  public CLIHandler$Server(Socket paramSocket, byte[] paramArrayOfByte, Integer paramInteger, Collection<? extends CLIHandler> paramCollection, boolean paramBoolean)
    throws IOException
  {
    super("CLI Handler Thread Handler: " + ++counter);
    key = paramArrayOfByte;
    setDaemon(true);
    block = paramInteger;
    handlers = paramCollection;
    work = paramSocket;
    failOnUnknownOptions = paramBoolean;
    
    start();
  }
  
  public int getLocalPort()
  {
    return socket.getLocalPort();
  }
  
  public void run()
  {
    if (work != null)
    {
      try
      {
        handleConnect(work);
      }
      catch (IOException localIOException1)
      {
        CLIHandler.access$300().log(Level.INFO, null, localIOException1);
      }
      return;
    }
    ServerSocket localServerSocket = socket;
    if (localServerSocket == null) {
      return;
    }
    while (socket != null) {
      try
      {
        CLIHandler.access$000(65, block);
        Socket localSocket = socket.accept();
        if (socket == null)
        {
          CLIHandler.access$000(66, block);
          localSocket.getOutputStream().write(0);
          CLIHandler.access$000(67, block);
          localSocket.close();
        }
        else
        {
          new Server(localSocket, key, block, handlers, failOnUnknownOptions);
        }
      }
      catch (InterruptedIOException localInterruptedIOException)
      {
        if (socket != null) {
          localInterruptedIOException.printStackTrace();
        }
      }
      catch (SocketException localSocketException)
      {
        if (socket != null) {
          localSocketException.printStackTrace();
        }
      }
      catch (IOException localIOException2)
      {
        localIOException2.printStackTrace();
      }
    }
    try
    {
      localServerSocket.close();
    }
    catch (IOException localIOException3)
    {
      localIOException3.printStackTrace();
    }
  }
  
  final void stopServer()
  {
    socket = null;
    
    interrupt();
  }
  
  private void handleConnect(Socket paramSocket)
    throws IOException
  {
    byte[] arrayOfByte = new byte[key.length];
    DataInputStream localDataInputStream = new DataInputStream(paramSocket.getInputStream());
    
    CLIHandler.access$000(70, block);
    
    localDataInputStream.readFully(arrayOfByte);
    
    final DataOutputStream localDataOutputStream = new DataOutputStream(paramSocket.getOutputStream());
    
    int j = 1;
    for (int k = 0; k < CLIHandler.access$400().length - 1; k++) {
      if (CLIHandler.access$400()[k] != arrayOfByte[k]) {
        j = 0;
      }
    }
    int i;
    if (j != 0)
    {
      i = arrayOfByte[(CLIHandler.access$400().length - 1)];
      localDataOutputStream.write(14);
      localDataOutputStream.writeInt(CLIHandler.access$400()[(CLIHandler.access$400().length - 1)]);
      localDataOutputStream.flush();
      localDataInputStream.readFully(arrayOfByte);
    }
    else
    {
      i = 0;
    }
    CLIHandler.access$000(90, block);
    if (Arrays.equals(arrayOfByte, key))
    {
      while (!CLIHandler.access$500(2000))
      {
        localDataOutputStream.write(3);
        localDataOutputStream.flush();
      }
      CLIHandler.access$000(93, block);
      localDataOutputStream.write(1);
      localDataOutputStream.flush();
      
      k = localDataInputStream.readInt();
      String[] arrayOfString = new String[k];
      for (int m = 0; m < arrayOfString.length; m++) {
        arrayOfString[m] = localDataInputStream.readUTF();
      }
      String str = localDataInputStream.readUTF();
      
      final CLIHandler.Args localArgs = new CLIHandler.Args(arrayOfString, new IS(localDataInputStream, localDataOutputStream, i), new OS(localDataOutputStream, 11), new OS(localDataOutputStream, 13), str);
      
      Thread local1ComputingAndNotifying = new Thread(localArgs)
      {
        public int res;
        public boolean finished;
        
        public void run()
        {
          try
          {
            if (CLIHandler.access$700(localArgs, this$0.handlers)) {
              res = 2;
            } else {
              res = CLIHandler.notifyHandlers(localArgs, this$0.handlers, 2, this$0.failOnUnknownOptions, false);
            }
            if (res == 0) {
              CLIHandler.access$000(98, this$0.block);
            } else {
              CLIHandler.access$000(99, this$0.block);
            }
          }
          finally
          {
            synchronized (this)
            {
              finished = true;
              notifyAll();
            }
          }
        }
        
        public synchronized void waitForResultAndNotifyOthers()
        {
          start();
          while (!finished) {
            try
            {
              wait(1000L);
              localDataOutputStream.write(3);
              localDataOutputStream.flush();
            }
            catch (SocketException localSocketException)
            {
              if (CLIHandler.Server.isClosedSocket(localSocketException))
              {
                localArgs.close();
                
                interrupt();
              }
              else
              {
                localSocketException.printStackTrace();
              }
            }
            catch (InterruptedException localInterruptedException)
            {
              localInterruptedException.printStackTrace();
            }
            catch (IOException localIOException)
            {
              localIOException.printStackTrace();
            }
          }
        }
      };
      local1ComputingAndNotifying.waitForResultAndNotifyOthers();
      try
      {
        localDataOutputStream.write(2);
        localDataOutputStream.writeInt(res);
      }
      catch (SocketException localSocketException)
      {
        if (isClosedSocket(localSocketException))
        {
          localArgs.close();
          
          local1ComputingAndNotifying.interrupt();
        }
        else
        {
          throw localSocketException;
        }
      }
    }
    else
    {
      CLIHandler.access$000(103, block);
      long l = lastReply + failDelay - System.currentTimeMillis();
      if (l > 0L)
      {
        try
        {
          Thread.sleep(l);
        }
        catch (InterruptedException localInterruptedException)
        {
          localInterruptedException.printStackTrace();
        }
        failDelay *= 2L;
      }
      else
      {
        failDelay = 100L;
      }
      lastReply = System.currentTimeMillis();
      localDataOutputStream.write(0);
    }
    CLIHandler.access$000(120, block);
    
    localDataOutputStream.close();
    localDataInputStream.close();
  }
  
  static final boolean isClosedSocket(SocketException paramSocketException)
  {
    if (paramSocketException.getMessage().equals("Broken pipe")) {
      return true;
    }
    if (paramSocketException.getMessage().startsWith("Connection reset by peer")) {
      return true;
    }
    return false;
  }
  
  private static final class IS
    extends InputStream
  {
    private final DataInputStream is;
    private final DataOutputStream os;
    private final int requestedVersion;
    
    public IS(DataInputStream paramDataInputStream, DataOutputStream paramDataOutputStream, int paramInt)
    {
      is = paramDataInputStream;
      os = paramDataOutputStream;
      requestedVersion = paramInt;
    }
    
    public int read()
      throws IOException
    {
      byte[] arrayOfByte = new byte[1];
      if (read(arrayOfByte) == 1) {
        return arrayOfByte[0];
      }
      return -1;
    }
    
    public void close()
      throws IOException
    {
      super.close();
    }
    
    public int available()
      throws IOException
    {
      os.write(12);
      os.flush();
      
      return is.readInt();
    }
    
    public int read(byte[] paramArrayOfByte)
      throws IOException
    {
      return read(paramArrayOfByte, 0, paramArrayOfByte.length);
    }
    
    public int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
      throws IOException
    {
      os.write(10);
      os.writeInt(paramInt2);
      os.flush();
      
      int i = requestedVersion >= 1 ? is.readInt() : is.read();
      if (i > 0) {
        return is.read(paramArrayOfByte, paramInt1, i);
      }
      return i;
    }
  }
  
  private static final class OS
    extends OutputStream
  {
    private DataOutputStream os;
    private int type;
    
    public OS(DataOutputStream paramDataOutputStream, int paramInt)
    {
      os = paramDataOutputStream;
      type = paramInt;
    }
    
    public void write(int paramInt)
      throws IOException
    {
      byte[] arrayOfByte = { (byte)paramInt };
      write(arrayOfByte);
    }
    
    public void write(byte[] paramArrayOfByte)
      throws IOException
    {
      write(paramArrayOfByte, 0, paramArrayOfByte.length);
    }
    
    public void close()
      throws IOException
    {
      super.close();
    }
    
    public void flush()
      throws IOException
    {
      os.flush();
    }
    
    public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
      throws IOException
    {
      os.write(type);
      os.writeInt(paramInt2);
      os.write(paramArrayOfByte, paramInt1, paramInt2);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Server
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.File;
import org.openide.util.Task;

final class CLIHandler$Status
{
  public static final int CANNOT_CONNECT = -255;
  private final File lockFile;
  private final int port;
  private int exitCode;
  private Task parael;
  
  CLIHandler$Status()
  {
    this(0);
  }
  
  CLIHandler$Status(int paramInt)
  {
    this(null, 0, paramInt, null);
  }
  
  CLIHandler$Status(File paramFile, int paramInt1, int paramInt2, Task paramTask)
  {
    lockFile = paramFile;
    port = paramInt1;
    exitCode = paramInt2;
    parael = paramTask;
  }
  
  private void waitFinished()
  {
    if (parael != null) {
      parael.waitFinished();
    }
  }
  
  public File getLockFile()
  {
    waitFinished();
    return lockFile;
  }
  
  public int getServerPort()
  {
    return port;
  }
  
  public int getExitCode()
  {
    return exitCode;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.CLIHandler.Status
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.Task;

public abstract class CLIHandler
{
  private static final int KEY_LENGTH = 10;
  private static final byte[] VERSION = { 78, 66, 67, 76, 73, 0, 0, 0, 0, 1 };
  private static final int REPLY_OK = 1;
  private static final int REPLY_EXIT = 2;
  private static final int REPLY_FAIL = 0;
  private static final int REPLY_DELAY = 3;
  private static final int REPLY_READ = 10;
  private static final int REPLY_WRITE = 11;
  private static final int REPLY_AVAILABLE = 12;
  private static final int REPLY_ERROR = 13;
  private static final int REPLY_VERSION = 14;
  public static final int WHEN_BOOT = 1;
  public static final int WHEN_INIT = 2;
  public static final int WHEN_EXTRA = 3;
  private static Server server;
  private static final Logger OUTPUT = Logger.getLogger(CLIHandler.class.getName());
  private int when;
  
  protected CLIHandler(int paramInt)
  {
    when = paramInt;
  }
  
  protected abstract int cli(Args paramArgs);
  
  protected static void showHelp(PrintWriter paramPrintWriter, Collection<? extends CLIHandler> paramCollection, int paramInt)
  {
    for (CLIHandler localCLIHandler : paramCollection) {
      if ((paramInt == -1) || (paramInt == when)) {
        localCLIHandler.usage(paramPrintWriter);
      }
    }
  }
  
  protected abstract void usage(PrintWriter paramPrintWriter);
  
  private static void enterState(int paramInt, Integer paramInteger)
  {
    if (OUTPUT.isLoggable(Level.FINEST)) {
      synchronized (OUTPUT)
      {
        OUTPUT.finest("state: " + paramInt + " thread: " + Thread.currentThread());
      }
    }
    if (paramInteger == null) {
      return;
    }
    synchronized (paramInteger)
    {
      if (paramInt == paramInteger.intValue())
      {
        if (OUTPUT.isLoggable(Level.FINEST)) {
          OUTPUT.finest(paramInt + " blocked");
        }
        paramInteger.notifyAll();
        try
        {
          paramInteger.wait();
        }
        catch (InterruptedException localInterruptedException)
        {
          throw new IllegalStateException();
        }
      }
      else if (OUTPUT.isLoggable(Level.FINEST))
      {
        OUTPUT.finest(paramInt + " not blocked");
      }
    }
  }
  
  private static boolean checkHelp(Args paramArgs, Collection<? extends CLIHandler> paramCollection)
  {
    String[] arrayOfString = paramArgs.getArguments();
    for (int i = 0; i < arrayOfString.length; i++) {
      if (arrayOfString[i] != null) {
        if ((arrayOfString[i].equals("-?")) || (arrayOfString[i].equals("--help")) || (arrayOfString[i].equals("-help")))
        {
          Logger.getLogger("").setLevel(Level.OFF);
          PrintWriter localPrintWriter = new PrintWriter(paramArgs.getOutputStream());
          showHelp(localPrintWriter, paramCollection, -1);
          localPrintWriter.flush();
          return true;
        }
      }
    }
    return false;
  }
  
  protected static int notifyHandlers(Args paramArgs, Collection<? extends CLIHandler> paramCollection, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
  {
    try
    {
      int i = 0;
      for (Object localObject1 = paramCollection.iterator(); ((Iterator)localObject1).hasNext();)
      {
        CLIHandler localCLIHandler = (CLIHandler)((Iterator)localObject1).next();
        if (when == paramInt)
        {
          i = localCLIHandler.cli(paramArgs);
          if (i != 0) {
            return i;
          }
        }
      }
      localObject1 = paramArgs.getArguments();
      int j;
      if (paramBoolean1)
      {
        localObject1 = paramArgs.getArguments();
        for (j = 0; j < localObject1.length; j++) {
          if (localObject1[j] != null)
          {
            PrintWriter localPrintWriter = new PrintWriter(paramArgs.getOutputStream());
            localPrintWriter.println("Ignored unknown option: " + localObject1[j]);
            
            localPrintWriter.flush();
            return 2;
          }
        }
      }
      return 0;
    }
    finally
    {
      paramArgs.reset(paramBoolean2);
    }
  }
  
  static final class Status
  {
    public static final int CANNOT_CONNECT = -255;
    private final File lockFile;
    private final int port;
    private int exitCode;
    private Task parael;
    
    Status()
    {
      this(0);
    }
    
    Status(int paramInt)
    {
      this(null, 0, paramInt, null);
    }
    
    Status(File paramFile, int paramInt1, int paramInt2, Task paramTask)
    {
      lockFile = paramFile;
      port = paramInt1;
      exitCode = paramInt2;
      parael = paramTask;
    }
    
    private void waitFinished()
    {
      if (parael != null) {
        parael.waitFinished();
1 2 3 4 5 6 7 8 9 10

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