org.eclipse.osgi_3.8.2.v20130124-134944

i = 0; i < numBundles; i++) {
        readBundleDescriptionLazyData(lazyIn, 0);
      }
    }
    finally
    {
      in.close();
      if (lazyIn != null) {
        try
        {
          lazyIn.close();
        }
        catch (IOException localIOException5) {}
      }
    }
    in.close();
    if (lazyIn != null) {
      try
      {
        lazyIn.close();
      }
      catch (IOException localIOException6) {}
    }
    return true;
  }
  
  private boolean readStateDeprecated(StateImpl state, DataInputStream in, long expectedTimestamp)
    throws IOException
  {
    if (in.readByte() != 38) {
      return false;
    }
    byte tag = readTag(in);
    if (tag != 1) {
      return false;
    }
    int index = in.readInt();
    long timestampRead = in.readLong();
    if ((expectedTimestamp >= 0L) && (timestampRead != expectedTimestamp)) {
      return false;
    }
    addToObjectTable(state, index);
    
    String[] platformPropKeys = (String[])readPlatformProp(in);
    state.addPlatformPropertyKeys(platformPropKeys);
    int numSets = in.readInt();
    Dictionary[] platformProps = new Dictionary[numSets];
    for (int i = 0; i < numSets; i++)
    {
      Hashtable<Object, Object> props = new Hashtable(platformPropKeys.length);
      int numProps = in.readInt();
      for (int j = 0; j < numProps; j++)
      {
        Object value = readPlatformProp(in);
        if ((value != null) && (j < platformPropKeys.length)) {
          props.put(platformPropKeys[j], value);
        }
      }
      platformProps[i] = props;
    }
    state.setPlatformProperties(platformProps);
    numBundles = in.readInt();
    if (numBundles == 0) {
      return true;
    }
    for (int i = 0; i < numBundles; i++)
    {
      BundleDescriptionImpl bundle = readBundleDescription(in);
      state.basicAddBundle(bundle);
      if (bundle.isResolved()) {
        state.addResolvedBundle(bundle);
      }
    }
    state.setTimeStamp(timestampRead);
    state.setResolved(in.readBoolean());
    in.readInt();
    if (lazyLoad) {
      return true;
    }
    for (int i = 0; i < numBundles; i++) {
      readBundleDescriptionLazyData(in, 0);
    }
    return true;
  }
  
  private Object readPlatformProp(DataInputStream in)
    throws IOException
  {
    byte type = in.readByte();
    if (type == 0) {
      return null;
    }
    int num = in.readInt();
    if (num == 1) {
      return readString(in, false);
    }
    String[] result = new String[num];
    for (int i = 0; i < result.length; i++) {
      result[i] = readString(in, false);
    }
    return result;
  }
  
  private BundleDescriptionImpl readBundleDescription(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (BundleDescriptionImpl)getFromObjectTable(in.readInt());
    }
    BundleDescriptionImpl result = new BundleDescriptionImpl();
    addToObjectTable(result, in.readInt());
    
    result.setBundleId(in.readLong());
    readBaseDescription(result, in);
    result.setLazyDataOffset(in.readInt());
    result.setLazyDataSize(in.readInt());
    result.setStateBit(1, in.readBoolean());
    result.setStateBit(2, in.readBoolean());
    result.setStateBit(32, in.readBoolean());
    result.setStateBit(64, in.readBoolean());
    result.setStateBit(128, in.readBoolean());
    String[] mandatory = readList(in);
    if (mandatory != null) {
      result.setDirective("mandatory", mandatory);
    }
    result.setAttributes(readMap(in));
    result.setArbitraryDirectives(readMap(in));
    result.setHost(readHostSpec(in));
    
    int numDeps = in.readInt();
    if (numDeps > 0)
    {
      BundleDescription[] deps = new BundleDescription[numDeps];
      for (int i = 0; i < numDeps; i++) {
        deps[i] = readBundleDescription(in);
      }
      result.addDependencies(deps, false);
    }
    HostSpecificationImpl hostSpec = (HostSpecificationImpl)result.getHost();
    if (hostSpec != null)
    {
      BundleDescription[] hosts = hostSpec.getHosts();
      if (hosts != null) {
        for (int i = 0; i < hosts.length; i++) {
          ((BundleDescriptionImpl)hosts[i]).addDependency(result, false);
        }
      }
    }
    result.setFullyLoaded(false);
    return result;
  }
  
  private BundleDescriptionImpl readBundleDescriptionLazyData(DataInputStream in, int skip)
    throws IOException
  {
    if (skip > 0) {
      in.skipBytes(skip);
    }
    int index = in.readInt();
    BundleDescriptionImpl result = (BundleDescriptionImpl)getFromObjectTable(index);
    if (result.isFullyLoaded())
    {
      in.skipBytes(result.getLazyDataSize() - 4);
      return result;
    }
    result.setLocation(readString(in, false));
    result.setPlatformFilter(readString(in, false));
    
    int exportCount = in.readInt();
    if (exportCount > 0)
    {
      ExportPackageDescription[] exports = new ExportPackageDescription[exportCount];
      for (int i = 0; i < exports.length; i++) {
        exports[i] = readExportPackageDesc(in);
      }
      result.setExportPackages(exports);
    }
    int importCount = in.readInt();
    if (importCount > 0)
    {
      ImportPackageSpecification[] imports = new ImportPackageSpecification[importCount];
      for (int i = 0; i < imports.length; i++) {
        imports[i] = readImportPackageSpec(in);
      }
      result.setImportPackages(imports);
    }
    int requiredBundleCount = in.readInt();
    if (requiredBundleCount > 0)
    {
      BundleSpecification[] requiredBundles = new BundleSpecification[requiredBundleCount];
      for (int i = 0; i < requiredBundles.length; i++) {
        requiredBundles[i] = readBundleSpec(in);
      }
      result.setRequiredBundles(requiredBundles);
    }
    int selectedCount = in.readInt();
    if (selectedCount > 0)
    {
      ExportPackageDescription[] selected = new ExportPackageDescription[selectedCount];
      for (int i = 0; i < selected.length; i++) {
        selected[i] = readExportPackageDesc(in);
      }
      result.setSelectedExports(selected);
    }
    int substitutedCount = in.readInt();
    if (substitutedCount > 0)
    {
      ExportPackageDescription[] selected = new ExportPackageDescription[substitutedCount];
      for (int i = 0; i < selected.length; i++) {
        selected[i] = readExportPackageDesc(in);
      }
      result.setSubstitutedExports(selected);
    }
    int resolvedCount = in.readInt();
    if (resolvedCount > 0)
    {
      ExportPackageDescription[] resolved = new ExportPackageDescription[resolvedCount];
      for (int i = 0; i < resolved.length; i++) {
        resolved[i] = readExportPackageDesc(in);
      }
      result.setResolvedImports(resolved);
    }
    int resolvedRequiredCount = in.readInt();
    if (resolvedRequiredCount > 0)
    {
      BundleDescription[] resolved = new BundleDescription[resolvedRequiredCount];
      for (int i = 0; i < resolved.length; i++) {
        resolved[i] = readBundleDescription(in);
      }
      result.setResolvedRequires(resolved);
    }
    int eeCount = in.readInt();
    if (eeCount > 0)
    {
      String[] ee = new String[eeCount];
      for (int i = 0; i < ee.length; i++) {
        ee[i] = readString(in, false);
      }
      result.setExecutionEnvironments(ee);
    }
    int dynamicPkgCnt = in.readInt();
    if (dynamicPkgCnt > 0)
    {
      HashMap<String, Long> dynamicStamps = new HashMap(dynamicPkgCnt);
      for (int i = 0; i < dynamicPkgCnt; i++)
      {
        String pkg = readString(in, false);
        Long stamp = new Long(in.readLong());
        dynamicStamps.put(pkg, stamp);
      }
      result.setDynamicStamps(dynamicStamps);
    }
    int genericCapCnt = in.readInt();
    if (genericCapCnt > 0)
    {
      GenericDescription[] capabilities = new GenericDescription[genericCapCnt];
      for (int i = 0; i < capabilities.length; i++) {
        capabilities[i] = readGenericDescription(in);
      }
      result.setGenericCapabilities(capabilities);
    }
    int genericReqCnt = in.readInt();
    if (genericReqCnt > 0)
    {
      GenericSpecification[] reqs = new GenericSpecification[genericReqCnt];
      for (int i = 0; i < reqs.length; i++) {
        reqs[i] = readGenericSpecification(in);
      }
      result.setGenericRequires(reqs);
    }
    int selectedGenCapCnt = in.readInt();
    if (selectedGenCapCnt > 0)
    {
      GenericDescription[] capabilities = new GenericDescription[selectedGenCapCnt];
      for (int i = 0; i < capabilities.length; i++) {
        capabilities[i] = readGenericDescription(in);
      }
      result.setSelectedCapabilities(capabilities);
    }
    int resolvedGenCapCnt = in.readInt();
    if (resolvedGenCapCnt > 0)
    {
      GenericDescription[] capabilities = new GenericDescription[resolvedGenCapCnt];
      for (int i = 0; i < capabilities.length; i++) {
        capabilities[i] = readGenericDescription(in);
      }
      result.setResolvedCapabilities(capabilities);
    }
    result.setNativeCodeSpecification(readNativeCode(in));
    
    Map raw = readMap(in);
    result.setStateWires(raw);
    
    result.setFullyLoaded(true);
    
    return result;
  }
  
  private BundleSpecificationImpl readBundleSpec(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (BundleSpecificationImpl)getFromObjectTable(in.readInt());
    }
    BundleSpecificationImpl result = new BundleSpecificationImpl();
    int tableIndex = in.readInt();
    addToObjectTable(result, tableIndex);
    readVersionConstraint(result, in);
    result.setSupplier(readBundleDescription(in));
    result.setExported(in.readBoolean());
    result.setOptional(in.readBoolean());
    result.setAttributes(readMap(in));
    result.setArbitraryDirectives(readMap(in));
    return result;
  }
  
  private ExportPackageDescriptionImpl readExportPackageDesc(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (ExportPackageDescriptionImpl)getFromObjectTable(in.readInt());
    }
    ExportPackageDescriptionImpl exportPackageDesc = new ExportPackageDescriptionImpl();
    int tableIndex = in.readInt();
    addToObjectTable(exportPackageDesc, tableIndex);
    readBaseDescription(exportPackageDesc, in);
    exportPackageDesc.setExporter(readBundleDescription(in));
    exportPackageDesc.setAttributes(readMap(in));
    exportPackageDesc.setDirectives(readMap(in));
    exportPackageDesc.setArbitraryDirectives(readMap(in));
    exportPackageDesc.setFragmentDeclaration(readExportPackageDesc(in));
    return exportPackageDesc;
  }
  
  private DisabledInfo readDisabledInfo(DataInputStream in)
    throws IOException
  {
    return new DisabledInfo(readString(in, false), readString(in, false), readBundleDescription(in));
  }
  
  private Map<String, Object> readMap(DataInputStream in)
    throws IOException
  {
    int count = in.readInt();
    if (count == 0) {
      return null;
    }
    HashMap<String, Object> result = new HashMap(count);
    for (int i = 0; i < count; i++)
    {
      String key = readString(in, false);
      Object value = null;
      byte type = in.readByte();
      if (type == 0)
      {
        value = readString(in, false);
      }
      else if (type == 1)
      {
        value = readList(in);
      }
      else if (type == 2)
      {
        value = in.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
      }
      else if (type == 3)
      {
        value = new Integer(in.readInt());
      }
      else if (type == 4)
      {
        value = new Long(in.readLong());
      }
      else if (type == 5)
      {
        value = new Double(in.readDouble());
      }
      else if (type == 6)
      {
        value = readVersion(in);
      }
      else if (type == 7)
      {
        value = readString(in, false);
        try
        {
          Class<?> uriClazz = Class.forName("java.net.URI");
          Constructor<?> constructor = uriClazz.getConstructor(new Class[] { String.class });
          value = constructor.newInstance(new Object[] { value });
        }
        catch (ClassNotFoundException localClassNotFoundException2) {}catch (RuntimeException e)
        {
          throw e;
        }
        catch (Exception e)
        {
          throw new RuntimeException(e.getMessage(), e);
        }
      }
      else if (type == 8)
      {
        int listType = in.readByte();
        int size = in.readInt();
        List<Object> list = new ArrayList(size);
        for (int j = 0; j < size; j++) {
          switch (listType)
          {
          case 0: 
            list.add(readString(in, false));
            break;
          case 3: 
            list.add(new Integer(in.readInt()));
            break;
          case 4: 
            list.add(new Long(in.readLong()));
            break;
          case 5: 
            list.add(new Double(in.readDouble()));
            break;
          case 6: 
            list.add(readVersion(in));
            break;
          case 7: 
            list.add(readStateWire(in));
            break;
          case 1: 
          case 2: 
          default: 
            throw new IOException("Invalid type: " + listType);
          }
        }
        value = list;
      }
      result.put(key, value);
    }
    return result;
  }
  
  private Object readStateWire(DataInputStream in)
    throws IOException
  {
    byte wireType = in.readByte();
    BaseDescription capability;
    BaseDescription capability;
    BaseDescription capability;
    BaseDescription capability;
    switch (wireType)
    {
    case 0: 
      VersionConstraintImpl requirement = readImportPackageSpec(in);
      capability = readExportPackageDesc(in);
      break;
    case 1: 
      VersionConstraintImpl requirement = readBundleSpec(in);
      capability = readBundleDescription(in);
      break;
    case 2: 
      VersionConstraintImpl requirement = readHostSpec(in);
      capability = readBundleDescription(in);
      break;
    case 3: 
      VersionConstraintImpl requirement = readGenericSpecification(in);
      capability = readGenericDescription(in);
      break;
    default: 
      throw new IOException("Invalid wire type: " + wireType);
    }
    BaseDescription capability;
    VersionConstraintImpl requirement;
    BundleDescription requirementHost = readBundleDescription(in);
    BundleDescription capabilityHost = readBundleDescription(in);
    if (requirement.getBundle() == null) {
      requirement.setBundle(requirementHost);
    }
    return new StateWire(requirementHost, requirement, capabilityHost, capability);
  }
  
  private String[] readList(DataInputStream in)
    throws IOException
  {
    int count = in.readInt();
    if (count == 0) {
      return null;
    }
    String[] result = new String[count];
    for (int i = 0; i < count; i++) {
      result[i] = readString(in, false);
    }
    return result;
  }
  
  private void readBaseDescription(BaseDescriptionImpl root, DataInputStream in)
    throws IOException
  {
    root.setName(readString(in, false));
    root.setVersion(readVersion(in));
  }
  
  private ImportPackageSpecificationImpl readImportPackageSpec(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (ImportPackageSpecificationImpl)getFromObjectTable(in.readInt());
    }
    ImportPackageSpecificationImpl result = new ImportPackageSpecificationImpl();
    int tableIndex = in.readInt();
    addToObjectTable(result, tableIndex);
    readVersionConstraint(result, in);
    result.setSupplier(readExportPackageDesc(in));
    result.setBundleSymbolicName(readString(in, false));
    result.setBundleVersionRange(readVersionRange(in));
    result.setAttributes(readMap(in));
    result.setDirectives(readMap(in));
    result.setArbitraryDirectives(readMap(in));
    return result;
  }
  
  private HostSpecificationImpl readHostSpec(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (HostSpecificationImpl)getFromObjectTable(in.readInt());
    }
    HostSpecificationImpl result = new HostSpecificationImpl();
    int tableIndex = in.readInt();
    addToObjectTable(result, tableIndex);
    readVersionConstraint(result, in);
    int hostCount = in.readInt();
    if (hostCount > 0)
    {
      BundleDescription[] hosts = new BundleDescription[hostCount];
      for (int i = 0; i < hosts.length; i++) {
        hosts[i] = readBundleDescription(in);
      }
      result.setHosts(hosts);
    }
    result.setAttributes(readMap(in));
    result.setArbitraryDirectives(readMap(in));
    return result;
  }
  
  private GenericDescription readGenericDescription(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (GenericDescription)getFromObjectTable(in.readInt());
    }
    int tableIndex = in.readInt();
    GenericDescriptionImpl result = new GenericDescriptionImpl();
    addToObjectTable(result, tableIndex);
    readBaseDescription(result, in);
    result.setSupplier(readBundleDescription(in));
    result.setType(readString(in, false));
    Map<String, Object> mapAttrs = readMap(in);
    Dictionary<String, Object> attrs = new Hashtable();
    if (mapAttrs != null) {
      for (Iterator<String> keys = mapAttrs.keySet().iterator(); keys.hasNext();)
      {
        String key = (String)keys.next();
        attrs.put(key, mapAttrs.get(key));
      }
    }
    result.setAttributes(attrs);
    Map directives = readMap(in);
    if (directives != null) {
      result.setDirectives(directives);
    }
    result.setFragmentDeclaration(readGenericDescription(in));
    return result;
  }
  
  private GenericSpecificationImpl readGenericSpecification(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    if (tag == 2) {
      return (GenericSpecificationImpl)getFromObjectTable(in.readInt());
    }
    GenericSpecificationImpl result = new GenericSpecificationImpl();
    int tableIndex = in.readInt();
    addToObjectTable(result, tableIndex);
    readVersionConstraint(result, in);
    result.setType(readString(in, false));
    int num = in.readInt();
    GenericDescription[] suppliers = num == 0 ? null : new GenericDescription[num];
    for (int i = 0; i < num; i++) {
      suppliers[i] = readGenericDescription(in);
    }
    result.setSupplers(suppliers);
    result.setResolution(in.readInt());
    try
    {
      result.setMatchingFilter(readString(in, false), false);
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    result.setAttributes(readMap(in));
    result.setArbitraryDirectives(readMap(in));
    return result;
  }
  
  private NativeCodeSpecification readNativeCode(DataInputStream in)
    throws IOException
  {
    if (!in.readBoolean()) {
      return null;
    }
    NativeCodeSpecificationImpl result = new NativeCodeSpecificationImpl();
    result.setOptional(in.readBoolean());
    int numNativeDesc = in.readInt();
    NativeCodeDescriptionImpl[] nativeDescs = new NativeCodeDescriptionImpl[numNativeDesc];
    for (int i = 0; i < numNativeDesc; i++) {
      nativeDescs[i] = readNativeCodeDescription(in);
    }
    result.setPossibleSuppliers(nativeDescs);
    int supplierIndex = in.readInt();
    if (supplierIndex >= 0) {
      result.setSupplier(nativeDescs[supplierIndex]);
    }
    return result;
  }
  
  private NativeCodeDescriptionImpl readNativeCodeDescription(DataInputStream in)
    throws IOException
  {
    NativeCodeDescriptionImpl result = new NativeCodeDescriptionImpl();
    readBaseDescription(result, in);
    result.setSupplier(readBundleDescription(in));
    try
    {
      result.setFilter(readString(in, false));
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    result.setLanguages(readStringArray(in));
    result.setNativePaths(readStringArray(in));
    result.setOSNames(readStringArray(in));
    result.setOSVersions(readVersionRanges(in));
    result.setProcessors(readStringArray(in));
    result.setInvalidNativePaths(in.readBoolean());
    return result;
  }
  
  private VersionRange[] readVersionRanges(DataInputStream in)
    throws IOException
  {
    int num = in.readInt();
    if (num == 0) {
      return null;
    }
    VersionRange[] result = new VersionRange[num];
    for (int i = 0; i < num; i++) {
      result[i] = readVersionRange(in);
    }
    return result;
  }
  
  private String[] readStringArray(DataInputStream in)
    throws IOException
  {
    int num = in.readInt();
    if (num == 0) {
      return null;
    }
    String[] result = new String[num];
    for (int i = 0; i < num; i++) {
      result[i] = readString(in, false);
    }
    return result;
  }
  
  private void readVersionConstraint(VersionConstraintImpl version, DataInputStream in)
    throws IOException
  {
    version.setName(readString(in, false));
    version.setVersionRange(readVersionRange(in));
  }
  
  private Version readVersion(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return Version.emptyVersion;
    }
    int majorComponent = in.readInt();
    int minorComponent = in.readInt();
    int serviceComponent = in.readInt();
    String qualifierComponent = readString(in, false);
    Version result = (Version)ObjectPool.intern(new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent));
    
    return result;
  }
  
  private VersionRange readVersionRange(DataInputStream in)
    throws IOException
  {
    byte tag = readTag(in);
    if (tag == 0) {
      return null;
    }
    return new VersionRange(readVersion(in), in.readBoolean(), readVersion(in), in.readBoolean());
  }
  
  public synchronized boolean loadStateDeprecated(StateImpl state, DataInputStream input, long expectedTimestamp)
    throws IOException
  {
    try
    {
      return readStateDeprecated(state, input, expectedTimestamp);
    }
    finally
    {
      input.close();
    }
  }
  
  public synchronized boolean loadState(StateImpl state, long expectedTimestamp)
    throws IOException
  {
    return readState(state, expectedTimestamp);
  }
  
  private String readString(DataInputStream in, boolean intern)
    throws IOException
  {
    byte type = in.readByte();
    if (type == 0) {
      return null;
    }
    if (type == 3)
    {
      int length = in.readInt();
      byte[] data = new byte[length];
      in.readFully(data);
      String string = new String(data, "UTF-8");
      if (intern) {
        return string.intern();
      }
      return (String)ObjectPool.intern(string);
    }
    if (intern) {
      return in.readUTF().intern();
    }
    return (String)ObjectPool.intern(in.readUTF());
  }
  
  private byte readTag(DataInputStream in)
    throws IOException
  {
    return in.readByte();
  }
  
  private DataInputStream openLazyFile()
    throws IOException
  {
    if (lazyFile == null) {
      throw new IOException();
    }
    return new DataInputStream(new BufferedInputStream(secureAction.getFileInputStream(lazyFile), 4096));
  }
  
  boolean isLazyLoaded()
  {
    return lazyLoad;
  }
  
  boolean getAccessedFlag()
  {
    return accessedFlag;
  }
  
  void setAccessedFlag(boolean accessedFlag)
  {
    this.accessedFlag = accessedFlag;
  }
  
  /* Error */
  void fullyLoad()
  {
    // Byte code:
    //   0: aload_0
    //   1: iconst_1
    //   2: invokevirtual 888	org/eclipse/osgi/internal/resolver/StateReader:setAccessedFlag	(Z)V
    //   5: aconst_null
    //   6: astore_1
    //   7: aload_0
    //   8: invokespecial 889	org/eclipse/osgi/internal/resolver/StateReader:openLazyFile	()Ljava/io/DataInputStream;
    //   11: astore_1
    //   12: iconst_0
    //   13: istore_2
    //   14: goto +13 -> 27
    //   17: aload_0
    //   18: aload_1
    //   19: iconst_0
    //   20: invokespecial 906	org/eclipse/osgi/internal/resolver/StateReader:readBundleDescriptionLazyData	(Ljava/io/DataInputStream;I)Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl;
    //   23: pop
    //   24: iinc 2 1
    //   27: iload_2
    //   28: aload_0
    //   29: getfield 736	org/eclipse/osgi/internal/resolver/StateReader:numBundles	I
    //   32: if_icmplt -15 -> 17
    //   35: goto +32 -> 67
    //   38: astore_2
    //   39: new 380	java/lang/RuntimeException
    //   42: dup
    //   43: aload_2
    //   44: invokevirtual 760	java/io/IOException:getMessage	()Ljava/lang/String;
    //   47: aload_2
    //   48: invokespecial 771	java/lang/RuntimeException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   51: athrow
    //   52: astore_3
    //   53: aload_1
    //   54: ifnull +11 -> 65
    //   57: aload_1
    //   58: invokevirtual 750	java/io/DataInputStream:close	()V
    //   61: goto +4 -> 65
    //   64: pop
    //   65: aload_3
    //   66: athrow
    //   67: aload_1
    //   68: ifnull +11 -> 79
    //   71: aload_1
    //   72: invokevirtual 750	java/io/DataInputStream:close	()V
    //   75: goto +4 -> 79
    //   78: pop
    //   79: return
    // Line number table:
    //   Java source line #794	-> byte code offset #0
    //   Java source line #795	-> byte code offset #5
    //   Java source line #797	-> byte code offset #7
    //   Java source line #798	-> byte code offset #12
    //   Java source line #799	-> byte code offset #17
    //   Java source line #798	-> byte code offset #24
    //   Java source line #800	-> byte code offset #35
    //   Java source line #801	-> byte code offset #39
    //   Java source line #802	-> byte code offset #52
    //   Java source line #803	-> byte code offset #53
    //   Java source line #805	-> byte code offset #57
    //   Java source line #806	-> byte code offset #61
    //   Java source line #809	-> byte code offset #65
    //   Java source line #803	-> byte code offset #67
    //   Java source line #805	-> byte code offset #71
    //   Java source line #806	-> byte code offset #75
    //   Java source line #810	-> byte code offset #79
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	80	0	this	StateReader
    //   6	66	1	in	DataInputStream
    //   13	15	2	i	int
    //   38	10	2	ioe	IOException
    //   52	14	3	localObject	Object
    //   64	1	5	localIOException1	IOException
    //   78	1	6	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   7	35	38	java/io/IOException
    //   7	52	52	finally
    //   57	61	64	java/io/IOException
    //   71	75	78	java/io/IOException
  }
  
  /* Error */
  void fullyLoad(BundleDescriptionImpl target)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: iconst_1
    //   2: invokevirtual 888	org/eclipse/osgi/internal/resolver/StateReader:setAccessedFlag	(Z)V
    //   5: aconst_null
    //   6: astore_2
    //   7: aload_0
    //   8: invokespecial 889	org/eclipse/osgi/internal/resolver/StateReader:openLazyFile	()Ljava/io/DataInputStream;
    //   11: astore_2
    //   12: new 386	java/util/ArrayList
    //   15: dup
    //   16: invokespecial 780	java/util/ArrayList:<init>	()V
    //   19: astore_3
    //   20: aload_0
    //   21: aload_1
    //   22: aload_3
    //   23: invokespecial 903	org/eclipse/osgi/internal/resolver/StateReader:addDependencies	(Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl;Ljava/util/List;)V
    //   26: aload_0
    //   27: aload_3
    //   28: invokespecial 893	org/eclipse/osgi/internal/resolver/StateReader:getSkipBytes	(Ljava/util/List;)[I
    //   31: astore 4
    //   33: iconst_0
    //   34: istore 5
    //   36: goto +17 -> 53
    //   39: aload_0
    //   40: aload_2
    //   41: aload 4
    //   43: iload 5
    //   45: iaload
    //   46: invokespecial 906	org/eclipse/osgi/internal/resolver/StateReader:readBundleDescriptionLazyData	(Ljava/io/DataInputStream;I)Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl;
    //   49: pop
    //   50: iinc 5 1
    //   53: iload 5
    //   55: aload 4
    //   57: arraylength
    //   58: if_icmplt -19 -> 39
    //   61: goto +16 -> 77
    //   64: astore 6
    //   66: aload_2
    //   67: ifnull +7 -> 74
    //   70: aload_2
    //   71: invokevirtual 750	java/io/DataInputStream:close	()V
    //   74: aload 6
    //   76: athrow
    //   77: aload_2
    //   78: ifnull +7 -> 85
    //   81: aload_2
    //   82: invokevirtual 750	java/io/DataInputStream:close	()V
    //   85: return
    // Line number table:
    //   Java source line #813	-> byte code offset #0
    //   Java source line #814	-> byte code offset #5
    //   Java source line #816	-> byte code offset #7
    //   Java source line #818	-> byte code offset #12
    //   Java source line #819	-> byte code offset #20
    //   Java source line #820	-> byte code offset #26
    //   Java source line #822	-> byte code offset #33
    //   Java source line #823	-> byte code offset #39
    //   Java source line #822	-> byte code offset #50
    //   Java source line #824	-> byte code offset #61
    //   Java source line #825	-> byte code offset #66
    //   Java source line #826	-> byte code offset #70
    //   Java source line #827	-> byte code offset #74
    //   Java source line #825	-> byte code offset #77
    //   Java source line #826	-> byte code offset #81
    //   Java source line #828	-> byte code offset #85
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	86	0	this	StateReader
    //   0	86	1	target	BundleDescriptionImpl
    //   6	76	2	in	DataInputStream
    //   19	9	3	toLoad	List<BundleDescriptionImpl>
    //   31	25	4	skipBytes	int[]
    //   34	20	5	i	int
    //   64	11	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	64	64	finally
  }
  
  private void addDependencies(BundleDescriptionImpl target, List<BundleDescriptionImpl> toLoad)
  {
    if ((toLoad.contains(target)) || (target.isFullyLoaded())) {
      return;
    }
    Iterator<BundleDescriptionImpl> load = toLoad.iterator();
    int i = 0;
    while (load.hasNext())
    {
      BundleDescriptionImpl bundle = (BundleDescriptionImpl)load.next();
      if (target.getLazyDataOffset() < bundle.getLazyDataOffset()) {
        break;
      }
      i++;
    }
    if (i >= toLoad.size()) {
      toLoad.add(target);
    } else {
      toLoad.add(i, target);
    }
    List<BundleDescription> deps = target.getBundleDependencies();
    for (Iterator<BundleDescription> iter = deps.iterator(); iter.hasNext();) {
      addDependencies((BundleDescriptionImpl)iter.next(), toLoad);
    }
  }
  
  private int[] getSkipBytes(List<BundleDescriptionImpl> toLoad)
  {
    int[] skipBytes = new int[toLoad.size()];
    for (int i = 0; i < skipBytes.length; i++)
    {
      BundleDescriptionImpl current = (BundleDescriptionImpl)toLoad.get(i);
      if (i == 0)
      {
        skipBytes[i] = current.getLazyDataOffset();
      }
      else
      {
        BundleDescriptionImpl previous = (BundleDescriptionImpl)toLoad.get(i - 1);
        skipBytes[i] = (current.getLazyDataOffset() - previous.getLazyDataOffset() - previous.getLazyDataSize());
      }
    }
    return skipBytes;
  }
  
  void flushLazyObjectCache()
  {
    for (Iterator<Map.Entry<Integer, Object>> entries = objectTable.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry<Integer, Object> entry = (Map.Entry)entries.next();
      Object value = entry.getValue();
      if (((value instanceof ExportPackageDescription)) || ((value instanceof GenericDescription)) || ((value instanceof ImportPackageSpecification)) || ((value instanceof BundleSpecification)) || ((value instanceof GenericSpecification))) {
        entries.remove();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.StateReader
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.DisabledInfo;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.GenericDescription;
import org.eclipse.osgi.service.resolver.GenericSpecification;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.NativeCodeDescription;
import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
import org.eclipse.osgi.service.resolver.StateHelper;
import org.eclipse.osgi.service.resolver.StateWire;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.osgi.framework.Filter;
import org.osgi.framework.Version;

class StateWriter
{
  private final Map<Object, Integer> objectTable = new HashMap();
  private final List<Object> forcedWrite = new ArrayList();
  
  private int addToObjectTable(Object object)
  {
    Integer cur = (Integer)objectTable.get(object);
    if (cur != null) {
      return cur.intValue();
    }
    objectTable.put(object, new Integer(objectTable.size()));
    
    return objectTable.size() - 1;
  }
  
  private int getFromObjectTable(Object object)
  {
    if (objectTable != null)
    {
      Object objectResult = objectTable.get(object);
      if (objectResult != null) {
        return ((Integer)objectResult).intValue();
      }
    }
    return -1;
  }
  
  private boolean writePrefix(Object object, DataOutputStream out)
    throws IOException
  {
    if (writeIndex(object, out)) {
      return true;
    }
    int index = addToObjectTable(object);
    out.writeByte(1);
    out.writeInt(index);
    return false;
  }
  
  private void writeStateDeprecated(StateImpl state, DataOutputStream out)
    throws IOException
  {
    out.write(38);
    if (writePrefix(state, out)) {
      return;
    }
    out.writeLong(state.getTimeStamp());
    
    String[] platformPropKeys = state.getPlatformPropertyKeys();
    writePlatformProp(platformPropKeys, out);
    Dictionary[] propSet = state.getPlatformProperties();
    out.writeInt(propSet.length);
    for (int i = 0; i < propSet.length; i++)
    {
      Dictionary<Object, Object> props = propSet[i];
      out.writeInt(platformPropKeys.length);
      for (int j = 0; j < platformPropKeys.length; j++) {
        writePlatformProp(props.get(platformPropKeys[j]), out);
      }
    }
    BundleDescription[] bundles = state.getBundles();
    StateHelperImpl.getInstance().sortBundles(bundles);
    out.writeInt(bundles.length);
    if (bundles.length == 0) {
      return;
    }
    for (int i = 0; i < bundles.length; i++) {
      writeBundleDescription(bundles[i], out, false);
    }
    out.writeBoolean(state.isResolved());
    
    out.writeInt(out.size());
    for (int i = 0; i < bundles.length; i++) {
      writeBundleDescriptionLazyData(bundles[i], out);
    }
  }
  
  public void saveState(StateImpl state, File stateFile, File lazyFile)
    throws IOException
  {
    DataOutputStream outLazy = null;
    DataOutputStream outState = null;
    FileOutputStream fosLazy = null;
    FileOutputStream fosState = null;
    synchronized (monitor)
    {
      try
      {
        BundleDescription[] bundles = state.getBundles();
        StateHelperImpl.getInstance().sortBundles(bundles);
        for (int i = 0; i < bundles.length; i++)
        {
          addToObjectTable(bundles[i]);
          if (bundles[i].getHost() != null) {
            addToObjectTable(bundles[i].getHost());
          }
        }
        fosLazy = new FileOutputStream(lazyFile);
        outLazy = new DataOutputStream(new BufferedOutputStream(fosLazy));
        for (int i = 0; i < bundles.length; i++) {
          writeBundleDescriptionLazyData(bundles[i], outLazy);
        }
        fosState = new FileOutputStream(stateFile);
        outState = new DataOutputStream(new BufferedOutputStream(fosState));
        outState.write(38);
        if (writePrefix(state, outState))
        {
          if (outLazy != null)
          {
            try
            {
              outLazy.flush();
              fosLazy.getFD().sync();
            }
            catch (IOException localIOException1) {}
            try
            {
              outLazy.close();
            }
            catch (IOException localIOException2) {}
          }
          if (outState != null)
          {
            try
            {
              outState.flush();
              fosState.getFD().sync();
            }
            catch (IOException localIOException3) {}
            try
            {
              outState.close();
            }
            catch (IOException localIOException4) {}
          }
          return;
        }
        BundleDescription[] bundles;
        outState.writeLong(state.getTimeStamp());
        
        String[] platformPropKeys = state.getPlatformPropertyKeys();
        writePlatformProp(platformPropKeys, outState);
        
        Dictionary[] propSet = state.getPlatformProperties();
        outState.writeInt(propSet.length);
        for (int i = 0; i < propSet.length; i++)
        {
          Dictionary<Object, Object> props = propSet[i];
          outState.writeInt(platformPropKeys.length);
          for (int j = 0; j < platformPropKeys.length; j++) {
            writePlatformProp(props.get(platformPropKeys[j]), outState);
          }
        }
        outState.writeInt(bundles.length);
        for (int i = 0; i < bundles.length; i++) {
          writeBundleDescription(bundles[i], outState, true);
        }
        DisabledInfo[] infos = state.getDisabledInfos();
        outState.writeInt(infos.length);
        for (int i = 0; i < infos.length; i++) {
          writeDisabledInfo(infos[i], outState);
        }
        outState.writeBoolean(state.isResolved());
      }
      finally
      {
        if (outLazy != null)
        {
          try
          {
            outLazy.flush();
            fosLazy.getFD().sync();
          }
          catch (IOException localIOException5) {}
          try
          {
            outLazy.close();
          }
          catch (IOException localIOException6) {}
        }
        if (outState != null)
        {
          try
          {
            outState.flush();
            fosState.getFD().sync();
          }
          catch (IOException localIOException7) {}
          try
          {
            outState.close();
          }
          catch (IOException localIOException8) {}
        }
      }
      if (outLazy != null)
      {
        try
        {
          outLazy.flush();
          fosLazy.getFD().sync();
        }
        catch (IOException localIOException9) {}
        try
        {
          outLazy.close();
        }
        catch (IOException localIOException10) {}
      }
      if (outState != null)
      {
        try
        {
          outState.flush();
          fosState.getFD().sync();
        }
        catch (IOException localIOException11) {}
        try
        {
          outState.close();
        }
        catch (IOException localIOException12) {}
      }
    }
  }
  
  private void writePlatformProp(Object obj, DataOutputStream out)
    throws IOException
  {
    if ((!(obj instanceof String)) && (!(obj instanceof String[])))
    {
      out.writeByte(0);
    }
    else
    {
      out.writeByte(1);
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

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