org.eclipse.osgi_3.7.2.v20120110-1415

    //   Java source line #124	-> byte code offset #17
    //   Java source line #125	-> byte code offset #18
    //   Java source line #126	-> byte code offset #24
    //   Java source line #128	-> byte code offset #31
    //   Java source line #129	-> byte code offset #52
    //   Java source line #131	-> byte code offset #80
    //   Java source line #132	-> byte code offset #94
    //   Java source line #148	-> byte code offset #99
    //   Java source line #149	-> byte code offset #105
    //   Java source line #133	-> byte code offset #134
    //   Java source line #135	-> byte code offset #135
    //   Java source line #137	-> byte code offset #140
    //   Java source line #138	-> byte code offset #163
    //   Java source line #140	-> byte code offset #164
    //   Java source line #142	-> byte code offset #169
    //   Java source line #143	-> byte code offset #182
    //   Java source line #144	-> byte code offset #189
    //   Java source line #146	-> byte code offset #190
    //   Java source line #148	-> byte code offset #194
    //   Java source line #149	-> byte code offset #200
    //   Java source line #147	-> byte code offset #232
    //   Java source line #148	-> byte code offset #233
    //   Java source line #149	-> byte code offset #239
    //   Java source line #150	-> byte code offset #268
    //   Java source line #148	-> byte code offset #270
    //   Java source line #149	-> byte code offset #276
    //   Java source line #151	-> byte code offset #305
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	306	0	this	StateManager
    //   51	19	1	lazyLoad	boolean
    //   135	35	1	lazyLoad	boolean
    //   189	2	1	ioe	IOException
    //   232	37	2	localObject	Object
    //   163	1	5	localNumberFormatException	NumberFormatException
    // Exception table:
    //   from	to	target	type
    //   140	160	163	java/lang/NumberFormatException
    //   31	99	189	java/io/IOException
    //   135	186	189	java/io/IOException
    //   31	99	232	finally
    //   135	194	232	finally
  }
  
  private synchronized void startDataManager()
  {
    if (dataManagerThread != null) {
      return;
    }
    dataManagerThread = new Thread(this, "State Data Manager");
    dataManagerThread.setDaemon(true);
    dataManagerThread.start();
  }
  
  public synchronized void stopDataManager()
  {
    if (dataManagerThread == null) {
      return;
    }
    dataManagerThread.interrupt();
    dataManagerThread = null;
  }
  
  private void writeState(StateImpl state, File saveStateFile, File saveLazyFile)
    throws IOException
  {
    if (state == null) {
      return;
    }
    if ((cachedState) && (!saveNeeded())) {
      return;
    }
    state.fullyLoad();
    factory.writeState(state, saveStateFile, saveLazyFile);
  }
  
  private boolean initializeSystemState()
  {
    systemState.setResolver(createResolver(System.getSecurityManager() != null));
    lastTimeStamp = systemState.getTimeStamp();
    return !systemState.setPlatformProperties(FrameworkProperties.getProperties());
  }
  
  public synchronized State createSystemState()
  {
    if (systemState == null)
    {
      systemState = factory.createSystemState(context);
      initializeSystemState();
    }
    return systemState;
  }
  
  public synchronized State readSystemState()
  {
    if (systemState == null) {
      internalReadSystemState();
    }
    return systemState;
  }
  
  public State getSystemState()
  {
    return systemState;
  }
  
  public long getCachedTimeStamp()
  {
    return lastTimeStamp;
  }
  
  public boolean saveNeeded()
  {
    return (systemState.getTimeStamp() != lastTimeStamp) || (systemState.dynamicCacheChanged());
  }
  
  public State getState(boolean mutable)
  {
    return mutable ? factory.createState(systemState) : new ReadOnlyState(systemState);
  }
  
  public State getState()
  {
    return getState(true);
  }
  
  public StateObjectFactory getFactory()
  {
    return factory;
  }
  
  public synchronized void commit(State state)
    throws BundleException
  {
    throw new IllegalArgumentException("PlatformAdmin.commit() not supported");
  }
  
  /**
   * @deprecated
   */
  public Resolver getResolver()
  {
    return createResolver(false);
  }
  
  public Resolver createResolver()
  {
    return createResolver(false);
  }
  
  private Resolver createResolver(boolean checkPermissions)
  {
    return new ResolverImpl(checkPermissions);
  }
  
  public StateHelper getStateHelper()
  {
    return StateHelperImpl.getInstance();
  }
  
  public void run()
  {
    long timeStamp = lastTimeStamp;
    for (;;)
    {
      try
      {
        Thread.sleep(expireTime);
      }
      catch (InterruptedException localInterruptedException)
      {
        return;
      }
      if (systemState == null) {
        continue;
      }
      synchronized (systemState)
      {
        if (!systemState.unloadLazyData(timeStamp)) {
          return;
        }
      }
    }
  }
  
  public void addDisabledInfo(DisabledInfo disabledInfo)
  {
    if (systemState == null) {
      throw new IllegalStateException();
    }
    systemState.addDisabledInfo(disabledInfo);
  }
  
  public void removeDisabledInfo(DisabledInfo disabledInfo)
  {
    if (systemState == null) {
      throw new IllegalStateException();
    }
    systemState.removeDisabledInfo(disabledInfo);
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;

class SystemBundleData$1$1
  extends BundleEntry
{
  final SystemBundleData.1 this$1;
  
  SystemBundleData$1$1(SystemBundleData.1 param1) {}
  
  public InputStream getInputStream()
    throws IOException
  {
    return SystemBundleData.access$0(SystemBundleData.1.access$0(this$1)).openStream();
  }
  
  public long getSize()
  {
    return 0L;
  }
  
  public String getName()
  {
    return "META-INF/MANIFEST.MF";
  }
  
  public long getTime()
  {
    return 0L;
  }
  
  public URL getLocalURL()
  {
    return SystemBundleData.access$0(SystemBundleData.1.access$0(this$1));
  }
  
  public URL getFileURL()
  {
    return null;
  }
}

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

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.util.Enumeration;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;

class SystemBundleData$1
  extends BundleFile
{
  final SystemBundleData this$0;
  
  SystemBundleData$1(SystemBundleData paramSystemBundleData, File $anonymous0)
  {
    super($anonymous0);
  }
  
  public File getFile(String path, boolean nativeCode)
  {
    return null;
  }
  
  public BundleEntry getEntry(String path)
  {
    if ("META-INF/MANIFEST.MF".equals(path))
    {
      System.err.println("Getting system bundle manifest: " + path);
      new BundleEntry()
      {
        public InputStream getInputStream()
          throws IOException
        {
          return SystemBundleData.access$0(this$0).openStream();
        }
        
        public long getSize()
        {
          return 0L;
        }
        
        public String getName()
        {
          return "META-INF/MANIFEST.MF";
        }
        
        public long getTime()
        {
          return 0L;
        }
        
        public URL getLocalURL()
        {
          return SystemBundleData.access$0(this$0);
        }
        
        public URL getFileURL()
        {
          return null;
        }
      };
    }
    return null;
  }
  
  public Enumeration<String> getEntryPaths(String path)
  {
    return null;
  }
  
  public void close() {}
  
  public void open() {}
  
  public boolean containsDir(String dir)
  {
    return false;
  }
}

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

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.Enumeration;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.hooks.StorageHook;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.util.Headers;
import org.osgi.framework.BundleException;

public class SystemBundleData
  extends BaseData
{
  private static final String OSGI_FRAMEWORK = "osgi.framework";
  
  public SystemBundleData(BaseAdaptor adaptor)
    throws BundleException
  {
    super(0L, adaptor);
    File osgiBase = getOsgiBase();
    createBundleFile(osgiBase);
    manifest = createManifest(osgiBase);
    setMetaData();
    setLastModified(System.currentTimeMillis());
    StorageHook[] hooks = adaptor.getHookRegistry().getStorageHooks();
    StorageHook[] instanceHooks = new StorageHook[hooks.length];
    for (int i = 0; i < hooks.length; i++) {
      instanceHooks[i] = hooks[i].create(this);
    }
    setStorageHooks(instanceHooks);
  }
  
  private File getOsgiBase()
  {
    String frameworkLocation = FrameworkProperties.getProperty("osgi.framework");
    if ((frameworkLocation != null) && (frameworkLocation.startsWith("file:"))) {
      return new File(frameworkLocation.substring(5));
    }
    try
    {
      URL url = getClass().getProtectionDomain().getCodeSource().getLocation();
      if ("file".equals(url.getProtocol())) {
        return new File(url.getPath());
      }
    }
    catch (Throwable localThrowable) {}
    return null;
  }
  
  private Headers<String, String> createManifest(File osgiBase)
    throws BundleException
  {
    InputStream in = null;
    if ((osgiBase != null) && (osgiBase.exists())) {
      try
      {
        BundleEntry entry = getBundleFile().getEntry("META-INF/MANIFEST.MF");
        if (entry != null) {
          in = entry.getInputStream();
        }
      }
      catch (IOException localIOException) {}
    }
    if (in == null) {
      in = getManifestAsResource();
    }
    if ((Debug.DEBUG_GENERAL) && 
      (in == null)) {
      Debug.println("Unable to find system bundle manifest META-INF/MANIFEST.MF");
    }
    if (in == null) {
      throw new BundleException(AdaptorMsg.SYSTEMBUNDLE_MISSING_MANIFEST, 3);
    }
    return Headers.parseManifest(in);
  }
  
  private InputStream getManifestAsResource()
  {
    URL url = getManifestURL();
    try
    {
      return url == null ? null : url.openStream();
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  private URL getManifestURL()
  {
    ClassLoader cl = getClass().getClassLoader();
    try
    {
      Enumeration<URL> manifests = cl != null ? cl.getResources("META-INF/MANIFEST.MF") : ClassLoader.getSystemResources("META-INF/MANIFEST.MF");
      while (manifests.hasMoreElements())
      {
        URL url = (URL)manifests.nextElement();
        try
        {
          Headers<String, String> headers = Headers.parseManifest(url.openStream());
          if ("true".equals(headers.get("Eclipse-SystemBundle"))) {
            return url;
          }
        }
        catch (BundleException localBundleException) {}
      }
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  private void createBundleFile(File osgiBase)
  {
    if (osgiBase != null) {
      try
      {
        bundleFile = getAdaptor().createBundleFile(osgiBase, this);
      }
      catch (IOException localIOException) {}
    } else {
      bundleFile = new BundleFile(osgiBase)
      {
        public File getFile(String path, boolean nativeCode)
        {
          return null;
        }
        
        public BundleEntry getEntry(String path)
        {
          if ("META-INF/MANIFEST.MF".equals(path))
          {
            System.err.println("Getting system bundle manifest: " + path);
            new BundleEntry()
            {
              public InputStream getInputStream()
                throws IOException
              {
                return SystemBundleData.this.getManifestURL().openStream();
              }
              
              public long getSize()
              {
                return 0L;
              }
              
              public String getName()
              {
                return "META-INF/MANIFEST.MF";
              }
              
              public long getTime()
              {
                return 0L;
              }
              
              public URL getLocalURL()
              {
                return SystemBundleData.this.getManifestURL();
              }
              
              public URL getFileURL()
              {
                return null;
              }
            };
          }
          return null;
        }
        
        public Enumeration<String> getEntryPaths(String path)
        {
          return null;
        }
        
        public void close() {}
        
        public void open() {}
        
        public boolean containsDir(String dir)
        {
          return false;
        }
      };
    }
  }
  
  private void setMetaData()
    throws BundleException
  {
    setLocation("System Bundle");
    BaseStorageHook.loadManifest(this, manifest);
  }
  
  public BundleClassLoader createClassLoader(ClassLoaderDelegate delegate, BundleProtectionDomain domain, String[] bundleclasspath)
  {
    return null;
  }
  
  public File createGenerationDir()
  {
    return null;
  }
  
  public String findLibrary(String libname)
  {
    return null;
  }
  
  public void installNativeCode(String[] nativepaths)
    throws BundleException
  {}
  
  public int getStartLevel()
  {
    return 0;
  }
  
  public int getStatus()
  {
    return 1;
  }
  
  public void save() {}
}

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

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import java.util.RandomAccess;
import org.eclipse.osgi.internal.resolver.StateBuilder;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.util.ManifestElement;

public class DynamicImportList
  extends AbstractList<String>
  implements RandomAccess
{
  private final List<String> imports = new ArrayList(0);
  private final WovenClassImpl wovenClass;
  
  public DynamicImportList(WovenClassImpl wovenClass)
  {
    this.wovenClass = wovenClass;
  }
  
  public String get(int index)
  {
    return (String)imports.get(index);
  }
  
  public int size()
  {
    return imports.size();
  }
  
  public String set(int index, String element)
  {
    wovenClass.checkPermission();
    validateSyntax(element);
    return (String)imports.set(index, element);
  }
  
  public void add(int index, String element)
  {
    wovenClass.checkPermission();
    validateSyntax(element);
    imports.add(index, element);
  }
  
  public String remove(int index)
  {
    wovenClass.checkPermission();
    return (String)imports.remove(index);
  }
  
  private void validateSyntax(String imported)
  {
    try
    {
      ManifestElement[] importElements = ManifestElement.parseHeader("Import-Package", imported);
      
      StateBuilder.checkImportExportSyntax("Import-Package", importElements, false, false, false);
      
      List<ImportPackageSpecification> dynamicImportSpecs = new ArrayList(importElements.length);
      ManifestElement[] arrayOfManifestElement1;
      int j = (arrayOfManifestElement1 = importElements).length;
      for (int i = 0; i < j; i++)
      {
        ManifestElement dynamicImportElement = arrayOfManifestElement1[i];
        StateBuilder.addImportPackages(dynamicImportElement, dynamicImportSpecs, 2, true);
      }
    }
    catch (Throwable t)
    {
      IllegalArgumentException exception = new IllegalArgumentException();
      exception.initCause(t);
      throw exception;
    }
    ManifestElement[] importElements;
  }
}

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

import java.net.URL;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.HookConfigurator;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingStatsHook;
import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.eclipse.osgi.framework.adaptor.EventPublisher;
import org.eclipse.osgi.framework.internal.core.Framework;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

public class WeavingHookConfigurator
  implements HookConfigurator, ClassLoadingHook, ClassLoadingStatsHook
{
  private BaseAdaptor adaptor;
  private final Map<ServiceRegistration<?>, Boolean> blackList = Collections.synchronizedMap(new WeakHashMap());
  private final ThreadLocal<List<WovenClassImpl>> wovenClassStack = new ThreadLocal();
  
  public void addHooks(HookRegistry hookRegistry)
  {
    adaptor = hookRegistry.getAdaptor();
    hookRegistry.addClassLoadingHook(this);
    hookRegistry.addClassLoadingStatsHook(this);
  }
  
  private ServiceRegistry getRegistry()
  {
    return ((Framework)adaptor.getEventPublisher()).getServiceRegistry();
  }
  
  public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
  {
    ServiceRegistry registry = getRegistry();
    if (registry == null) {
      return null;
    }
    ClassLoaderDelegate delegate = manager.getBaseClassLoader().getDelegate();
    BundleLoader loader;
    if ((delegate instanceof BundleLoader))
    {
      loader = (BundleLoader)delegate;
    }
    else
    {
      Throwable e = new IllegalStateException("Could not obtain loader");
      adaptor.getEventPublisher().publishFrameworkEvent(2, manager.getBaseData().getBundle(), e);
      return null;
    }
    BundleLoader loader;
    WovenClassImpl wovenClass = new WovenClassImpl(name, classbytes, entry, classpathEntry.getDomain(), loader, registry, blackList);
    List<WovenClassImpl> wovenClasses = (List)wovenClassStack.get();
    if (wovenClasses == null)
    {
      wovenClasses = new ArrayList(6);
      wovenClassStack.set(wovenClasses);
    }
    wovenClasses.add(wovenClass);
    try
    {
      return wovenClass.callHooks();
    }
    catch (Throwable t)
    {
      ServiceRegistration<?> errorHook = wovenClass.getErrorHook();
      Bundle errorBundle = errorHook != null ? errorHook.getReference().getBundle() : manager.getBaseData().getBundle();
      adaptor.getEventPublisher().publishFrameworkEvent(2, errorBundle, t);
      
      ClassFormatError error = new ClassFormatError("Unexpected error from weaving hook.");
      error.initCause(t);
      throw error;
    }
  }
  
  public boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain)
  {
    return false;
  }
  
  public String findLibrary(BaseData data, String libName)
  {
    return null;
  }
  
  public ClassLoader getBundleClassLoaderParent()
  {
    return null;
  }
  
  public BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath)
  {
    return null;
  }
  
  public void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data) {}
  
  public void preFindLocalClass(String name, ClasspathManager manager) {}
  
  public void postFindLocalClass(String name, Class<?> clazz, ClasspathManager manager) {}
  
  public void preFindLocalResource(String name, ClasspathManager manager) {}
  
  public void postFindLocalResource(String name, URL resource, ClasspathManager manager) {}
  
  public void recordClassDefine(String name, Class<?> clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
  {
    List<WovenClassImpl> wovenClasses = (List)wovenClassStack.get();
    if ((wovenClasses == null) || (wovenClasses.size() == 0)) {
      return;
    }
    WovenClassImpl wovenClass = (WovenClassImpl)wovenClasses.remove(wovenClasses.size() - 1);
    
    wovenClass.setWeavingCompleted(clazz);
  }
}

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

import java.security.PrivilegedExceptionAction;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;

class WovenClassImpl$1
  implements PrivilegedExceptionAction<Object>
{
  final WovenClassImpl this$0;
  
  WovenClassImpl$1(WovenClassImpl paramWovenClassImpl) {}
  
  public Object run()
  {
    this$0.registry.notifyHooksPrivileged(this$0);
    return null;
  }
}

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

import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.internal.baseadaptor.AdaptorUtil;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.loader.BundleLoaderProxy;
import org.eclipse.osgi.internal.serviceregistry.HookContext;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.hooks.weaving.WeavingException;
import org.osgi.framework.hooks.weaving.WeavingHook;
import org.osgi.framework.hooks.weaving.WovenClass;
import org.osgi.framework.wiring.BundleWiring;

public final class WovenClassImpl
  implements WovenClass, HookContext
{
  private static final byte FLAG_HOOKCALLED = 1;
  private static final byte FLAG_HOOKSCOMPLETE = 2;
  private static final byte FLAG_WEAVINGCOMPLETE = 4;
  private static final String weavingHookName = WeavingHook.class.getName();
  private final String className;
  private final BundleEntry entry;
  private final List<String> dynamicImports;
  private final ProtectionDomain domain;
  private final BundleLoader loader;
  final ServiceRegistry registry;
  private final Map<ServiceRegistration<?>, Boolean> blackList;
  private byte[] validBytes;
  private byte[] resultBytes;
  private byte hookFlags = 0;
  private Throwable error;
  private ServiceRegistration<?> errorHook;
  private Class<?> clazz;
  
  public WovenClassImpl(String className, byte[] bytes, BundleEntry entry, ProtectionDomain domain, BundleLoader loader, ServiceRegistry registry, Map<ServiceRegistration<?>, Boolean> blacklist)
  {
    this.className = className;
    validBytes = (resultBytes = bytes);
    this.entry = entry;
    dynamicImports = new DynamicImportList(this);
    this.domain = domain;
    this.loader = loader;
    this.registry = registry;
    blackList = blacklist;
  }
  
  public byte[] getBytes()
  {
    if ((hookFlags & 0x2) == 0)
    {
      checkPermission();
      return validBytes;
    }
    byte[] current = validBytes;
    byte[] results = new byte[current.length];
    System.arraycopy(current, 0, results, 0, current.length);
    return results;
  }
  
  public void setBytes(byte[] newBytes)
  {
    checkPermission();
    if (newBytes == null) {
      throw new NullPointerException("newBytes cannot be null.");
    }
    if ((hookFlags & 0x2) != 0) {
      throw new IllegalStateException("Weaving has completed already.");
    }
    resultBytes = (validBytes = newBytes);
  }
  
  void checkPermission()
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(new AdminPermission(loader.getBundle(), "weave"));
    }
  }
  
  public List<String> getDynamicImports()
  {
    if ((hookFlags & 0x2) == 0) {
      return dynamicImports;
    }
    return Collections.unmodifiableList(dynamicImports);
  }
  
  public boolean isWeavingComplete()
  {
    return (hookFlags & 0x4) != 0;
  }
  
  private void setHooksComplete()
  {
    byte[] original = validBytes;
    validBytes = new byte[original.length];
    System.arraycopy(original, 0, validBytes, 0, original.length);
    hookFlags = ((byte)(hookFlags | 0x2));
  }
  
  void setWeavingCompleted(Class<?> clazz)
  {
    this.clazz = clazz;
    hookFlags = ((byte)(hookFlags | 0x4));
  }
  
  public String getClassName()
  {
    return className;
  }
  
  public ProtectionDomain getProtectionDomain()
  {
    return domain;
  }
  
  public Class<?> getDefinedClass()
  {
    return clazz;
  }
  
  public BundleWiring getBundleWiring()
  {
    return loader.getLoaderProxy().getBundleDescription().getWiring();
  }
  
  public void call(Object hook, ServiceRegistration<?> hookRegistration)
    throws Exception
  {
    if (error != null) {
      return;
    }
    if ((hook instanceof WeavingHook))
    {
      if (blackList.containsKey(hookRegistration)) {
        return;
      }
      if ((hookFlags & 0x1) == 0)
      {
        hookFlags = ((byte)(hookFlags | 0x1));
        if (!validBytes(validBytes)) {
          validBytes = AdaptorUtil.getBytes(entry.getInputStream(), (int)entry.getSize(), 8192);
        }
      }
      try
      {
        ((WeavingHook)hook).weave(this);
      }
      catch (WeavingException e)
      {
        error = e;
        errorHook = hookRegistration;
      }
      catch (Throwable t)
      {
        error = t;
        errorHook = hookRegistration;
        
        blackList.put(hookRegistration, Boolean.TRUE);
      }
    }
  }
  
  private boolean validBytes(byte[] checkBytes)
  {
    if ((checkBytes == null) || (checkBytes.length < 4)) {
      return false;
    }
    if ((checkBytes[0] & 0xCA) != 202) {
      return false;
    }
    if ((checkBytes[1] & 0xFE) != 254) {
      return false;
    }
    if ((checkBytes[2] & 0xBA) != 186) {
      return false;
    }
    if ((checkBytes[3] & 0xBE) != 190) {
      return false;
    }
    return true;
  }
  
  public String getHookMethodName()
  {
    return "weave";
  }
  
  public String getHookClassName()
  {
    return weavingHookName;
  }
  
  byte[] callHooks()
    throws Throwable
  {
    SecurityManager sm = System.getSecurityManager();
    byte[] wovenBytes = (byte[])null;
    List<String> newImports = null;
    try
    {
      if (sm == null) {
        registry.notifyHooksPrivileged(this);
      } else {
        try
        {
          AccessController.doPrivileged(new PrivilegedExceptionAction()
          {
            public Object run()
            {
              registry.notifyHooksPrivileged(WovenClassImpl.this);
              return null;
            }
          });
        }
        catch (PrivilegedActionException e)
        {
          throw ((RuntimeException)e.getException());
        }
      }
    }
    finally
    {
      if ((hookFlags & 0x1) != 0)
      {
        wovenBytes = resultBytes;
        newImports = dynamicImports;
        setHooksComplete();
      }
    }
    if ((hookFlags & 0x1) != 0)
    {
      wovenBytes = resultBytes;
      newImports = dynamicImports;
      setHooksComplete();
    }
    if (error != null) {
      throw error;
    }
    if (newImports != null) {
      for (Iterator localIterator = newImports.iterator(); localIterator.hasNext();)
      {
        String newImport = (String)localIterator.next();
        try
        {
          ManifestElement[] importElements = ManifestElement.parseHeader("Import-Package", newImport);
          loader.addDynamicImportPackage(importElements);
        }
        catch (BundleException localBundleException) {}
      }
    }
    return wovenBytes;
  }
  
  public String toString()
  {
    return className;
  }
  
  public ServiceRegistration<?> getErrorHook()
  {
    return errorHook;
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.eclipse.osgi.framework.internal.core.PackageAdminImpl;
import org.eclipse.osgi.internal.module.CompositeResolveHelper;
import org.eclipse.osgi.service.internal.composite.CompositeModule;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

public abstract class CompositeBase
  extends BundleHost
  implements CompositeResolveHelper, CompositeModule
{
  protected static String PROP_COMPOSITE = "org.eclipse.equinox.Composite";
  protected static String PROP_PARENTFRAMEWORK = "org.eclipse.equinox.parentFramework";
  protected final org.osgi.framework.launch.Framework companionFramework;
  protected final ThreadLocal resolving = new ThreadLocal();
  
  public CompositeBase(BundleData bundledata, org.eclipse.osgi.framework.internal.core.Framework framework)
    throws BundleException
  {
    super(bundledata, framework);
    companionFramework = findCompanionFramework(framework, bundledata);
  }
  
  protected abstract org.osgi.framework.launch.Framework findCompanionFramework(org.eclipse.osgi.framework.internal.core.Framework paramFramework, BundleData paramBundleData)
    throws BundleException;
  
  protected abstract Bundle getCompanionBundle();
  
  protected boolean isSurrogate()
  {
    return false;
  }
  
  public BundleDescription getCompositeDescription()
  {
    return getBundleDescription();
  }
  
  public ClassLoaderDelegate getDelegate()
  {
    return getBundleLoader();
  }
  
  /* Error */
  public void refreshContent()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 107	org/eclipse/osgi/internal/composite/CompositeBase:resolving	Ljava/lang/ThreadLocal;
    //   4: getstatic 104	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
    //   7: invokevirtual 112	java/lang/ThreadLocal:set	(Ljava/lang/Object;)V
    //   10: aload_0
    //   11: getfield 108	org/eclipse/osgi/internal/composite/CompositeBase:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   14: invokevirtual 115	org/eclipse/osgi/framework/internal/core/Framework:getPackageAdmin	()Lorg/eclipse/osgi/framework/internal/core/PackageAdminImpl;
    //   17: iconst_1
    //   18: anewarray 62	org/osgi/framework/Bundle
    //   21: dup
    //   22: iconst_0
    //   23: aload_0
    //   24: aastore
    //   25: iconst_1
    //   26: aconst_null
    //   27: invokevirtual 117	org/eclipse/osgi/framework/internal/core/PackageAdminImpl:refreshPackages	([Lorg/osgi/framework/Bundle;Z[Lorg/osgi/framework/FrameworkListener;)V
    //   30: goto +14 -> 44
    //   33: astore_1
    //   34: aload_0
    //   35: getfield 107	org/eclipse/osgi/internal/composite/CompositeBase:resolving	Ljava/lang/ThreadLocal;
    //   38: aconst_null
    //   39: invokevirtual 112	java/lang/ThreadLocal:set	(Ljava/lang/Object;)V
    //   42: aload_1
    //   43: athrow
    //   44: aload_0
    //   45: getfield 107	org/eclipse/osgi/internal/composite/CompositeBase:resolving	Ljava/lang/ThreadLocal;
    //   48: aconst_null
    //   49: invokevirtual 112	java/lang/ThreadLocal:set	(Ljava/lang/Object;)V
    //   52: return
    // Line number table:
    //   Java source line #67	-> byte code offset #0
    //   Java source line #69	-> byte code offset #10
    //   Java source line #70	-> byte code offset #33
    //   Java source line #71	-> byte code offset #34
    //   Java source line #72	-> byte code offset #42
    //   Java source line #71	-> byte code offset #44
    //   Java source line #73	-> byte code offset #52
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	53	0	this	CompositeBase
    //   33	10	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   10	33	33	finally
  }
  
  public boolean resolveContent()
  {
    resolving.set(Boolean.TRUE);
    try
    {
      return framework.getPackageAdmin().resolveBundles(new Bundle[] { this });
    }
    finally
    {
      resolving.set(null);
    }
  }
  
  public void started(CompositeModule surrogate) {}
  
  public void stopped(CompositeModule surrogate) {}
  
  public void updateContent(InputStream content)
    throws BundleException
  {
    super.update(content);
  }
  
  public void update()
    throws BundleException
  {
    throw new BundleException("Cannot update composite bundles", 2);
  }
  
  public void update(InputStream in)
    throws BundleException
  {
    try
    {
      in.close();
    }
    catch (IOException localIOException) {}
    throw new BundleException("Cannot update composite bundles", 2);
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.security.ProtectionDomain;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.osgi.framework.Bundle;

public class CompositeClassLoader
  extends ClassLoader
  implements BaseClassLoader
{
  private final ClassLoaderDelegate delegate;
  private final ClasspathManager manager;
  private final ClassLoaderDelegate companionDelegate;
  private final ThreadLocal beingLoaded = new ThreadLocal();
  
  public CompositeClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, ClassLoaderDelegate companionDelegate, BaseData data)
  {
    super(parent);
    this.delegate = delegate;
    manager = new ClasspathManager(data, new String[0], this);
    this.companionDelegate = companionDelegate;
  }
  
  public ClasspathEntry createClassPathEntry(BundleFile bundlefile, ProtectionDomain cpDomain)
  {
    return null;
  }
  
  public Class defineClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry)
  {
    return null;
  }
  
  public ClasspathManager getClasspathManager()
  {
    return manager;
  }
  
  public ProtectionDomain getDomain()
  {
    return null;
  }
  
  public Object publicDefinePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
  {
    return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase);
  }
  
  public Class publicFindLoaded(String classname)
  {
    return findLoadedClass(classname);
  }
  
  public Object publicGetPackage(String pkgname)
  {
    return getPackage(pkgname);
  }
  
  public void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath) {}
  
  public void close() {}
  
  public Class findLocalClass(String classname)
    throws ClassNotFoundException
  {
    if (!startLoading(classname)) {
      throw new ClassNotFoundException(classname);
    }
    try
    {
      return companionDelegate.findClass(classname);
    }
    finally
    {
      stopLoading(classname);
    }
  }
  
  public URL findLocalResource(String resource)
  {
    if (!startLoading(resource)) {
      return null;
    }
    try
    {
      return companionDelegate.findResource(resource);
    }
    finally
    {
      stopLoading(resource);
    }
  }
  
  public Enumeration findLocalResources(String resource)
  {
    if (!startLoading(resource)) {
      return null;
    }
    try
    {
      return companionDelegate.findResources(resource);
    }
    catch (IOException localIOException)
    {
      return null;
    }
    finally
    {
      stopLoading(resource);
    }
  }
  
  public ClassLoaderDelegate getDelegate()
  {
    return delegate;
  }
  
  public URL getResource(String name)
  {
    return delegate.findResource(name);
  }
  
  public void initialize()
  {
    manager.initialize();
  }
  
  public Class loadClass(String name)
    throws ClassNotFoundException
  {
    return delegate.findClass(name);
  }
  
  private boolean startLoading(String name)
  {
    Set classesAndResources = (Set)beingLoaded.get();
    if ((classesAndResources != null) && (classesAndResources.contains(name))) {
      return false;
    }
    if (classesAndResources == null)
    {
      classesAndResources = new HashSet(3);
      beingLoaded.set(classesAndResources);
    }
    classesAndResources.add(name);
    return true;
  }
  
  private void stopLoading(String name)
  {
    ((Set)beingLoaded.get()).remove(name);
  }
  
  public Bundle getBundle()
  {
    return manager.getBaseData().getBundle();
  }
  
  public List<URL> findEntries(String path, String filePattern, int options)
  {
    return Collections.EMPTY_LIST;
  }
  
  public Collection<String> listResources(String path, String filePattern, int options)
  {
    return Collections.EMPTY_LIST;
  }
  
  public Collection<String> listLocalResources(String path, String filePattern, int options)
  {
    return Collections.EMPTY_LIST;
  }
}

/* Location:
 * Qualified Name:     org.
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-2019. Infinite Loop Ltd