org.eclipse.osgi_3.7.2.v20120110-1415

loader.BundleLoaderProxy;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.NativeCodeDescription;
import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
import org.eclipse.osgi.service.resolver.ResolverError;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.storagemanager.StorageManager;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.SynchronousBundleListener;

public class BaseStorage
  implements SynchronousBundleListener
{
  private static final String RUNTIME_ADAPTOR = "org.eclipse.osgi/eclipseadaptor";
  private static final String OPTION_PLATFORM_ADMIN = "org.eclipse.osgi/eclipseadaptor/debug/platformadmin";
  private static final String OPTION_PLATFORM_ADMIN_RESOLVER = "org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver";
  private static final String OPTION_MONITOR_PLATFORM_ADMIN = "org.eclipse.osgi/eclipseadaptor/resolver/timing";
  private static final String OPTION_RESOLVER_READER = "org.eclipse.osgi/eclipseadaptor/resolver/reader/timing";
  private static final String PROP_FRAMEWORK_EXTENSIONS = "osgi.framework.extensions";
  private static final String PROP_BUNDLE_STORE = "osgi.bundlestore";
  static final String DATA_DIR_NAME = "data";
  static final String LIB_TEMP = "libtemp";
  private static final String PROP_ENABLE_STATE_SAVER = "eclipse.enableStateSaver";
  static final String BUNDLEFILE_NAME = "bundlefile";
  private static final String PROP_CLEAN = "osgi.clean";
  public static final byte BUNDLEDATA_VERSION = 18;
  public static final byte EXTENSION_INITIALIZE = 1;
  public static final byte EXTENSION_INSTALLED = 2;
  public static final byte EXTENSION_UNINSTALLED = 4;
  public static final byte EXTENSION_UPDATED = 8;
  public static final int TYPE_DIRECTORYBUNDLE = 268435456;
  public static final int TYPE_FILEBUNDLE = 536870912;
  public static final String DELETE_FLAG = ".delete";
  private static final String PERM_DATA_FILE = ".permdata";
  private static final byte PERMDATA_VERSION = 1;
  private MRUBundleFileList mruList = new MRUBundleFileList();
  BaseAdaptor adaptor;
  private String installPath;
  private StorageManager storageManager;
  private StateManager stateManager;
  private KeyedHashSet storageHooks = new KeyedHashSet(5, false);
  private BundleContext context;
  private SynchronousBundleListener extensionListener;
  private final Method addFwkURLMethod;
  private final Method addExtURLMethod;
  private String[] configuredExtensions;
  private long timeStamp = 0L;
  private int initialBundleStartLevel = 1;
  private final Object nextIdMonitor = new Object();
  private volatile long nextId = 1L;
  private File bundleStoreRoot;
  private BasePermissionStorage permissionStorage;
  private StateSaver stateSaver;
  private boolean invalidState;
  private boolean storageManagerClosed;
  
  BaseStorage()
  {
    addFwkURLMethod = findAddURLMethod(getFwkClassLoader(), "addURL");
    addExtURLMethod = findAddURLMethod(getExtClassLoader(), "addURL");
  }
  
  public void initialize(BaseAdaptor initAdaptor)
    throws IOException
  {
    adaptor = initAdaptor;
    setDebugOptions();
    if (Boolean.valueOf(FrameworkProperties.getProperty("osgi.clean")).booleanValue()) {
      cleanOSGiCache();
    }
    Location installLoc = LocationManager.getInstallLocation();
    if (installLoc != null)
    {
      URL installURL = installLoc.getURL();
      
      installPath = installURL.getPath();
    }
    boolean readOnlyConfiguration = LocationManager.getConfigurationLocation().isReadOnly();
    storageManager = initFileManager(LocationManager.getOSGiConfigurationDir(), readOnlyConfiguration ? "none" : null, readOnlyConfiguration);
    storageManagerClosed = false;
    
    StorageHook[] hooks = initAdaptor.getHookRegistry().getStorageHooks();
    for (int i = 0; i < hooks.length; i++) {
      storageHooks.add(hooks[i]);
    }
  }
  
  private static Method findAddURLMethod(ClassLoader cl, String name)
  {
    if (cl == null) {
      return null;
    }
    return findMethod(cl.getClass(), name, new Class[] { URL.class });
  }
  
  private static Method findMethod(Class<?> clazz, String name, Class<?>[] args)
  {
    if (clazz == null) {
      return null;
    }
    try
    {
      Method result = clazz.getDeclaredMethod(name, args);
      result.setAccessible(true);
      return result;
    }
    catch (NoSuchMethodException localNoSuchMethodException) {}catch (SecurityException localSecurityException) {}
    return findMethod(clazz.getSuperclass(), name, args);
  }
  
  private static void callAddURLMethod(ClassLoader cl, Method meth, URL arg)
    throws InvocationTargetException
  {
    try
    {
      meth.invoke(cl, new Object[] { arg });
    }
    catch (Throwable t)
    {
      throw new InvocationTargetException(t);
    }
  }
  
  private ClassLoader getFwkClassLoader()
  {
    return getClass().getClassLoader();
  }
  
  private ClassLoader getExtClassLoader()
  {
    ClassLoader cl = ClassLoader.getSystemClassLoader();
    ClassLoader extcl = cl.getParent();
    while ((extcl != null) && (extcl.getParent() != null)) {
      extcl = extcl.getParent();
    }
    return extcl;
  }
  
  private static void setDebugOptions()
  {
    FrameworkDebugOptions options = FrameworkDebugOptions.getDefault();
    if (options == null) {
      return;
    }
    StateManager.DEBUG = options != null;
    StateManager.DEBUG_READER = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/resolver/reader/timing", false);
    StateManager.MONITOR_PLATFORM_ADMIN = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/resolver/timing", false);
    StateManager.DEBUG_PLATFORM_ADMIN = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/debug/platformadmin", false);
    StateManager.DEBUG_PLATFORM_ADMIN_RESOLVER = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver", false);
  }
  
  protected StorageManager initFileManager(File baseDir, String lockMode, boolean readOnly)
    throws IOException
  {
    StorageManager sManager = new StorageManager(baseDir, lockMode, readOnly);
    try
    {
      sManager.open(!readOnly);
    }
    catch (IOException ex)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Error reading framework metadata: " + ex.getMessage());
        Debug.printStackTrace(ex);
      }
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR, ex.getMessage());
      FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, ex, null);
      adaptor.getFrameworkLog().log(logEntry);
      FrameworkProperties.setProperty("eclipse.exitcode", "15");
      String errorDialog = "<title>" + AdaptorMsg.ADAPTOR_STORAGE_INIT_FAILED_TITLE + "</title>" + NLS.bind(AdaptorMsg.ADAPTOR_STORAGE_INIT_FAILED_MSG, baseDir) + "\n" + ex.getMessage();
      FrameworkProperties.setProperty("eclipse.exitdata", errorDialog);
      throw ex;
    }
    return sManager;
  }
  
  public boolean isReadOnly()
  {
    return storageManager.isReadOnly();
  }
  
  public void compact()
  {
    if (!isReadOnly()) {
      compact(getBundleStoreRoot());
    }
  }
  
  private void compact(File directory)
  {
    if (Debug.DEBUG_GENERAL) {
      Debug.println("compact(" + directory.getPath() + ")");
    }
    String[] list = directory.list();
    if (list == null) {
      return;
    }
    int len = list.length;
    for (int i = 0; i < len; i++) {
      if (!"data".equals(list[i]))
      {
        File target = new File(directory, list[i]);
        if (target.isDirectory())
        {
          File delete = new File(target, ".delete");
          if (delete.exists())
          {
            if ((!AdaptorUtil.rm(target)) && (!delete.exists()))
            {
              try
              {
                FileOutputStream out = new FileOutputStream(delete);
                out.close();
              }
              catch (IOException e)
              {
                if (!Debug.DEBUG_GENERAL) {
                  continue;
                }
              }
              Debug.println("Unable to write " + delete.getPath() + ": " + e.getMessage());
            }
          }
          else {
            compact(target);
          }
        }
      }
    }
  }
  
  public long getFreeSpace()
    throws IOException
  {
    return -1L;
  }
  
  public File getDataFile(BaseData data, String path)
  {
    BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
    if (storageHook == null) {
      return null;
    }
    return storageHook.getDataFile(path);
  }
  
  BaseAdaptor getAdaptor()
  {
    return adaptor;
  }
  
  public void installNativeCode(BaseData data, String[] nativepaths)
    throws BundleException
  {
    if (nativepaths.length > 0)
    {
      BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
      if (storageHook != null) {
        storageHook.installNativePaths(nativepaths);
      }
    }
  }
  
  public Dictionary<String, String> loadManifest(BaseData data)
    throws BundleException
  {
    return loadManifest(data, false);
  }
  
  public Dictionary<String, String> loadManifest(BaseData bundleData, boolean firstTime)
    throws BundleException
  {
    Dictionary<String, String> result = null;
    StorageHook[] dataStorageHooks = bundleData.getStorageHooks();
    for (int i = 0; (i < dataStorageHooks.length) && (result == null); i++) {
      result = dataStorageHooks[i].getManifest(firstTime);
    }
    if (result == null) {
      result = AdaptorUtil.loadManifestFrom(bundleData);
    }
    if (result == null) {
      throw new BundleException(NLS.bind(AdaptorMsg.MANIFEST_NOT_FOUND_EXCEPTION, "META-INF/MANIFEST.MF", bundleData.getLocation()), 3);
    }
    return result;
  }
  
  public File getExtractFile(BaseData data, String path)
  {
    BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
    if (storageHook == null) {
      return null;
    }
    File childGenDir = storageHook.getGenerationDir();
    if (childGenDir != null)
    {
      File childPath = new File(childGenDir, path);
      if (childPath.exists()) {
        return childPath;
      }
    }
    File parentGenDir = storageHook.getParentGenerationDir();
    if (parentGenDir != null)
    {
      File parentPath = new File(parentGenDir, path);
      if (parentPath.exists()) {
        return parentPath;
      }
    }
    File bundleGenerationDir = storageHook.createGenerationDir();
    if ((bundleGenerationDir != null) && (bundleGenerationDir.exists())) {
      return new File(bundleGenerationDir, path);
    }
    return null;
  }
  
  public BaseData[] getInstalledBundles()
  {
    try
    {
      return readBundleDatas();
    }
    catch (Throwable t)
    {
      FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, "Error loading bundle datas.  Recalculating cache.", 0, t, null);
      adaptor.getFrameworkLog().log(logEntry);
    }
    return null;
  }
  
  private BaseData[] readBundleDatas()
  {
    InputStream bundleDataStream = findStorageStream(".bundledata");
    if (bundleDataStream == null) {
      return null;
    }
    try
    {
      DataInputStream in = new DataInputStream(new BufferedInputStream(bundleDataStream));
      try
      {
        byte version = in.readByte();
        if (version != 18) {
          return null;
        }
        timeStamp = in.readLong();
        initialBundleStartLevel = in.readInt();
        nextId = in.readLong();
        
        int numStorageHooks = in.readInt();
        StorageHook[] hooks = adaptor.getHookRegistry().getStorageHooks();
        if (numStorageHooks != hooks.length) {
          return null;
        }
        for (int i = 0; i < numStorageHooks; i++)
        {
          Object storageKey = hooks[i].getKey();
          int storageVersion = hooks[i].getStorageVersion();
          if ((!storageKey.equals(in.readUTF())) || (storageVersion != in.readInt())) {
            return null;
          }
        }
        int bundleCount = in.readInt();
        List<BaseData> result = new ArrayList(bundleCount);
        long id = -1L;
        boolean bundleDiscarded = false;
        for (int i = 0; i < bundleCount; i++)
        {
          boolean error = false;
          BaseData data = null;
          try
          {
            id = in.readLong();
            if (id != 0L)
            {
              data = loadBaseData(id, in);
              data.getBundleFile();
              StorageHook[] dataStorageHooks = data.getStorageHooks();
              for (int j = 0; j < dataStorageHooks.length; j++) {
                dataStorageHooks[j].validate();
              }
              if (Debug.DEBUG_GENERAL) {
                Debug.println("BundleData created: " + data);
              }
              processExtension(data, (byte)1);
              result.add(data);
            }
          }
          catch (IllegalArgumentException localIllegalArgumentException)
          {
            bundleDiscarded = true;
            error = true;
          }
          catch (BundleException localBundleException)
          {
            bundleDiscarded = true;
            error = true;
          }
          catch (IOException e)
          {
            bundleDiscarded = true;
            error = true;
            if (Debug.DEBUG_GENERAL)
            {
              Debug.println("Error reading framework metadata: " + e.getMessage());
              Debug.printStackTrace(e);
            }
          }
          if ((error) && (data != null))
          {
            BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
            storageHook.delete(true, 1);
          }
        }
        if (bundleDiscarded) {
          FrameworkProperties.setProperty("eclipse.refreshBundles", "true");
        }
        return (BaseData[])result.toArray(new BaseData[result.size()]);
      }
      finally
      {
        in.close();
      }
      return null;
    }
    catch (IOException e)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Error reading framework metadata: " + e.getMessage());
        Debug.printStackTrace(e);
      }
    }
  }
  
  void saveAllData(boolean shutdown)
  {
    if (Debug.DEBUG_GENERAL) {
      Debug.println("Saving framework data ...");
    }
    if (storageManagerClosed) {
      try
      {
        storageManager.open(!LocationManager.getConfigurationLocation().isReadOnly());
        storageManagerClosed = false;
      }
      catch (IOException e)
      {
        String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR, e.getMessage());
        FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null);
        adaptor.getFrameworkLog().log(logEntry);
      }
    }
    saveBundleDatas();
    saveStateData(shutdown);
    savePermissionStorage();
    if (shutdown) {
      stateManager.stopDataManager();
    }
  }
  
  private BasePermissionStorage readPermissionData()
  {
    BasePermissionStorage result = new BasePermissionStorage(this);
    InputStream permDataStream = findStorageStream(".permdata");
    if (permDataStream == null) {
      return result;
    }
    try
    {
      DataInputStream in = new DataInputStream(new BufferedInputStream(permDataStream));
      try
      {
        if (1 != in.readByte()) {
          return result;
        }
        int numPerms = in.readInt();
        if (numPerms > 0)
        {
          String[] perms = new String[numPerms];
          for (int i = 0; i < numPerms; i++) {
            perms[i] = in.readUTF();
          }
          result.setPermissionData(null, perms);
        }
        int numLocs = in.readInt();
        if (numLocs > 0) {
          for (int i = 0; i < numLocs; i++)
          {
            String loc = in.readUTF();
            numPerms = in.readInt();
            String[] perms = new String[numPerms];
            for (int j = 0; j < numPerms; j++) {
              perms[j] = in.readUTF();
            }
            result.setPermissionData(loc, perms);
          }
        }
        int numCondPerms = in.readInt();
        if (numCondPerms > 0)
        {
          String[] condPerms = new String[numCondPerms];
          for (int i = 0; i < numCondPerms; i++) {
            condPerms[i] = in.readUTF();
          }
          result.saveConditionalPermissionInfos(condPerms);
        }
        result.setDirty(false);
      }
      finally
      {
        in.close();
      }
      in.close();
    }
    catch (IOException e)
    {
      adaptor.getFrameworkLog().log(new FrameworkEvent(2, context.getBundle(), e));
    }
    return result;
  }
  
  /* Error */
  private void savePermissionStorage()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   4: ifnull +20 -> 24
    //   7: aload_0
    //   8: invokevirtual 1364	org/eclipse/osgi/internal/baseadaptor/BaseStorage:isReadOnly	()Z
    //   11: ifne +13 -> 24
    //   14: aload_0
    //   15: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   18: invokevirtual 1349	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:isDirty	()Z
    //   21: ifne +4 -> 25
    //   24: return
    //   25: getstatic 1184	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   28: ifeq +9 -> 37
    //   31: ldc_w 601
    //   34: invokestatic 1331	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   37: aload_0
    //   38: getfield 1210	org/eclipse/osgi/internal/baseadaptor/BaseStorage:storageManager	Lorg/eclipse/osgi/storagemanager/StorageManager;
    //   41: ldc 4
    //   43: invokevirtual 1434	org/eclipse/osgi/storagemanager/StorageManager:getOutputStream	(Ljava/lang/String;)Lorg/eclipse/osgi/storagemanager/ManagedOutputStream;
    //   46: astore_1
    //   47: new 637	java/io/DataOutputStream
    //   50: dup
    //   51: new 635	java/io/BufferedOutputStream
    //   54: dup
    //   55: aload_1
    //   56: invokespecial 1220	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   59: invokespecial 1231	java/io/DataOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   62: astore_2
    //   63: iconst_1
    //   64: istore_3
    //   65: aload_2
    //   66: iconst_1
    //   67: invokevirtual 1228	java/io/DataOutputStream:writeByte	(I)V
    //   70: aload_0
    //   71: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   74: aconst_null
    //   75: invokevirtual 1355	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getPermissionData	(Ljava/lang/String;)[Ljava/lang/String;
    //   78: astore 4
    //   80: aload_2
    //   81: aload 4
    //   83: ifnonnull +7 -> 90
    //   86: iconst_0
    //   87: goto +6 -> 93
    //   90: aload 4
    //   92: arraylength
    //   93: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   96: aload 4
    //   98: ifnull +29 -> 127
    //   101: iconst_0
    //   102: istore 5
    //   104: goto +15 -> 119
    //   107: aload_2
    //   108: aload 4
    //   110: iload 5
    //   112: aaload
    //   113: invokevirtual 1232	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   116: iinc 5 1
    //   119: iload 5
    //   121: aload 4
    //   123: arraylength
    //   124: if_icmplt -17 -> 107
    //   127: aload_0
    //   128: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   131: invokevirtual 1352	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getLocations	()[Ljava/lang/String;
    //   134: astore 5
    //   136: aload_2
    //   137: aload 5
    //   139: ifnonnull +7 -> 146
    //   142: iconst_0
    //   143: goto +6 -> 149
    //   146: aload 5
    //   148: arraylength
    //   149: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   152: aload 5
    //   154: ifnull +90 -> 244
    //   157: iconst_0
    //   158: istore 6
    //   160: goto +76 -> 236
    //   163: aload_2
    //   164: aload 5
    //   166: iload 6
    //   168: aaload
    //   169: invokevirtual 1232	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   172: aload_0
    //   173: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   176: aload 5
    //   178: iload 6
    //   180: aaload
    //   181: invokevirtual 1355	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getPermissionData	(Ljava/lang/String;)[Ljava/lang/String;
    //   184: astore 7
    //   186: aload_2
    //   187: aload 7
    //   189: ifnonnull +7 -> 196
    //   192: iconst_0
    //   193: goto +6 -> 199
    //   196: aload 7
    //   198: arraylength
    //   199: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   202: aload 7
    //   204: ifnull +29 -> 233
    //   207: iconst_0
    //   208: istore 8
    //   210: goto +15 -> 225
    //   213: aload_2
    //   214: aload 7
    //   216: iload 8
    //   218: aaload
    //   219: invokevirtual 1232	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   222: iinc 8 1
    //   225: iload 8
    //   227: aload 7
    //   229: arraylength
    //   230: if_icmplt -17 -> 213
    //   233: iinc 6 1
    //   236: iload 6
    //   238: aload 5
    //   240: arraylength
    //   241: if_icmplt -78 -> 163
    //   244: aload_0
    //   245: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   248: invokevirtual 1351	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getConditionalPermissionInfos	()[Ljava/lang/String;
    //   251: astore 6
    //   253: aload_2
    //   254: aload 6
    //   256: ifnonnull +7 -> 263
    //   259: iconst_0
    //   260: goto +6 -> 266
    //   263: aload 6
    //   265: arraylength
    //   266: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   269: aload 6
    //   271: ifnull +29 -> 300
    //   274: iconst_0
    //   275: istore 7
    //   277: goto +15 -> 292
    //   280: aload_2
    //   281: aload 6
    //   283: iload 7
    //   285: aaload
    //   286: invokevirtual 1232	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   289: iinc 7 1
    //   292: iload 7
    //   294: aload 6
    //   296: arraylength
    //   297: if_icmplt -17 -> 280
    //   300: aload_2
    //   301: invokevirtual 1227	java/io/DataOutputStream:close	()V
    //   304: aload_0
    //   305: getfield 1207	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   308: iconst_0
    //   309: invokevirtual 1350	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:setDirty	(Z)V
    //   312: iconst_0
    //   313: istore_3
    //   314: goto +24 -> 338
    //   317: astore 9
    //   319: iload_3
    //   320: ifeq +15 -> 335
    //   323: aload_1
    //   324: invokevirtual 1426	org/eclipse/osgi/storagemanager/ManagedOutputStream:abort	()V
    //   327: aload_2
    //   328: invokevirtual 1227	java/io/DataOutputStream:close	()V
    //   331: goto +4 -> 335
    //   334: pop
    //   335: aload 9
    //   337: athrow
    //   338: iload_3
    //   339: ifeq +50 -> 389
    //   342: aload_1
    //   343: invokevirtual 1426	org/eclipse/osgi/storagemanager/ManagedOutputStream:abort	()V
    //   346: aload_2
    //   347: invokevirtual 1227	java/io/DataOutputStream:close	()V
    //   350: goto +39 -> 389
    //   353: pop
    //   354: goto +35 -> 389
    //   357: astore_1
    //   358: aload_0
    //   359: getfield 1204	org/eclipse/osgi/internal/baseadaptor/BaseStorage:adaptor	Lorg/eclipse/osgi/baseadaptor/BaseAdaptor;
    //   362: invokevirtual 1299	org/eclipse/osgi/baseadaptor/BaseAdaptor:getFrameworkLog	()Lorg/eclipse/osgi/framework/log/FrameworkLog;
    //   365: new 718	org/osgi/framework/FrameworkEvent
    //   368: dup
    //   369: iconst_2
    //   370: aload_0
    //   371: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:context	Lorg/osgi/framework/BundleContext;
    //   374: invokeinterface 1486 1 0
    //   379: aload_1
    //   380: invokespecial 1442	org/osgi/framework/FrameworkEvent:<init>	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;)V
    //   383: invokeinterface 1459 2 0
    //   388: return
    //   389: return
    // Line number table:
    //   Java source line #510	-> byte code offset #0
    //   Java source line #511	-> byte code offset #24
    //   Java source line #512	-> byte code offset #25
    //   Java source line #513	-> byte code offset #31
    //   Java source line #515	-> byte code offset #37
    //   Java source line #516	-> byte code offset #47
    //   Java source line #517	-> byte code offset #63
    //   Java source line #519	-> byte code offset #65
    //   Java source line #521	-> byte code offset #70
    //   Java source line #522	-> byte code offset #80
    //   Java source line #523	-> byte code offset #96
    //   Java source line #524	-> byte code offset #101
    //   Java source line #525	-> byte code offset #107
    //   Java source line #524	-> byte code offset #116
    //   Java source line #526	-> byte code offset #127
    //   Java source line #527	-> byte code offset #136
    //   Java source line #528	-> byte code offset #152
    //   Java source line #529	-> byte code offset #157
    //   Java source line #530	-> byte code offset #163
    //   Java source line #531	-> byte code offset #172
    //   Java source line #532	-> byte code offset #186
    //   Java source line #533	-> byte code offset #202
    //   Java source line #534	-> byte code offset #207
    //   Java source line #535	-> byte code offset #213
    //   Java source line #534	-> byte code offset #222
    //   Java source line #529	-> byte code offset #233
    //   Java source line #537	-> byte code offset #244
    //   Java source line #538	-> byte code offset #253
    //   Java source line #539	-> byte code offset #269
    //   Java source line #540	-> byte code offset #274
    //   Java source line #541	-> byte code offset #280
    //   Java source line #540	-> byte code offset #289
    //   Java source line #542	-> byte code offset #300
    //   Java source line #543	-> byte code offset #304
    //   Java source line #544	-> byte code offset #312
    //   Java source line #545	-> byte code offset #317
    //   Java source line #547	-> byte code offset #319
    //   Java source line #548	-> byte code offset #323
    //   Java source line #550	-> byte code offset #327
    //   Java source line #551	-> byte code offset #334
    //   Java source line #554	-> byte code offset #335
    //   Java source line #547	-> byte code offset #338
    //   Java source line #548	-> byte code offset #342
    //   Java source line #550	-> byte code offset #346
    //   Java source line #551	-> byte code offset #353
    //   Java source line #555	-> byte code offset #357
    //   Java source line #556	-> byte code offset #358
    //   Java source line #557	-> byte code offset #388
    //   Java source line #559	-> byte code offset #389
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	390	0	this	BaseStorage
    //   46	297	1	fmos	org.eclipse.osgi.storagemanager.ManagedOutputStream
    //   357	23	1	e	IOException
    //   62	285	2	out	DataOutputStream
    //   64	275	3	error	boolean
    //   78	44	4	defaultPerms	String[]
    //   102	18	5	i	int
    //   134	105	5	locations	String[]
    //   158	79	6	i	int
    //   251	44	6	condPerms	String[]
    //   184	44	7	perms	String[]
    //   275	18	7	i	int
    //   208	18	8	j	int
    //   317	19	9	localObject	Object
    //   334	1	14	localIOException1	IOException
    //   353	1	15	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   65	317	317	finally
    //   327	331	334	java/io/IOException
    //   346	350	353	java/io/IOException
    //   37	354	357	java/io/IOException
  }
  
  /* Error */
  private void saveBundleDatas()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 1209	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   4: ifnull +40 -> 44
    //   7: aload_0
    //   8: invokevirtual 1364	org/eclipse/osgi/internal/baseadaptor/BaseStorage:isReadOnly	()Z
    //   11: ifne +33 -> 44
    //   14: aload_0
    //   15: getfield 1194	org/eclipse/osgi/internal/baseadaptor/BaseStorage:timeStamp	J
    //   18: aload_0
    //   19: getfield 1209	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   22: invokevirtual 1418	org/eclipse/osgi/internal/baseadaptor/StateManager:getSystemState	()Lorg/eclipse/osgi/service/resolver/State;
    //   25: invokeinterface 1470 1 0
    //   30: lcmp
    //   31: ifne +14 -> 45
    //   34: aload_0
    //   35: getfield 1209	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   38: invokevirtual 1416	org/eclipse/osgi/internal/baseadaptor/StateManager:saveNeeded	()Z
    //   41: ifne +4 -> 45
    //   44: return
    //   45: getstatic 1184	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   48: ifeq +9 -> 57
    //   51: ldc_w 614
    //   54: invokestatic 1331	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   57: aload_0
    //   58: getfield 1210	org/eclipse/osgi/internal/baseadaptor/BaseStorage:storageManager	Lorg/eclipse/osgi/storagemanager/StorageManager;
    //   61: ldc_w 593
    //   64: invokevirtual 1434	org/eclipse/osgi/storagemanager/StorageManager:getOutputStream	(Ljava/lang/String;)Lorg/eclipse/osgi/storagemanager/ManagedOutputStream;
    //   67: astore_1
    //   68: new 637	java/io/DataOutputStream
    //   71: dup
    //   72: new 635	java/io/BufferedOutputStream
    //   75: dup
    //   76: aload_1
    //   77: invokespecial 1220	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   80: invokespecial 1231	java/io/DataOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   83: astore_2
    //   84: iconst_1
    //   85: istore_3
    //   86: aload_2
    //   87: bipush 18
    //   89: invokevirtual 1228	java/io/DataOutputStream:writeByte	(I)V
    //   92: aload_2
    //   93: aload_0
    //   94: getfield 1209	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   97: invokevirtual 1418	org/eclipse/osgi/internal/baseadaptor/StateManager:getSystemState	()Lorg/eclipse/osgi/service/resolver/State;
    //   100: invokeinterface 1470 1 0
    //   105: invokevirtual 1230	java/io/DataOutputStream:writeLong	(J)V
    //   108: aload_2
    //   109: aload_0
    //   110: getfield 1192	org/eclipse/osgi/internal/baseadaptor/BaseStorage:initialBundleStartLevel	I
    //   113: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   116: aload_2
    //   117: aload_0
    //   118: getfield 1193	org/eclipse/osgi/internal/baseadaptor/BaseStorage:nextId	J
    //   121: invokevirtual 1230	java/io/DataOutputStream:writeLong	(J)V
    //   124: aload_0
    //   125: getfield 1204	org/eclipse/osgi/internal/baseadaptor/BaseStorage:adaptor	Lorg/eclipse/osgi/baseadaptor/BaseAdaptor;
    //   128: invokevirtual 1297	org/eclipse/osgi/baseadaptor/BaseAdaptor:getHookRegistry	()Lorg/eclipse/osgi/baseadaptor/HookRegistry;
    //   131: invokevirtual 1321	org/eclipse/osgi/baseadaptor/HookRegistry:getStorageHooks	()[Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;
    //   134: astore 4
    //   136: aload_2
    //   137: aload 4
    //   139: arraylength
    //   140: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   143: iconst_0
    //   144: istore 5
    //   146: goto +37 -> 183
    //   149: aload_2
    //   150: aload 4
    //   152: iload 5
    //   154: aaload
    //   155: invokeinterface 1451 1 0
    //   160: checkcast 654	java/lang/String
    //   163: invokevirtual 1232	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   166: aload_2
    //   167: aload 4
    //   169: iload 5
    //   171: aaload
    //   172: invokeinterface 1448 1 0
    //   177: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   180: iinc 5 1
    //   183: iload 5
    //   185: aload 4
    //   187: arraylength
    //   188: if_icmplt -39 -> 149
    //   191: aload_0
    //   192: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:context	Lorg/osgi/framework/BundleContext;
    //   195: invokeinterface 1487 1 0
    //   200: astore 5
    //   202: aload_2
    //   203: aload 5
    //   205: arraylength
    //   206: invokevirtual 1229	java/io/DataOutputStream:writeInt	(I)V
    //   209: iconst_0
    //   210: istore 6
    //   212: goto +54 -> 266
    //   215: aload 5
    //   217: iload 6
    //   219: aaload
    //   220: invokeinterface 1485 1 0
    //   225: lstore 7
    //   227: aload_2
    //   228: lload 7
    //   230: invokevirtual 1230	java/io/DataOutputStream:writeLong	(J)V
    //   233: lload 7
    //   235: lconst_0
    //   236: lcmp
    //   237: ifeq +26 -> 263
    //   240: aload 5
    //   242: iload 6
    //   244: aaload
    //   245: checkcast 685	org/eclipse/osgi/framework/internal/core/AbstractBundle
    //   248: invokevirtual 1337	org/eclipse/osgi/framework/internal/core/AbstractBundle:getBundleData	()Lorg/eclipse/osgi/framework/adaptor/BundleData;
    //   251: astore 9
    //   253: aload_0
    //   254: aload 9
    //   256: checkcast 670	org/eclipse/osgi/baseadaptor/BaseData
    //   259: aload_2
    //   260: invokevirtual 1382	org/eclipse/osgi/internal/baseadaptor/BaseStorage:saveBaseData	(Lorg/eclipse/osgi/baseadaptor/BaseData;Ljava/io/DataOutputStream;)V
    //   263: iinc 6 1
    //   266: iload 6
    //   268: aload 5
    //   270: arraylength
    //   271: if_icmplt -56 -> 215
    //   274: aload_2
    //   275: invokevirtual 1227	java/io/DataOutputStream:close	()V
    //   278: aload_0
    //   279: aload_0
    //   280: getfield 1209	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   283: invokevirtual 1418	org/eclipse/osgi/internal/baseadaptor/StateManager:getSystemState	()Lorg/eclipse/osgi/service/resolver/State;
    //   286: invokeinterface 1470 1 0
    //   291: putfield 1194	org/eclipse/osgi/internal/baseadaptor/BaseStorage:timeStamp	J
    //   294: iconst_0
    //   295: istore_3
    //   296: goto +24 -> 320
    //   299: astore 10
    //   301: iload_3
    //   302: ifeq +15 -> 317
    //   305: aload_1
    //   306: invokevirtual 1426	org/eclipse/osgi/storagemanager/ManagedOutputStream:abort	()V
    //   309: aload_2
    //   310: invokevirtual 1227	java/io/DataOutputStream:close	()V
    //   313: goto +4 -> 317
    //   316: pop
    //   317: aload 10
    //   319: athrow
    //   320: iload_3
    //   321: ifeq +50 -> 371
    //   324: aload_1
    //   325: invokevirtual 1426	org/eclipse/osgi/storagemanager/ManagedOutputStream:abort	()V
    //   328: aload_2
    //   329: invokevirtual 1227	java/io/DataOutputStream:close	()V
    //   332: goto +39 -> 371
    //   335: pop
    //   336: goto +35 -> 371
    //   339: astore_1
    //   340: aload_0
    //   341: getfield 1204	org/eclipse/osgi/internal/baseadaptor/BaseStorage:adaptor	Lorg/eclipse/osgi/baseadaptor/BaseAdaptor;
    //   344: invokevirtual 1299	org/eclipse/osgi/baseadaptor/BaseAdaptor:getFrameworkLog	()Lorg/eclipse/osgi/framework/log/FrameworkLog;
    //   347: new 718	org/osgi/framework/FrameworkEvent
    //   350: dup
    //   351: iconst_2
    //   352: aload_0
    //   353: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:context	Lorg/osgi/framework/BundleContext;
    //   356: invokeinterface 1486 1 0
    //   361: aload_1
    //   362: invokespecial 1442	org/osgi/framework/FrameworkEvent:<init>	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;)V
    //   365: invokeinterface 1459 2 0
    //   370: return
    //   371: return
    // Line number table:
    //   Java source line #563	-> byte code offset #0
    //   Java source line #564	-> byte code offset #44
    //   Java source line #565	-> byte code offset #45
    //   Java source line #566	-> byte code offset #51
    //   Java source line #568	-> byte code offset #57
    //   Java source line #569	-> byte code offset #68
    //   Java source line #570	-> byte code offset #84
    //   Java source line #572	-> byte code offset #86
    //   Java source line #573	-> byte code offset #92
    //   Java source line #574	-> byte code offset #108
    //   Java source line #575	-> byte code offset #116
    //   Java source line #577	-> byte code offset #124
    //   Java source line #578	-> byte code offset #136
    //   Java source line #579	-> byte code offset #143
    //   Java source line #580	-> byte code offset #149
    //   Java source line #581	-> byte code offset #166
    //   Java source line #579	-> byte code offset #180
    //   Java source line #584	-> byte code offset #191
    //   Java source line #585	-> byte code offset #202
    //   Java source line #586	-> byte code offset #209
    //   Java source line #587	-> byte code offset #215
    //   Java source line #588	-> byte code offset #227
    //   Java source line #589	-> byte code offset #233
    //   Java source line #590	-> byte code offset #240
    //   Java source line #591	-> byte code offset #253
    //   Java source line #586	-> byte code offset #263
    //   Java source line #594	-> byte code offset #274
    //   Java source line #596	-> byte code offset #278
    //   Java source line #597	-> byte code offset #294
    //   Java source line #598	-> byte code offset #299
    //   Java source line #600	-> byte code offset #301
    //   Java source line #601	-> byte code offset #305
    //   Java source line #603	-> byte code offset #309
    //   Java source line #604	-> byte code offset #316
    //   Java source line #607	-> byte code offset #317
    //   Java source line #600	-> byte code offset #320
    //   Java source line #601	-> byte code offset #324
    //   Java source line #603	-> byte code offset #328
    //   Java source line #604	-> byte code offset #335
    //   Java source line #608	-> byte code offset #339
    //   Java source line #609	-> byte code offset #340
    //   Java source line #610	-> byte code offset #370
    //   Java source line #612	-> byte code offset #371
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	372	0	this	BaseStorage
    //   67	258	1	fmos	org.eclipse.osgi.storagemanager.ManagedOutputStream
    //   339	23	1	e	IOException
    //   83	246	2	out	DataOutputStream
    //   85	236	3	error	boolean
    //   134	52	4	hooks	StorageHook[]
    //   144	40	5	i	int
    //   200	69	5	bundles	Bundle[]
    //   210	57	6	i	int
    //   225	9	7	id	long
    //   251	4	9	data	BundleData
    //   299	19	10	localObject	Object
    //   316	1	12	localIOException1	IOException
    //   335	1	13	localIOException2	IOException
 
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

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