org.eclipse.osgi_3.8.2.v20130124-134944

updateSplash", null);
    }
    catch (SecurityException e)
    {
      throw ((IllegalStateException)new IllegalStateException(e.getMessage()).initCause(e));
    }
    catch (NoSuchMethodException e)
    {
      throw ((IllegalStateException)new IllegalStateException(e.getMessage()).initCause(e));
    }
  }
  
  public void update()
  {
    if (updateMethod != null) {
      try
      {
        updateMethod.invoke(splashHandler, null);
      }
      catch (Throwable localThrowable) {}
    }
  }
  
  public void applicationRunning()
  {
    if (EclipseStarter.debug)
    {
      String timeString = FrameworkProperties.getProperty("eclipse.startTime");
      long time = timeString == null ? 0L : Long.parseLong(timeString);
      System.out.println("Application Started: " + (System.currentTimeMillis() - time));
    }
    StatsManager.doneBooting();
    splashHandler.run();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.DefaultStartupMonitor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

class EclipseAdaptorHook$ParsingService
  implements ServiceFactory<Object>
{
  private final boolean isSax;
  
  public EclipseAdaptorHook$ParsingService(boolean isSax)
  {
    this.isSax = isSax;
  }
  
  public Object getService(Bundle bundle, ServiceRegistration<Object> registration)
  {
    BundleHost host = (bundle instanceof BundleHost) ? (BundleHost)bundle : null;
    if ((!EclipseAdaptorHook.SET_TCCL_XMLFACTORY) || (bundle == null)) {
      return createService();
    }
    ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();
    try
    {
      ClassLoader cl = host.getClassLoader();
      if (cl != null) {
        Thread.currentThread().setContextClassLoader(cl);
      }
      return createService();
    }
    finally
    {
      Thread.currentThread().setContextClassLoader(savedClassLoader);
    }
  }
  
  private Object createService()
  {
    if (isSax) {
      return SAXParserFactory.newInstance();
    }
    return DocumentBuilderFactory.newInstance();
  }
  
  public void ungetService(Bundle bundle, ServiceRegistration<Object> registration, Object service) {}
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorHook.ParsingService
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.IOException;
import java.io.PrintStream;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.HookConfigurator;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.debug.FrameworkDebugOptions;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.baseadaptor.AdaptorUtil;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.service.localization.BundleLocalization;
import org.eclipse.osgi.service.pluginconversion.PluginConverter;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.urlconversion.URLConverter;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class EclipseAdaptorHook
  implements AdaptorHook, HookConfigurator
{
  public static final String SAXFACTORYNAME = "javax.xml.parsers.SAXParserFactory";
  public static final String DOMFACTORYNAME = "javax.xml.parsers.DocumentBuilderFactory";
  private static final String RUNTIME_ADAPTOR = "org.eclipse.osgi/eclipseadaptor";
  private static final String OPTION_CONVERTER = "org.eclipse.osgi/eclipseadaptor/converter/debug";
  private static final String OPTION_LOCATION = "org.eclipse.osgi/eclipseadaptor/debug/location";
  private static final String OPTION_CACHEDMANIFEST = "org.eclipse.osgi/eclipseadaptor/debug/cachedmanifest";
  static final boolean SET_TCCL_XMLFACTORY = "true".equals(FrameworkProperties.getProperty("eclipse.parsers.setTCCL", "true"));
  private BaseAdaptor adaptor;
  private boolean noXML = false;
  private List<ServiceRegistration<?>> registrations = new ArrayList(10);
  
  public void frameworkStart(BundleContext context)
    throws BundleException
  {
    registrations.clear();
    registerEndorsedXMLParser(context);
    Dictionary<String, Object> locationProperties = new Hashtable(1);
    Location location = LocationManager.getUserLocation();
    if (location != null)
    {
      locationProperties.put("type", "osgi.user.area");
      registrations.add(context.registerService(Location.class.getName(), location, locationProperties));
    }
    location = LocationManager.getInstanceLocation();
    if (location != null)
    {
      locationProperties.put("type", "osgi.instance.area");
      registrations.add(context.registerService(Location.class.getName(), location, locationProperties));
    }
    location = LocationManager.getConfigurationLocation();
    if (location != null)
    {
      locationProperties.put("type", "osgi.configuration.area");
      registrations.add(context.registerService(Location.class.getName(), location, locationProperties));
    }
    location = LocationManager.getInstallLocation();
    if (location != null)
    {
      locationProperties.put("type", "osgi.install.area");
      registrations.add(context.registerService(Location.class.getName(), location, locationProperties));
    }
    location = LocationManager.getEclipseHomeLocation();
    if (location != null)
    {
      locationProperties.put("type", "eclipse.home.location");
      registrations.add(context.registerService(Location.class.getName(), location, locationProperties));
    }
    Dictionary<String, Object> urlProperties = new Hashtable();
    urlProperties.put("protocol", new String[] { "bundleentry", "bundleresource" });
    registrations.add(context.registerService(URLConverter.class.getName(), new URLConverterImpl(), urlProperties));
    
    registrations.add(AdaptorUtil.register(EnvironmentInfo.class.getName(), EclipseEnvironmentInfo.getDefault(), context));
    registrations.add(AdaptorUtil.register(PlatformAdmin.class.getName(), adaptor.getPlatformAdmin(), context));
    PluginConverter converter = PluginConverterImpl.getDefault();
    if (converter == null) {
      converter = new PluginConverterImpl(adaptor, context);
    }
    registrations.add(AdaptorUtil.register(PluginConverter.class.getName(), converter, context));
    String builtinEnabled = FrameworkProperties.getProperty("osgi.console.enable.builtin", "org.eclipse.equinox.console");
    if ("true".equals(builtinEnabled)) {
      registrations.add(AdaptorUtil.register(CommandProvider.class.getName(), new EclipseCommandProvider(context), context));
    }
    registrations.add(AdaptorUtil.register(BundleLocalization.class.getName(), new BundleLocalizationImpl(), context));
  }
  
  private void registerEndorsedXMLParser(BundleContext bc)
  {
    try
    {
      Class.forName("javax.xml.parsers.SAXParserFactory");
      registrations.add(bc.registerService("javax.xml.parsers.SAXParserFactory", new ParsingService(true), null));
      Class.forName("javax.xml.parsers.DocumentBuilderFactory");
      registrations.add(bc.registerService("javax.xml.parsers.DocumentBuilderFactory", new ParsingService(false), null));
    }
    catch (ClassNotFoundException e)
    {
      noXML = true;
      if (Debug.DEBUG_ENABLED)
      {
        String message = EclipseAdaptorMsg.ECLIPSE_ADAPTOR_ERROR_XML_SERVICE;
        adaptor.getFrameworkLog().log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null));
      }
    }
  }
  
  private static class ParsingService
    implements ServiceFactory<Object>
  {
    private final boolean isSax;
    
    public ParsingService(boolean isSax)
    {
      this.isSax = isSax;
    }
    
    public Object getService(Bundle bundle, ServiceRegistration<Object> registration)
    {
      BundleHost host = (bundle instanceof BundleHost) ? (BundleHost)bundle : null;
      if ((!EclipseAdaptorHook.SET_TCCL_XMLFACTORY) || (bundle == null)) {
        return createService();
      }
      ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();
      try
      {
        ClassLoader cl = host.getClassLoader();
        if (cl != null) {
          Thread.currentThread().setContextClassLoader(cl);
        }
        return createService();
      }
      finally
      {
        Thread.currentThread().setContextClassLoader(savedClassLoader);
      }
    }
    
    private Object createService()
    {
      if (isSax) {
        return SAXParserFactory.newInstance();
      }
      return DocumentBuilderFactory.newInstance();
    }
    
    public void ungetService(Bundle bundle, ServiceRegistration<Object> registration, Object service) {}
  }
  
  public void frameworkStop(BundleContext context)
    throws BundleException
  {
    printStats();
    if (!noXML) {
      PluginParser.releaseXMLParsing();
    }
    for (Iterator localIterator = registrations.iterator(); localIterator.hasNext();)
    {
      ServiceRegistration<?> registration = (ServiceRegistration)localIterator.next();
      registration.unregister();
    }
    registrations.clear();
  }
  
  private void printStats()
  {
    FrameworkDebugOptions debugOptions = FrameworkDebugOptions.getDefault();
    if (debugOptions == null) {
      return;
    }
    String registryParsing = debugOptions.getOption("org.eclipse.core.runtime/registry/parsing/timing/value");
    if (registryParsing != null) {
      MessageHelper.debug("Time spent in registry parsing: " + registryParsing);
    }
    String packageAdminResolution = debugOptions.getOption("debug.packageadmin/timing/value");
    if (packageAdminResolution != null) {
      System.out.println("Time spent in package admin resolve: " + packageAdminResolution);
    }
    String constraintResolution = debugOptions.getOption("org.eclipse.core.runtime.adaptor/resolver/timing/value");
    if (constraintResolution != null) {
      System.out.println("Time spent resolving the dependency system: " + constraintResolution);
    }
  }
  
  public void frameworkStopping(BundleContext context) {}
  
  public void addProperties(Properties properties) {}
  
  public URLConnection mapLocationToURLConnection(String location)
    throws IOException
  {
    return null;
  }
  
  public void handleRuntimeError(Throwable error) {}
  
  public FrameworkLog createFrameworkLog()
  {
    return null;
  }
  
  public void initialize(BaseAdaptor initAdaptor)
  {
    adaptor = initAdaptor;
    
    EclipseEnvironmentInfo.getDefault();
    setDebugOptions();
  }
  
  private void setDebugOptions()
  {
    FrameworkDebugOptions options = FrameworkDebugOptions.getDefault();
    if (options == null) {
      return;
    }
    PluginConverterImpl.DEBUG = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/converter/debug", false);
    BasicLocation.DEBUG = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/debug/location", false);
    CachedManifest.DEBUG = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/debug/cachedmanifest", false);
  }
  
  public void addHooks(HookRegistry hookRegistry)
  {
    hookRegistry.addAdaptorHook(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorHook
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import org.eclipse.osgi.util.NLS;

public class EclipseAdaptorMsg
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMessages";
  public static String ECLIPSE_MISSING_IMPORTED_PACKAGE;
  public static String ECLIPSE_MISSING_OPTIONAL_IMPORTED_PACKAGE;
  public static String ECLIPSE_MISSING_DYNAMIC_IMPORTED_PACKAGE;
  public static String ECLIPSE_MISSING_OPTIONAL_REQUIRED_BUNDLE;
  public static String ECLIPSE_MISSING_REQUIRED_BUNDLE;
  public static String ECLIPSE_MISSING_HOST;
  public static String ECLIPSE_MISSING_NATIVECODE;
  public static String ECLIPSE_MISSING_REQUIRED_CAPABILITY;
  public static String ECLIPSE_MISSING_REQUIREMENT;
  public static String ECLIPSE_CANNOT_CHANGE_LOCATION;
  public static String ECLIPSE_BUNDLESTOPPER_CYCLES_FOUND;
  public static String ECLIPSE_CACHEDMANIFEST_UNEXPECTED_EXCEPTION;
  public static String fileManager_cannotLock;
  public static String fileManager_updateFailed;
  public static String fileManager_illegalInReadOnlyMode;
  public static String fileManager_notOpen;
  public static String ECLIPSE_ADAPTOR_ERROR_XML_SERVICE;
  public static String ECLIPSE_ADAPTOR_RUNTIME_ERROR;
  public static String ECLIPSE_ADAPTOR_EXITING;
  public static String ECLIPSE_DATA_MANIFEST_NOT_FOUND;
  public static String ECLIPSE_CONVERTER_ERROR_CONVERTING;
  public static String ECLIPSE_DATA_ERROR_READING_MANIFEST;
  public static String ECLIPSE_CLASSLOADER_CANNOT_GET_HEADERS;
  public static String ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP;
  public static String ECLIPSE_CLASSLOADER_ACTIVATION;
  public static String ECLIPSE_CONSOLE_COMMANDS_HEADER;
  public static String ECLIPSE_CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION;
  public static String ECLIPSE_CONSOLE_HELP_ENABLE_COMMAND_DESCRIPTION;
  public static String ECLIPSE_CONSOLE_HELP_DISABLE_COMMAND_DESCRIPTION;
  public static String ECLIPSE_CONSOLE_HELP_LD_COMMAND_DESCRIPTION;
  public static String ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR;
  public static String ECLIPSE_CONSOLE_NO_CONSTRAINTS_NO_PLATFORM_ADMIN_MESSAGE;
  public static String ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR;
  public static String ECLIPSE_CONSOLE_NO_CONSTRAINTS;
  public static String ECLIPSE_CONSOLE_DIRECT_CONSTRAINTS;
  public static String ECLIPSE_CONSOLE_LEAF_CONSTRAINTS;
  public static String ECLIPSE_CONSOLE_BUNDLE_DISABLED_MESSAGE;
  public static String ECLIPSE_CONSOLE_DISABLED_COUNT_MESSAGE;
  public static String ECLIPSE_CONSOLE_DISABLED_BUNDLE_HEADER;
  public static String ECLIPSE_CONSOLE_DISABLED_BUNDLE_REASON1;
  public static String ECLIPSE_STARTUP_ALREADY_RUNNING;
  public static String ECLIPSE_STARTUP_STARTUP_ERROR;
  public static String ECLIPSE_STARTUP_SHUTDOWN_ERROR;
  public static String ECLIPSE_STARTUP_ERROR_CHECK_LOG;
  public static String ECLIPSE_STARTUP_NOT_RUNNING;
  public static String ECLIPSE_STARTUP_ERROR_NO_APPLICATION;
  public static String ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED;
  public static String ECLIPSE_STARTUP_ALL_NOT_RESOLVED;
  public static String ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE;
  public static String ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED;
  public static String ECLIPSE_STARTUP_BUNDLE_NOT_FOUND;
  public static String ECLIPSE_STARTUP_FAILED_UNINSTALL;
  public static String ECLIPSE_STARTUP_FAILED_INSTALL;
  public static String ECLIPSE_STARTUP_FAILED_START;
  public static String ECLIPSE_STARTUP_APP_ERROR;
  public static String ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR;
  public static String ECLIPSE_STARTUP_PROPS_NOT_SET;
  public static String error_badNL;
  public static String location_cannotLock;
  public static String location_cannotLockNIO;
  public static String location_folderReadOnly;
  public static String location_notSet;
  public static String location_notFileProtocol;
  public static String location_noLockFile;
  public static String ECLIPSE_CONVERTER_FILENOTFOUND;
  public static String ECLIPSE_CONVERTER_ERROR_CREATING_BUNDLE_MANIFEST;
  public static String ECLIPSE_CONVERTER_PLUGIN_LIBRARY_IGNORED;
  public static String ECLIPSE_CONVERTER_ERROR_PARSING_PLUGIN_MANIFEST;
  public static String ECLIPSE_CONVERTER_MISSING_ATTRIBUTE;
  public static String parse_error;
  public static String parse_errorNameLineColumn;
  public static String ECLIPSE_CONVERTER_NO_SAX_FACTORY;
  public static String ECLIPSE_CONVERTER_PARSE_UNKNOWNTOP_ELEMENT;
  public static String ECLIPSE_PLUGIN_EXTRACTION_PROBLEM;
  
  static
  {
    NLS.initializeMessages("org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMessages", EclipseAdaptorMsg.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMsg
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.PrintStream;
import java.lang.reflect.Method;
import java.util.Map;
import org.eclipse.core.runtime.adaptor.EclipseStarter;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.profile.Profile;
import org.eclipse.osgi.service.runnable.ApplicationLauncher;
import org.eclipse.osgi.service.runnable.ApplicationRunnable;
import org.eclipse.osgi.service.runnable.ParameterizedRunnable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

public class EclipseAppLauncher
  implements ApplicationLauncher
{
  private volatile ParameterizedRunnable runnable = null;
  private Object appContext = null;
  private Semaphore runningLock = new Semaphore(1);
  private Semaphore waitForAppLock = new Semaphore(0);
  private BundleContext context;
  private boolean relaunch = false;
  private boolean failOnNoDefault = false;
  private FrameworkLog log;
  
  public EclipseAppLauncher(BundleContext context, boolean relaunch, boolean failOnNoDefault, FrameworkLog log)
  {
    this.context = context;
    this.relaunch = relaunch;
    this.failOnNoDefault = failOnNoDefault;
    this.log = log;
    findRunnableService();
  }
  
  private void findRunnableService()
  {
    String appClass = ParameterizedRunnable.class.getName();
    ServiceReference[] runRefs = null;
    try
    {
      runRefs = context.getServiceReferences(ParameterizedRunnable.class.getName(), "(&(objectClass=" + appClass + ")(eclipse.application=*))");
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    if ((runRefs != null) && (runRefs.length > 0))
    {
      runnable = ((ParameterizedRunnable)context.getService(runRefs[0]));
      
      relaunch = false;
      waitForAppLock.release();
    }
  }
  
  public Object start(Object defaultContext)
    throws Exception
  {
    if ((failOnNoDefault) && (runnable == null)) {
      throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_NO_APPLICATION);
    }
    Object result = null;
    boolean doRelaunch;
    do
    {
      try
      {
        result = runApplication(defaultContext);
      }
      catch (Exception e)
      {
        if ((!relaunch) || ((context.getBundle().getState() & 0x20) == 0)) {
          throw e;
        }
        if (log != null) {
          log.log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_APP_ERROR, 1, e, null));
        }
      }
      doRelaunch = ((relaunch) && ((context.getBundle().getState() & 0x20) != 0)) || (FrameworkProperties.getProperty("osgi.framework.relaunch") != null);
    } while (doRelaunch);
    return result;
  }
  
  private Object runApplication(Object defaultContext)
    throws Exception
  {
    waitForAppLock.acquire();
    
    runningLock.acquire();
    long time;
    if (EclipseStarter.debug)
    {
      timeString = FrameworkProperties.getProperty("eclipse.startTime");
      time = timeString == null ? 0L : Long.parseLong(timeString);
      System.out.println("Starting application: " + (System.currentTimeMillis() - time));
    }
    if ((Profile.STARTUP) || (Profile.BENCHMARK)) {
      Profile.logTime("EclipseStarter.run(Object)()", "framework initialized! starting application...");
    }
    try
    {
      return runnable.run(appContext != null ? appContext : defaultContext);
    }
    finally
    {
      if (Profile.STARTUP) {
        Profile.logExit("EclipseStarter.run(Object)()");
      }
      runnable = null;
      appContext = null;
      runningLock.release();
    }
  }
  
  public void launch(ParameterizedRunnable app, Object applicationContext)
  {
    waitForAppLock.acquire(-1L);
    if (!runningLock.acquire(-1L)) {
      throw new IllegalStateException("An application is aready running.");
    }
    runnable = app;
    appContext = applicationContext;
    waitForAppLock.release();
    runningLock.release();
  }
  
  public void shutdown()
  {
    if (runningLock.acquire(-1L)) {
      return;
    }
    ParameterizedRunnable currentRunnable = runnable;
    if ((currentRunnable instanceof ApplicationRunnable))
    {
      ((ApplicationRunnable)currentRunnable).stop();
      runningLock.acquire(60000L);
    }
  }
  
  public Object reStart(Object argument)
    throws Exception
  {
    ServiceReference[] ref = null;
    ref = context.getServiceReferences("org.osgi.service.application.ApplicationDescriptor", "(eclipse.application.default=true)");
    if ((ref != null) && (ref.length > 0))
    {
      Object defaultApp = context.getService(ref[0]);
      Method launch = defaultApp.getClass().getMethod("launch", new Class[] { Map.class });
      launch.invoke(defaultApp, new Object[1]);
      return start(argument);
    }
    throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_NO_APPLICATION);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.File;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
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.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
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.internal.core.FrameworkProperties;
import org.eclipse.osgi.internal.baseadaptor.BaseClassLoadingHook;
import org.eclipse.osgi.internal.baseadaptor.BaseStorageHook;

public class EclipseClassLoadingHook
  implements ClassLoadingHook, HookConfigurator
{
  private static String[] NL_JAR_VARIANTS = buildNLJarVariants(EclipseEnvironmentInfo.getDefault().getNL());
  private static boolean DEFINE_PACKAGES;
  private static final boolean DEFINE_PACKAGE_ATTRIBUTES = !"noattributes".equals(FrameworkProperties.getProperty("osgi.classloader.define.packages"));
  private static String[] LIB_VARIANTS = buildLibraryVariants();
  private Object pkgLock = new Object();
  
  static
  {
    try
    {
      Class.forName("java.lang.Package");
      DEFINE_PACKAGES = true;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      DEFINE_PACKAGES = false;
    }
  }
  
  private static String[] buildLibraryVariants()
  {
    List<String> result = new ArrayList();
    EclipseEnvironmentInfo info = EclipseEnvironmentInfo.getDefault();
    result.add("ws/" + info.getWS() + "/");
    result.add("os/" + info.getOS() + "/" + info.getOSArch() + "/");
    result.add("os/" + info.getOS() + "/");
    String nl = info.getNL();
    nl = nl.replace('_', '/');
    while (nl.length() > 0)
    {
      result.add("nl/" + nl + "/");
      int i = nl.lastIndexOf('/');
      nl = i < 0 ? "" : nl.substring(0, i);
    }
    result.add("");
    return (String[])result.toArray(new String[result.size()]);
  }
  
  public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
  {
    if (!DEFINE_PACKAGES) {
      return null;
    }
    int lastIndex = name.lastIndexOf('.');
    if (lastIndex < 0) {
      return null;
    }
    String packageName = name.substring(0, lastIndex);
    synchronized (pkgLock)
    {
      Object pkg = manager.getBaseClassLoader().publicGetPackage(packageName);
      if (pkg != null) {
        return null;
      }
    }
    Object pkg;
    String specTitle = null;String specVersion = null;String specVendor = null;String implTitle = null;String implVersion = null;String implVendor = null;
    if (DEFINE_PACKAGE_ATTRIBUTES)
    {
      ClasspathManifest cpm = (ClasspathManifest)classpathEntry.getUserObject(ClasspathManifest.KEY);
      if (cpm == null)
      {
        cpm = new ClasspathManifest();
        classpathEntry.addUserObject(cpm);
      }
      Manifest mf = cpm.getManifest(classpathEntry, manager);
      if (mf != null)
      {
        Attributes mainAttributes = mf.getMainAttributes();
        String dirName = packageName.replace('.', '/') + '/';
        Attributes packageAttributes = mf.getAttributes(dirName);
        boolean noEntry = false;
        if (packageAttributes == null)
        {
          noEntry = true;
          packageAttributes = mainAttributes;
        }
        specTitle = packageAttributes.getValue(Attributes.Name.SPECIFICATION_TITLE);
        if ((specTitle == null) && (!noEntry)) {
          specTitle = mainAttributes.getValue(Attributes.Name.SPECIFICATION_TITLE);
        }
        specVersion = packageAttributes.getValue(Attributes.Name.SPECIFICATION_VERSION);
        if ((specVersion == null) && (!noEntry)) {
          specVersion = mainAttributes.getValue(Attributes.Name.SPECIFICATION_VERSION);
        }
        specVendor = packageAttributes.getValue(Attributes.Name.SPECIFICATION_VENDOR);
        if ((specVendor == null) && (!noEntry)) {
          specVendor = mainAttributes.getValue(Attributes.Name.SPECIFICATION_VENDOR);
        }
        implTitle = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
        if ((implTitle == null) && (!noEntry)) {
          implTitle = mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
        }
        implVersion = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
        if ((implVersion == null) && (!noEntry)) {
          implVersion = mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
        }
        implVendor = packageAttributes.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
        if ((implVendor == null) && (!noEntry)) {
          implVendor = mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
        }
      }
    }
    synchronized (pkgLock)
    {
      pkg = manager.getBaseClassLoader().publicGetPackage(packageName);
      if (pkg != null) {
        return null;
      }
      manager.getBaseClassLoader().publicDefinePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, null);
    }
    return null;
  }
  
  public boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain)
  {
    String var = hasPrefix(cp);
    if (var != null) {
      return addInternalClassPath(var, cpEntries, cp, hostmanager, sourcedata, sourcedomain);
    }
    if (cp.startsWith("external:"))
    {
      cp = cp.substring("external:".length());
      
      ClasspathEntry cpEntry = hostmanager.getExternalClassPath(BaseStorageHook.substituteVars(cp), sourcedata, sourcedomain);
      if (cpEntry != null)
      {
        cpEntries.add(cpEntry);
        return true;
      }
    }
    return false;
  }
  
  private boolean addInternalClassPath(String var, ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostloader, BaseData sourcedata, ProtectionDomain sourcedomain)
  {
    if (var.equals("ws")) {
      return ClasspathManager.addClassPathEntry(cpEntries, "ws/" + EclipseEnvironmentInfo.getDefault().getWS() + cp.substring(4), hostloader, sourcedata, sourcedomain);
    }
    if (var.equals("os")) {
      return ClasspathManager.addClassPathEntry(cpEntries, "os/" + EclipseEnvironmentInfo.getDefault().getOS() + cp.substring(4), hostloader, sourcedata, sourcedomain);
    }
    if (var.equals("nl"))
    {
      cp = cp.substring(4);
      for (int i = 0; i < NL_JAR_VARIANTS.length; i++) {
        if (ClasspathManager.addClassPathEntry(cpEntries, "nl/" + NL_JAR_VARIANTS[i] + cp, hostloader, sourcedata, sourcedomain)) {
          return true;
        }
      }
    }
    return false;
  }
  
  private static String hasPrefix(String libPath)
  {
    if (libPath.startsWith("$ws$")) {
      return "ws";
    }
    if (libPath.startsWith("$os$")) {
      return "os";
    }
    if (libPath.startsWith("$nl$")) {
      return "nl";
    }
    return null;
  }
  
  private static String[] buildNLJarVariants(String nl)
  {
    List<String> result = new ArrayList();
    nl = nl.replace('_', '/');
    while (nl.length() > 0)
    {
      result.add("nl/" + nl + "/");
      int i = nl.lastIndexOf('/');
      nl = i < 0 ? "" : nl.substring(0, i);
    }
    result.add("");
    return (String[])result.toArray(new String[result.size()]);
  }
  
  public void recordClassDefine(String name, Class<?> clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {}
  
  public String findLibrary(BaseData data, String libName)
  {
    if (libName.length() == 0) {
      return null;
    }
    if ((libName.charAt(0) == '/') || (libName.charAt(0) == '\\')) {
      libName = libName.substring(1);
    }
    String mappedLibName = System.mapLibraryName(libName);
    String result = searchVariants(data, mappedLibName);
    if (result != null) {
      return result;
    }
    String[] mappedLibNames = BaseClassLoadingHook.mapLibraryNames(mappedLibName);
    for (int i = 0; (i < mappedLibNames.length) && (result == null); i++) {
      result = searchVariants(data, mappedLibNames[i]);
    }
    return result;
  }
  
  private String searchVariants(BaseData bundledata, String path)
  {
    for (int i = 0; i < LIB_VARIANTS.length; i++)
    {
      BundleFile baseBundleFile = bundledata.getBundleFile();
      BundleEntry libEntry = baseBundleFile.getEntry(LIB_VARIANTS[i] + path);
      if (libEntry != null)
      {
        File libFile = baseBundleFile.getFile(LIB_VARIANTS[i] + path, true);
        if (libFile == null) {
          return null;
        }
        if ("hpux".equals(EclipseEnvironmentInfo.getDefault().getOS())) {
          try
          {
            Runtime.getRuntime().exec(new String[] { "chmod", "755", libFile.getAbsolutePath() }).waitFor();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
        return libFile.getAbsolutePath();
      }
    }
    return null;
  }
  
  public ClassLoader getBundleClassLoaderParent()
  {
    return null;
  }
  
  public void addHooks(HookRegistry hookRegistry)
  {
    hookRegistry.addClassLoadingHook(this);
  }
  
  public BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath)
  {
    return null;
  }
  
  public void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data) {}
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseClassLoadingHook
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.State;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

public class EclipseCommandProvider
  implements CommandProvider
{
  public static final String NEW_LINE = "\r\n";
  public static final String TAB = "\t";
  private static final String POLICY_CONSOLE = "org.eclipse.osgi.framework.console";
  private PlatformAdmin platformAdmin;
  private BundleContext context;
  private Map<String, String> commandsHelp = null;
  
  public EclipseCommandProvider(BundleContext context)
  {
    this.context = context;
  }
  
  public String getHelp()
  {
    return getHelp(null);
  }
  
  private String getHelp(String commandName)
  {
    StringBuffer help = new StringBuffer(512);
    if (commandsHelp == null) {
      initializeCommandsHelp();
    }
    if (commandName != null)
    {
      if (commandsHelp.containsKey(commandName)) {
        addCommand(commandName, (String)commandsHelp.get(commandName), help);
      }
      return help.toString();
    }
    addHeader(EclipseAdaptorMsg.ECLIPSE_CONSOLE_COMMANDS_HEADER, help);
    for (Iterator localIterator = commandsHelp.entrySet().iterator(); localIterator.hasNext();)
    {
      Map.Entry<String, String> entry = (Map.Entry)localIterator.next();
      addCommand((String)entry.getKey(), (String)entry.getValue(), help);
    }
    return help.toString();
  }
  
  private void initializeCommandsHelp()
  {
    commandsHelp = new LinkedHashMap();
    commandsHelp.put("diag", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION);
    commandsHelp.put("enableBundle", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_ENABLE_COMMAND_DESCRIPTION);
    commandsHelp.put("disableBundle", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_DISABLE_COMMAND_DESCRIPTION);
    commandsHelp.put("disabledBundles", EclipseAdaptorMsg.ECLIPSE_CONSOLE_HELP_LD_COMMAND_DESCRIPTION);
  }
  
  private void addHeader(String header, StringBuffer help)
  {
    help.append("---");
    help.append(header);
    help.append("---");
    help.append("\r\n");
  }
  
  private void addCommand(String command, String description, StringBuffer help)
  {
    help.append("\t");
    help.append(command);
    help.append(" - ");
    help.append(description);
    help.append("\r\n");
  }
  
  private BundleDescription getBundleDescriptionFromToken(State state, String token)
  {
    try
    {
      long id = Long.parseLong(token);
      return state.getBundle(id);
    }
    catch (NumberFormatException localNumberFormatException)
    {
      BundleDescription[] allBundles = state.getBundles(token);
      if (allBundles.length > 0) {
        return allBundles[0];
      }
    }
    return null;
  }
  
  private PlatformAdmin getPlatformAdmin(CommandInterpreter ci)
  {
    if (platformAdmin == null)
    {
      ServiceReference<?> platformAdminRef = context.getServiceReference(PlatformAdmin.class.getName());
      if (platformAdminRef == null)
      {
        ci.print("  ");
        ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_CONSTRAINTS_NO_PLATFORM_ADMIN_MESSAGE);
        return null;
      }
      platformAdmin = ((PlatformAdmin)context.getService(platformAdminRef));
    }
    return platformAdmin;
  }
  
  private void ungetPlatformAdmin()
  {
    ServiceReference<?> platformAdminRef = context.getServiceReference(PlatformAdmin.class.getName());
    context.ungetService(platformAdminRef);
  }
  
  /* Error */
  public void _diag(CommandInterpreter ci)
    throws java.lang.Exception
  {
    // Byte code:
    //   0: aload_1
    //   1: invokeinterface 421 1 0
    //   6: astore_2
    //   7: aload_2
    //   8: ifnonnull +13 -> 21
    //   11: aload_1
    //   12: getstatic 369	org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg:ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR	Ljava/lang/String;
    //   15: invokeinterface 420 2 0
    //   20: return
    //   21: aload_0
    //   22: aload_1
    //   23: invokespecial 400	org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider:getPlatformAdmin	(Lorg/eclipse/osgi/framework/console/CommandInterpreter;)Lorg/eclipse/osgi/service/resolver/PlatformAdmin;
    //   26: iconst_0
    //   27: invokeinterface 429 2 0
    //   32: astore_3
    //   33: goto +466 -> 499
    //   36: aload_0
    //   37: aload_3
    //   38: aload_2
    //   39: invokespecial 402	org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider:getBundleDescriptionFromToken	(Lorg/eclipse/osgi/service/resolver/State;Ljava/lang/String;)Lorg/eclipse/osgi/service/resolver/BundleDescription;
    //   42: astore 4
    //   44: aload 4
    //   46: ifnonnull +26 -> 72
    //   49: aload_1
    //   50: getstatic 358	org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg:ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR	Ljava/lang/String;
    //   53: aload_2
    //   54: invokestatic 407	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   57: invokeinterface 420 2 0
    //   62: aload_1
    //   63: invokeinterface 421 1 0
    //   68: astore_2
    //   69: goto +430 -> 499
    //   72: aload_1
    //   73: new 190	java/lang/StringBuffer
    //   76: dup
    //   77: aload 4
    //   79: invokeinterface 423 1 0
    //   84: invokestatic 386	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   87: invokespecial 389	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   90: ldc_w 178
    //   93: invokevirtual 392	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   96: aload 4
    //   98: invokeinterface 422 1 0
    //   103: invokevirtual 390	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   106: ldc_w 179
    //   109: invokevirtual 392	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   112: invokevirtual 388	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   115: invokeinterface 420 2 0
    //   120: aload_0
    //   121: getfield 374	org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider:platformAdmin	Lorg/eclipse/osgi/service/resolver/PlatformAdmin;
    //   124: invokeinterface 430 1 0
    //   129: aload 4
    //   131: invokeinterface 437 2 0
    //   136: astore 5
    //   138: aload_0
    //   139: getfield 374	org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider:platformAdmin	Lorg/eclipse/osgi/service/resolver/PlatformAdmin;
    //   142: iconst_0
    //   143: invokeinterface 429 2 0
    //   148: aload 4
    //   150: invokeinterface 436 2 0
    //   155: astore 6
    //   157: iconst_0
    //   158: istore 7
    //   160: goto +48 -> 208
    //   163: aload 6
    //   165: iload 7
    //   167: aaload
    //   168: invokeinterface 431 1 0
    //   173: ldc_w 175
    //   176: iand
    //   177: ifeq +6 -> 183
    //   180: goto +25 -> 205
    //   183: aload_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-2019. Infinite Loop Ltd