org.eclipse.equinox.common_3.6.0.v20110523

16:43:47.534 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.common_3.6.0.v20110523.jar
package org.eclipse.core.internal.boot;

import java.io.IOException;
import java.net.URL;
import org.eclipse.core.internal.runtime.CommonMessages;
import org.eclipse.osgi.util.NLS;

public class PlatformURLBaseConnection
  extends PlatformURLConnection
{
  public static final String PLATFORM = "base";
  public static final String PLATFORM_URL_STRING = "platform:/base/";
  private static URL installURL;
  
  public PlatformURLBaseConnection(URL url)
  {
    super(url);
  }
  
  protected boolean allowCaching()
  {
    return true;
  }
  
  protected URL resolve()
    throws IOException
  {
    String spec = url.getFile().trim();
    if (spec.startsWith("/")) {
      spec = spec.substring(1);
    }
    if (!spec.startsWith("base/"))
    {
      String message = NLS.bind(CommonMessages.url_badVariant, url);
      throw new IOException(message);
    }
    return spec.length() == "base".length() + 1 ? installURL : new URL(installURL, spec.substring("base".length() + 1));
  }
  
  public static void startup(URL url)
  {
    if (installURL != null) {
      return;
    }
    installURL = url;
    PlatformURLHandler.register("base", PlatformURLBaseConnection.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.boot.PlatformURLBaseConnection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.boot;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
import java.util.Properties;
import org.eclipse.core.internal.runtime.Activator;
import org.eclipse.core.internal.runtime.CommonMessages;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version;

public abstract class PlatformURLConnection
  extends URLConnection
{
  private boolean isInCache = false;
  private boolean isJar = false;
  private URL resolvedURL = null;
  private URL cachedURL = null;
  private URLConnection connection = null;
  private static Properties cacheIndex = new Properties();
  private static String cacheLocation;
  private static String indexName;
  private static String filePrefix;
  private static final int BUF_SIZE = 32768;
  private static final Object NOT_FOUND = new Object();
  private static final String CACHE_PROP = ".cache.properties";
  private static final String CACHE_LOCATION_PROP = "location";
  private static final String CACHE_INDEX_PROP = "index";
  private static final String CACHE_PREFIX_PROP = "prefix";
  private static final String CACHE_INDEX = ".index.properties";
  private static final String CACHE_DIR = ".eclipse-platform" + File.separator;
  private static final String OPTION_DEBUG = "org.eclipse.core.runtime/url/debug";
  private static final String OPTION_DEBUG_CONNECT = "org.eclipse.core.runtime/url/debug/connect";
  private static final String OPTION_DEBUG_CACHE_LOOKUP = "org.eclipse.core.runtime/url/debug/cachelookup";
  private static final String OPTION_DEBUG_CACHE_COPY = "org.eclipse.core.runtime/url/debug/cachecopy";
  public static final boolean DEBUG;
  public static final boolean DEBUG_CONNECT;
  public static final boolean DEBUG_CACHE_LOOKUP;
  public static final boolean DEBUG_CACHE_COPY;
  
  static
  {
    Activator activator = Activator.getDefault();
    if (activator == null)
    {
      DEBUG = DEBUG_CONNECT = DEBUG_CACHE_LOOKUP = DEBUG_CACHE_COPY = 0;
    }
    else
    {
      DebugOptions debugOptions = activator.getDebugOptions();
      if (debugOptions != null)
      {
        DEBUG = debugOptions.getBooleanOption("org.eclipse.core.runtime/url/debug", false);
        DEBUG_CONNECT = debugOptions.getBooleanOption("org.eclipse.core.runtime/url/debug/connect", true);
        DEBUG_CACHE_LOOKUP = debugOptions.getBooleanOption("org.eclipse.core.runtime/url/debug/cachelookup", true);
        DEBUG_CACHE_COPY = debugOptions.getBooleanOption("org.eclipse.core.runtime/url/debug/cachecopy", true);
      }
      else
      {
        DEBUG = DEBUG_CONNECT = DEBUG_CACHE_LOOKUP = DEBUG_CACHE_COPY = 0;
      }
    }
  }
  
  protected PlatformURLConnection(URL url)
  {
    super(url);
  }
  
  protected boolean allowCaching()
  {
    return false;
  }
  
  public void connect()
    throws IOException
  {
    connect(false);
  }
  
  private synchronized void connect(boolean asLocal)
    throws IOException
  {
    if (connected) {
      return;
    }
    if (shouldCache(asLocal)) {
      try
      {
        URL inCache = getURLInCache();
        if (inCache != null) {
          connection = inCache.openConnection();
        }
      }
      catch (IOException localIOException) {}
    }
    if (connection == null) {
      connection = resolvedURL.openConnection();
    }
    connected = true;
    if ((DEBUG) && (DEBUG_CONNECT)) {
      debug("Connected as " + connection.getURL());
    }
  }
  
  /* Error */
  private void copyToCache()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 424	org/eclipse/core/internal/boot/PlatformURLConnection:isInCache	Z
    //   4: aload_0
    //   5: getfield 431	org/eclipse/core/internal/boot/PlatformURLConnection:cachedURL	Ljava/net/URL;
    //   8: ifnonnull +7 -> 15
    //   11: iconst_1
    //   12: goto +4 -> 16
    //   15: iconst_0
    //   16: ior
    //   17: ifeq +4 -> 21
    //   20: return
    //   21: aload_0
    //   22: getfield 425	org/eclipse/core/internal/boot/PlatformURLConnection:isJar	Z
    //   25: ifeq +35 -> 60
    //   28: aload_0
    //   29: getfield 433	org/eclipse/core/internal/boot/PlatformURLConnection:url	Ljava/net/URL;
    //   32: invokevirtual 480	java/net/URL:getFile	()Ljava/lang/String;
    //   35: astore_1
    //   36: aload_1
    //   37: ldc 2
    //   39: invokevirtual 469	java/lang/String:lastIndexOf	(Ljava/lang/String;)I
    //   42: istore_2
    //   43: iload_2
    //   44: iconst_m1
    //   45: if_icmpeq +10 -> 55
    //   48: aload_1
    //   49: iconst_0
    //   50: iload_2
    //   51: invokevirtual 466	java/lang/String:substring	(II)Ljava/lang/String;
    //   54: astore_1
    //   55: aload_1
    //   56: astore_3
    //   57: goto +11 -> 68
    //   60: aload_0
    //   61: getfield 433	org/eclipse/core/internal/boot/PlatformURLConnection:url	Ljava/net/URL;
    //   64: invokevirtual 480	java/net/URL:getFile	()Ljava/lang/String;
    //   67: astore_3
    //   68: aload_0
    //   69: getfield 425	org/eclipse/core/internal/boot/PlatformURLConnection:isJar	Z
    //   72: ifeq +43 -> 115
    //   75: aload_0
    //   76: getfield 432	org/eclipse/core/internal/boot/PlatformURLConnection:resolvedURL	Ljava/net/URL;
    //   79: invokevirtual 480	java/net/URL:getFile	()Ljava/lang/String;
    //   82: astore_1
    //   83: aload_1
    //   84: ldc 2
    //   86: invokevirtual 469	java/lang/String:lastIndexOf	(Ljava/lang/String;)I
    //   89: istore_2
    //   90: iload_2
    //   91: iconst_m1
    //   92: if_icmpeq +10 -> 102
    //   95: aload_1
    //   96: iconst_0
    //   97: iload_2
    //   98: invokevirtual 466	java/lang/String:substring	(II)Ljava/lang/String;
    //   101: astore_1
    //   102: new 265	java/net/URL
    //   105: dup
    //   106: aload_1
    //   107: invokespecial 484	java/net/URL:<init>	(Ljava/lang/String;)V
    //   110: astore 4
    //   112: goto +9 -> 121
    //   115: aload_0
    //   116: getfield 432	org/eclipse/core/internal/boot/PlatformURLConnection:resolvedURL	Ljava/net/URL;
    //   119: astore 4
    //   121: aconst_null
    //   122: astore 5
    //   124: aload_0
    //   125: getfield 425	org/eclipse/core/internal/boot/PlatformURLConnection:isJar	Z
    //   128: ifeq +56 -> 184
    //   131: aload_0
    //   132: getfield 431	org/eclipse/core/internal/boot/PlatformURLConnection:cachedURL	Ljava/net/URL;
    //   135: invokevirtual 480	java/net/URL:getFile	()Ljava/lang/String;
    //   138: astore_1
    //   139: aload_1
    //   140: ldc 6
    //   142: invokevirtual 468	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   145: istore_2
    //   146: iload_2
    //   147: iconst_m1
    //   148: if_icmpeq +11 -> 159
    //   151: aload_1
    //   152: iload_2
    //   153: iconst_1
    //   154: iadd
    //   155: invokevirtual 465	java/lang/String:substring	(I)Ljava/lang/String;
    //   158: astore_1
    //   159: aload_1
    //   160: ldc 2
    //   162: invokevirtual 469	java/lang/String:lastIndexOf	(Ljava/lang/String;)I
    //   165: istore_2
    //   166: iload_2
    //   167: iconst_m1
    //   168: if_icmpeq +10 -> 178
    //   171: aload_1
    //   172: iconst_0
    //   173: iload_2
    //   174: invokevirtual 466	java/lang/String:substring	(II)Ljava/lang/String;
    //   177: astore_1
    //   178: aload_1
    //   179: astore 6
    //   181: goto +12 -> 193
    //   184: aload_0
    //   185: getfield 431	org/eclipse/core/internal/boot/PlatformURLConnection:cachedURL	Ljava/net/URL;
    //   188: invokevirtual 480	java/net/URL:getFile	()Ljava/lang/String;
    //   191: astore 6
    //   193: aconst_null
    //   194: astore 7
    //   196: aconst_null
    //   197: astore 8
    //   199: iconst_0
    //   200: istore 9
    //   202: lconst_0
    //   203: lstore 10
    //   205: getstatic 419	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG	Z
    //   208: ifeq +61 -> 269
    //   211: getstatic 420	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG_CACHE_COPY	Z
    //   214: ifeq +55 -> 269
    //   217: aload_0
    //   218: getfield 425	org/eclipse/core/internal/boot/PlatformURLConnection:isJar	Z
    //   221: ifeq +27 -> 248
    //   224: aload_0
    //   225: new 262	java/lang/StringBuffer
    //   228: dup
    //   229: ldc 8
    //   231: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   234: aload 6
    //   236: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   239: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   242: invokevirtual 505	org/eclipse/core/internal/boot/PlatformURLConnection:debug	(Ljava/lang/String;)V
    //   245: goto +24 -> 269
    //   248: aload_0
    //   249: new 262	java/lang/StringBuffer
    //   252: dup
    //   253: ldc 7
    //   255: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   258: aload 6
    //   260: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   263: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   266: invokevirtual 505	org/eclipse/core/internal/boot/PlatformURLConnection:debug	(Ljava/lang/String;)V
    //   269: aload 4
    //   271: invokevirtual 479	java/net/URL:openStream	()Ljava/io/InputStream;
    //   274: astore 5
    //   276: ldc 1
    //   278: newarray <illegal type>
    //   280: astore 12
    //   282: aload 5
    //   284: aload 12
    //   286: invokevirtual 453	java/io/InputStream:read	([B)I
    //   289: istore 13
    //   291: new 250	java/io/File
    //   294: dup
    //   295: aload 6
    //   297: invokespecial 439	java/io/File:<init>	(Ljava/lang/String;)V
    //   300: astore 7
    //   302: new 253	java/io/FileOutputStream
    //   305: dup
    //   306: aload 7
    //   308: invokespecial 447	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   311: astore 8
    //   313: goto +30 -> 343
    //   316: lload 10
    //   318: iload 13
    //   320: i2l
    //   321: ladd
    //   322: lstore 10
    //   324: aload 8
    //   326: aload 12
    //   328: iconst_0
    //   329: iload 13
    //   331: invokevirtual 446	java/io/FileOutputStream:write	([BII)V
    //   334: aload 5
    //   336: aload 12
    //   338: invokevirtual 453	java/io/InputStream:read	([B)I
    //   341: istore 13
    //   343: iload 13
    //   345: iconst_m1
    //   346: if_icmpne -30 -> 316
    //   349: aload 5
    //   351: invokevirtual 452	java/io/InputStream:close	()V
    //   354: aconst_null
    //   355: astore 5
    //   357: aload 8
    //   359: invokevirtual 445	java/io/FileOutputStream:flush	()V
    //   362: aload 8
    //   364: invokevirtual 448	java/io/FileOutputStream:getFD	()Ljava/io/FileDescriptor;
    //   367: invokevirtual 440	java/io/FileDescriptor:sync	()V
    //   370: aload 8
    //   372: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   375: aconst_null
    //   376: astore 8
    //   378: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   381: aload_3
    //   382: aload 6
    //   384: invokevirtual 499	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   387: pop
    //   388: aload_0
    //   389: iconst_1
    //   390: putfield 424	org/eclipse/core/internal/boot/PlatformURLConnection:isInCache	Z
    //   393: goto +122 -> 515
    //   396: astore 12
    //   398: iconst_1
    //   399: istore 9
    //   401: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   404: aload_3
    //   405: getstatic 426	org/eclipse/core/internal/boot/PlatformURLConnection:NOT_FOUND	Ljava/lang/Object;
    //   408: invokevirtual 499	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   411: pop
    //   412: getstatic 419	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG	Z
    //   415: ifeq +30 -> 445
    //   418: getstatic 420	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG_CACHE_COPY	Z
    //   421: ifeq +24 -> 445
    //   424: aload_0
    //   425: new 262	java/lang/StringBuffer
    //   428: dup
    //   429: ldc 10
    //   431: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   434: aload 12
    //   436: invokevirtual 475	java/lang/StringBuffer:append	(Ljava/lang/Object;)Ljava/lang/StringBuffer;
    //   439: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   442: invokevirtual 505	org/eclipse/core/internal/boot/PlatformURLConnection:debug	(Ljava/lang/String;)V
    //   445: aload 12
    //   447: athrow
    //   448: astore 14
    //   450: iload 9
    //   452: ifne +40 -> 492
    //   455: getstatic 419	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG	Z
    //   458: ifeq +34 -> 492
    //   461: getstatic 420	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG_CACHE_COPY	Z
    //   464: ifeq +28 -> 492
    //   467: aload_0
    //   468: new 262	java/lang/StringBuffer
    //   471: dup
    //   472: lload 10
    //   474: invokestatic 467	java/lang/String:valueOf	(J)Ljava/lang/String;
    //   477: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   480: ldc_w 233
    //   483: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   486: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   489: invokevirtual 505	org/eclipse/core/internal/boot/PlatformURLConnection:debug	(Ljava/lang/String;)V
    //   492: aload 5
    //   494: ifnull +8 -> 502
    //   497: aload 5
    //   499: invokevirtual 452	java/io/InputStream:close	()V
    //   502: aload 8
    //   504: ifnull +8 -> 512
    //   507: aload 8
    //   509: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   512: aload 14
    //   514: athrow
    //   515: iload 9
    //   517: ifne +40 -> 557
    //   520: getstatic 419	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG	Z
    //   523: ifeq +34 -> 557
    //   526: getstatic 420	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG_CACHE_COPY	Z
    //   529: ifeq +28 -> 557
    //   532: aload_0
    //   533: new 262	java/lang/StringBuffer
    //   536: dup
    //   537: lload 10
    //   539: invokestatic 467	java/lang/String:valueOf	(J)Ljava/lang/String;
    //   542: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   545: ldc_w 233
    //   548: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   551: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   554: invokevirtual 505	org/eclipse/core/internal/boot/PlatformURLConnection:debug	(Ljava/lang/String;)V
    //   557: aload 5
    //   559: ifnull +8 -> 567
    //   562: aload 5
    //   564: invokevirtual 452	java/io/InputStream:close	()V
    //   567: aload 8
    //   569: ifnull +8 -> 577
    //   572: aload 8
    //   574: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   577: return
    // Line number table:
    //   Java source line #120	-> byte code offset #0
    //   Java source line #121	-> byte code offset #20
    //   Java source line #127	-> byte code offset #21
    //   Java source line #128	-> byte code offset #28
    //   Java source line #129	-> byte code offset #36
    //   Java source line #130	-> byte code offset #43
    //   Java source line #131	-> byte code offset #48
    //   Java source line #132	-> byte code offset #55
    //   Java source line #134	-> byte code offset #60
    //   Java source line #138	-> byte code offset #68
    //   Java source line #139	-> byte code offset #75
    //   Java source line #140	-> byte code offset #83
    //   Java source line #141	-> byte code offset #90
    //   Java source line #142	-> byte code offset #95
    //   Java source line #143	-> byte code offset #102
    //   Java source line #145	-> byte code offset #115
    //   Java source line #146	-> byte code offset #121
    //   Java source line #150	-> byte code offset #124
    //   Java source line #151	-> byte code offset #131
    //   Java source line #152	-> byte code offset #139
    //   Java source line #153	-> byte code offset #146
    //   Java source line #154	-> byte code offset #151
    //   Java source line #155	-> byte code offset #159
    //   Java source line #156	-> byte code offset #166
    //   Java source line #157	-> byte code offset #171
    //   Java source line #158	-> byte code offset #178
    //   Java source line #160	-> byte code offset #184
    //   Java source line #161	-> byte code offset #193
    //   Java source line #162	-> byte code offset #196
    //   Java source line #164	-> byte code offset #199
    //   Java source line #165	-> byte code offset #202
    //   Java source line #168	-> byte code offset #205
    //   Java source line #169	-> byte code offset #217
    //   Java source line #170	-> byte code offset #224
    //   Java source line #172	-> byte code offset #248
    //   Java source line #175	-> byte code offset #269
    //   Java source line #176	-> byte code offset #276
    //   Java source line #177	-> byte code offset #282
    //   Java source line #179	-> byte code offset #291
    //   Java source line #180	-> byte code offset #302
    //   Java source line #182	-> byte code offset #313
    //   Java source line #183	-> byte code offset #316
    //   Java source line #184	-> byte code offset #324
    //   Java source line #185	-> byte code offset #334
    //   Java source line #182	-> byte code offset #343
    //   Java source line #188	-> byte code offset #349
    //   Java source line #189	-> byte code offset #354
    //   Java source line #190	-> byte code offset #357
    //   Java source line #191	-> byte code offset #362
    //   Java source line #192	-> byte code offset #370
    //   Java source line #193	-> byte code offset #375
    //   Java source line #196	-> byte code offset #378
    //   Java source line #197	-> byte code offset #388
    //   Java source line #198	-> byte code offset #396
    //   Java source line #199	-> byte code offset #398
    //   Java source line #200	-> byte code offset #401
    //   Java source line #202	-> byte code offset #412
    //   Java source line #203	-> byte code offset #424
    //   Java source line #204	-> byte code offset #445
    //   Java source line #205	-> byte code offset #448
    //   Java source line #206	-> byte code offset #450
    //   Java source line #207	-> byte code offset #467
    //   Java source line #208	-> byte code offset #492
    //   Java source line #209	-> byte code offset #497
    //   Java source line #210	-> byte code offset #502
    //   Java source line #211	-> byte code offset #507
    //   Java source line #212	-> byte code offset #512
    //   Java source line #206	-> byte code offset #515
    //   Java source line #207	-> byte code offset #532
    //   Java source line #208	-> byte code offset #557
    //   Java source line #209	-> byte code offset #562
    //   Java source line #210	-> byte code offset #567
    //   Java source line #211	-> byte code offset #572
    //   Java source line #213	-> byte code offset #577
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	578	0	this	PlatformURLConnection
    //   35	21	1	tmp	String
    //   82	25	1	tmp	String
    //   138	41	1	tmp	String
    //   42	9	2	ix	int
    //   89	9	2	ix	int
    //   145	29	2	ix	int
    //   56	2	3	key	String
    //   67	338	3	key	String
    //   110	3	4	src	URL
    //   119	151	4	src	URL
    //   122	441	5	srcis	InputStream
    //   179	3	6	tgt	String
    //   191	192	6	tgt	String
    //   194	113	7	tgtFile	File
    //   197	376	8	tgtos	java.io.FileOutputStream
    //   200	316	9	error	boolean
    //   203	335	10	total	long
    //   280	57	12	buf	byte[]
    //   396	50	12	e	IOException
    //   289	55	13	count	int
    //   448	65	14	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   205	393	396	java/io/IOException
    //   205	448	448	finally
  }
  
  protected void debug(String s)
  {
    System.out.println("URL " + getURL().toString() + "^" + Integer.toHexString(Thread.currentThread().hashCode()) + " " + s);
  }
  
  private static void debugStartup(String s)
  {
    System.out.println("URL " + s);
  }
  
  public URL[] getAuxillaryURLs()
    throws IOException
  {
    return null;
  }
  
  public synchronized InputStream getInputStream()
    throws IOException
  {
    if (!connected) {
      connect();
    }
    return connection.getInputStream();
  }
  
  public URL getResolvedURL()
  {
    return resolvedURL;
  }
  
  public URL getURLAsLocal()
    throws IOException
  {
    connect(true);
    URL u = connection.getURL();
    String up = u.getProtocol();
    if ((!up.equals("file")) && (!up.equals("jar")) && (!up.startsWith("bundle"))) {
      throw new IOException(NLS.bind(CommonMessages.url_noaccess, up));
    }
    return u;
  }
  
  private URL getURLInCache()
    throws IOException
  {
    if (!allowCaching()) {
      return null;
    }
    if (isInCache) {
      return cachedURL;
    }
    if (((cacheLocation == null ? 1 : 0) | (cacheIndex == null ? 1 : 0)) != 0) {
      return null;
    }
    String file = "";
    String jarEntry = null;
    if (isJar)
    {
      file = url.getFile();
      int ix = file.lastIndexOf("!/");
      if (ix != -1)
      {
        jarEntry = file.substring(ix + "!/".length());
        file = file.substring(0, ix);
      }
    }
    else
    {
      file = url.getFile();
    }
    String tmp = (String)cacheIndex.get(file);
    if ((tmp != null) && (tmp == NOT_FOUND)) {
      throw new IOException();
    }
    if ((tmp != null) && (!new File(tmp).exists()))
    {
      tmp = null;
      cacheIndex.remove(url.getFile());
    }
    if (tmp != null)
    {
      if (isJar)
      {
        if ((DEBUG) && (DEBUG_CACHE_LOOKUP)) {
          debug("Jar located in cache as " + tmp);
        }
        tmp = "file:" + tmp + "!/" + jarEntry;
        cachedURL = new URL("jar", null, -1, tmp);
      }
      else
      {
        if ((DEBUG) && (DEBUG_CACHE_LOOKUP)) {
          debug("Located in cache as " + tmp);
        }
        cachedURL = new URL("file", null, -1, tmp);
      }
      isInCache = true;
    }
    else
    {
      int ix = file.lastIndexOf("/");
      tmp = file.substring(ix + 1);
      tmp = cacheLocation + filePrefix + Long.toString(new Date().getTime()) + "_" + tmp;
      tmp = tmp.replace(File.separatorChar, '/');
      if (isJar)
      {
        tmp = "file:" + tmp + "!/" + jarEntry;
        cachedURL = new URL("jar", null, -1, tmp);
      }
      else
      {
        cachedURL = new URL("file", null, -1, tmp);
      }
      copyToCache();
    }
    return cachedURL;
  }
  
  protected URL resolve()
    throws IOException
  {
    throw new IOException();
  }
  
  protected static String getId(String spec)
  {
    String id = (String)parse(spec)[0];
    return id == null ? spec : id;
  }
  
  protected static String getVersion(String spec)
  {
    Version version = (Version)parse(spec)[1];
    return version == null ? "" : version.toString();
  }
  
  private static Object[] parse(String spec)
  {
    String bsn = null;
    Version version = null;
    int underScore = spec.indexOf('_');
    while (underScore >= 0)
    {
      try
      {
        version = Version.parseVersion(spec.substring(underScore + 1));
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        underScore = spec.indexOf('_', underScore + 1);
        continue;
      }
      bsn = spec.substring(0, underScore);
      break;
    }
    return new Object[] { bsn, version };
  }
  
  void setResolvedURL(URL url)
    throws IOException
  {
    if (url == null) {
      throw new IOException();
    }
    if (resolvedURL != null) {
      return;
    }
    int ix = url.getFile().lastIndexOf("!/");
    isJar = (-1 != ix);
    if ((isJar) && (!url.getProtocol().equals("jar"))) {
      url = new URL("jar", "", -1, url.toExternalForm());
    }
    resolvedURL = url;
  }
  
  private boolean shouldCache(boolean asLocal)
  {
    String rp = resolvedURL.getProtocol();
    String rf = resolvedURL.getFile();
    if (rp.equals("file")) {
      return false;
    }
    if ((rp.equals("jar")) && (rf.startsWith("file"))) {
      return false;
    }
    if (asLocal) {
      return true;
    }
    return true;
  }
  
  /* Error */
  static void shutdown()
  {
    // Byte code:
    //   0: getstatic 430	org/eclipse/core/internal/boot/PlatformURLConnection:indexName	Ljava/lang/String;
    //   3: ifnull +142 -> 145
    //   6: getstatic 428	org/eclipse/core/internal/boot/PlatformURLConnection:cacheLocation	Ljava/lang/String;
    //   9: ifnull +136 -> 145
    //   12: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   15: invokevirtual 495	java/util/Properties:keys	()Ljava/util/Enumeration;
    //   18: astore_0
    //   19: goto +36 -> 55
    //   22: aload_0
    //   23: invokeinterface 517 1 0
    //   28: checkcast 261	java/lang/String
    //   31: astore_1
    //   32: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   35: aload_1
    //   36: invokevirtual 496	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   39: astore_2
    //   40: aload_2
    //   41: getstatic 426	org/eclipse/core/internal/boot/PlatformURLConnection:NOT_FOUND	Ljava/lang/Object;
    //   44: if_acmpne +11 -> 55
    //   47: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   50: aload_1
    //   51: invokevirtual 497	java/util/Properties:remove	(Ljava/lang/Object;)Ljava/lang/Object;
    //   54: pop
    //   55: aload_0
    //   56: invokeinterface 516 1 0
    //   61: ifne -39 -> 22
    //   64: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   67: invokevirtual 492	java/util/Properties:size	()I
    //   70: ifne +4 -> 74
    //   73: return
    //   74: aconst_null
    //   75: astore_3
    //   76: new 253	java/io/FileOutputStream
    //   79: dup
    //   80: new 262	java/lang/StringBuffer
    //   83: dup
    //   84: getstatic 428	org/eclipse/core/internal/boot/PlatformURLConnection:cacheLocation	Ljava/lang/String;
    //   87: invokestatic 472	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   90: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   93: getstatic 430	org/eclipse/core/internal/boot/PlatformURLConnection:indexName	Ljava/lang/String;
    //   96: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   99: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   102: invokespecial 449	java/io/FileOutputStream:<init>	(Ljava/lang/String;)V
    //   105: astore_3
    //   106: getstatic 435	org/eclipse/core/internal/boot/PlatformURLConnection:cacheIndex	Ljava/util/Properties;
    //   109: aload_3
    //   110: aconst_null
    //   111: invokevirtual 498	java/util/Properties:store	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   114: aload_3
    //   115: invokevirtual 445	java/io/FileOutputStream:flush	()V
    //   118: aload_3
    //   119: invokevirtual 448	java/io/FileOutputStream:getFD	()Ljava/io/FileDescriptor;
    //   122: invokevirtual 440	java/io/FileDescriptor:sync	()V
    //   125: goto +12 -> 137
    //   128: astore 4
    //   130: aload_3
    //   131: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   134: aload 4
    //   136: athrow
    //   137: aload_3
    //   138: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   141: goto +4 -> 145
    //   144: pop
    //   145: return
    // Line number table:
    //   Java source line #386	-> byte code offset #0
    //   Java source line #388	-> byte code offset #12
    //   Java source line #391	-> byte code offset #19
    //   Java source line #392	-> byte code offset #22
    //   Java source line #393	-> byte code offset #32
    //   Java source line #394	-> byte code offset #40
    //   Java source line #395	-> byte code offset #47
    //   Java source line #391	-> byte code offset #55
    //   Java source line #398	-> byte code offset #64
    //   Java source line #399	-> byte code offset #73
    //   Java source line #402	-> byte code offset #74
    //   Java source line #403	-> byte code offset #76
    //   Java source line #405	-> byte code offset #106
    //   Java source line #406	-> byte code offset #114
    //   Java source line #407	-> byte code offset #118
    //   Java source line #408	-> byte code offset #128
    //   Java source line #409	-> byte code offset #130
    //   Java source line #410	-> byte code offset #134
    //   Java source line #409	-> byte code offset #137
    //   Java source line #411	-> byte code offset #144
    //   Java source line #415	-> byte code offset #145
    // Local variable table:
    //   start	length	slot	name	signature
    //   18	38	0	keys	java.util.Enumeration
    //   31	20	1	key	String
    //   39	2	2	value	Object
    //   75	63	3	fos	java.io.FileOutputStream
    //   128	7	4	localObject1	Object
    //   144	1	5	localIOException	IOException
    // Exception table:
    //   from	to	target	type
    //   106	128	128	finally
    //   74	141	144	java/io/IOException
  }
  
  /* Error */
  static void startup(String location, String os, String ws, String nl)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokestatic 507	org/eclipse/core/internal/boot/PlatformURLConnection:verifyLocation	(Ljava/lang/String;)Z
    //   4: pop
    //   5: aload_0
    //   6: invokevirtual 463	java/lang/String:trim	()Ljava/lang/String;
    //   9: astore 4
    //   11: aload 4
    //   13: getstatic 417	java/io/File:separator	Ljava/lang/String;
    //   16: invokevirtual 470	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   19: ifne +26 -> 45
    //   22: new 262	java/lang/StringBuffer
    //   25: dup
    //   26: aload 4
    //   28: invokestatic 472	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   31: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   34: getstatic 417	java/io/File:separator	Ljava/lang/String;
    //   37: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   40: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   43: astore 4
    //   45: new 262	java/lang/StringBuffer
    //   48: dup
    //   49: aload 4
    //   51: invokestatic 472	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   54: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   57: ldc 3
    //   59: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   62: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   65: astore 4
    //   67: new 250	java/io/File
    //   70: dup
    //   71: aload 4
    //   73: invokespecial 439	java/io/File:<init>	(Ljava/lang/String;)V
    //   76: astore 5
    //   78: aconst_null
    //   79: astore 6
    //   81: aload 5
    //   83: invokevirtual 437	java/io/File:exists	()Z
    //   86: ifeq +55 -> 141
    //   89: new 269	java/util/Properties
    //   92: dup
    //   93: invokespecial 493	java/util/Properties:<init>	()V
    //   96: astore 6
    //   98: new 252	java/io/FileInputStream
    //   101: dup
    //   102: aload 5
    //   104: invokespecial 442	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   107: astore 7
    //   109: aload 6
    //   111: aload 7
    //   113: invokevirtual 494	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   116: goto +13 -> 129
    //   119: astore 8
    //   121: aload 7
    //   123: invokevirtual 441	java/io/FileInputStream:close	()V
    //   126: aload 8
    //   128: athrow
    //   129: aload 7
    //   131: invokevirtual 441	java/io/FileInputStream:close	()V
    //   134: goto +7 -> 141
    //   137: pop
    //   138: aconst_null
    //   139: astore 6
    //   141: aload 6
    //   143: ifnonnull +201 -> 344
    //   146: new 269	java/util/Properties
    //   149: dup
    //   150: invokespecial 493	java/util/Properties:<init>	()V
    //   153: astore 6
    //   155: ldc_w 249
    //   158: invokestatic 477	java/lang/System:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   161: astore 8
    //   163: aload 8
    //   165: getstatic 417	java/io/File:separator	Ljava/lang/String;
    //   168: invokevirtual 470	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   171: ifne +26 -> 197
    //   174: new 262	java/lang/StringBuffer
    //   177: dup
    //   178: aload 8
    //   180: invokestatic 472	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   183: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   186: getstatic 417	java/io/File:separator	Ljava/lang/String;
    //   189: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   192: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   195: astore 8
    //   197: new 262	java/lang/StringBuffer
    //   200: dup
    //   201: aload 8
    //   203: invokestatic 472	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   206: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   209: getstatic 427	org/eclipse/core/internal/boot/PlatformURLConnection:CACHE_DIR	Ljava/lang/String;
    //   212: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   215: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   218: astore 8
    //   220: aload 6
    //   222: ldc 12
    //   224: aload 8
    //   226: invokevirtual 499	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   229: pop
    //   230: new 267	java/util/Date
    //   233: dup
    //   234: invokespecial 491	java/util/Date:<init>	()V
    //   237: invokevirtual 490	java/util/Date:getTime	()J
    //   240: invokestatic 456	java/lang/Long:toString	(J)Ljava/lang/String;
    //   243: astore 8
    //   245: aload 6
    //   247: ldc 17
    //   249: aload 8
    //   251: invokevirtual 499	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   254: pop
    //   255: new 262	java/lang/StringBuffer
    //   258: dup
    //   259: aload 8
    //   261: invokestatic 472	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   264: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   267: ldc 5
    //   269: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   272: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   275: astore 8
    //   277: aload 6
    //   279: ldc 11
    //   281: aload 8
    //   283: invokevirtual 499	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   286: pop
    //   287: aconst_null
    //   288: astore 9
    //   290: new 253	java/io/FileOutputStream
    //   293: dup
    //   294: aload 5
    //   296: invokespecial 447	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   299: astore 9
    //   301: aload 6
    //   303: aload 9
    //   305: aconst_null
    //   306: invokevirtual 498	java/util/Properties:store	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   309: aload 9
    //   311: invokevirtual 445	java/io/FileOutputStream:flush	()V
    //   314: aload 9
    //   316: invokevirtual 448	java/io/FileOutputStream:getFD	()Ljava/io/FileDescriptor;
    //   319: invokevirtual 440	java/io/FileDescriptor:sync	()V
    //   322: goto +13 -> 335
    //   325: astore 10
    //   327: aload 9
    //   329: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   332: aload 10
    //   334: athrow
    //   335: aload 9
    //   337: invokevirtual 444	java/io/FileOutputStream:close	()V
    //   340: goto +4 -> 344
    //   343: pop
    //   344: aload 6
    //   346: ldc 17
    //   348: invokevirtual 496	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   351: checkcast 261	java/lang/String
    //   354: putstatic 429	org/eclipse/core/internal/boot/PlatformURLConnection:filePrefix	Ljava/lang/String;
    //   357: aload 6
    //   359: ldc 11
    //   361: invokevirtual 496	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   364: checkcast 261	java/lang/String
    //   367: putstatic 430	org/eclipse/core/internal/boot/PlatformURLConnection:indexName	Ljava/lang/String;
    //   370: aload 6
    //   372: ldc 12
    //   374: invokevirtual 496	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   377: checkcast 261	java/lang/String
    //   380: putstatic 428	org/eclipse/core/internal/boot/PlatformURLConnection:cacheLocation	Ljava/lang/String;
    //   383: getstatic 419	org/eclipse/core/internal/boot/PlatformURLConnection:DEBUG	Z
    //   386: ifeq +69 -> 455
    //   389: new 262	java/lang/StringBuffer
    //   392: dup
    //   393: ldc_w 237
    //   396: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   399: getstatic 428	org/eclipse/core/internal/boot/PlatformURLConnection:cacheLocation	Ljava/lang/String;
    //   402: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   405: invokevirtual 473	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   408: invokestatic 506	org/eclipse/core/internal/boot/PlatformURLConnection:debugStartup	(Ljava/lang/String;)V
    //   411: new 262	java/lang/StringBuffer
    //   414: dup
    //   415: ldc_w 236
    //   418: invokespecial 474	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   421: getstatic 430	org/eclipse/core/internal/boot/PlatformURLConnection:indexName	Ljava/lang/String;
    //   424: invokevirtual 476	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   427: 
1 2 3 4 5 6

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-2017. Infinite Loop Ltd