org.eclipse.equinox.launcher_1.3.0.v20120522-1813

16:44:00.461 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
package org.eclipse.core.launcher;

public class Main
{
  public static void main(String[] args)
  {
    org.eclipse.equinox.launcher.Main.main(args);
  }
}

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

public class Constants
{
  public static final String INTERNAL_ARCH_I386 = "i386";
  public static final String INTERNAL_AMD64 = "amd64";
  public static final String INTERNAL_OS_SUNOS = "SunOS";
  public static final String INTERNAL_OS_LINUX = "Linux";
  public static final String INTERNAL_OS_MACOSX = "Mac OS";
  public static final String INTERNAL_OS_AIX = "AIX";
  public static final String INTERNAL_OS_HPUX = "HP-UX";
  public static final String INTERNAL_OS_QNX = "QNX";
  public static final String INTERNAL_OS_OS400 = "OS/400";
  public static final String INTERNAL_OS_OS390 = "OS/390";
  public static final String INTERNAL_OS_ZOS = "z/OS";
  public static final String ARCH_X86 = "x86";
  public static final String ARCH_X86_64 = "x86_64";
  public static final String OS_WIN32 = "win32";
  public static final String OS_LINUX = "linux";
  public static final String OS_AIX = "aix";
  public static final String OS_SOLARIS = "solaris";
  public static final String OS_HPUX = "hpux";
  public static final String OS_QNX = "qnx";
  public static final String OS_MACOSX = "macosx";
  public static final String OS_OS400 = "os/400";
  public static final String OS_OS390 = "os/390";
  public static final String OS_ZOS = "z/os";
  public static final String OS_UNKNOWN = "unknown";
  public static final String WS_WIN32 = "win32";
  public static final String WS_WPF = "wpf";
  public static final String WS_MOTIF = "motif";
  public static final String WS_GTK = "gtk";
  public static final String WS_PHOTON = "photon";
  public static final String WS_CARBON = "carbon";
  public static final String WS_COCOA = "cocoa";
  public static final String WS_UNKNOWN = "unknown";
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.launcher.Constants
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

public class JNIBridge
{
  private String library;
  private boolean libraryLoaded = false;
  
  private native void _set_exit_data(String paramString1, String paramString2);
  
  private native void _set_launcher_info(String paramString1, String paramString2);
  
  private native void _update_splash();
  
  private native long _get_splash_handle();
  
  private native void _show_splash(String paramString);
  
  private native void _takedown_splash();
  
  private native int OleInitialize(int paramInt);
  
  private native void OleUninitialize();
  
  public JNIBridge(String library)
  {
    this.library = library;
  }
  
  private void loadLibrary()
  {
    if (library != null) {
      try
      {
        if (library.indexOf("wpf") != -1)
        {
          int idx = library.indexOf("eclipse_");
          if (idx != -1)
          {
            String comLibrary = library.substring(0, idx) + "com_";
            comLibrary = comLibrary + library.substring(idx + 8, library.length());
            Runtime.getRuntime().load(comLibrary);
            OleInitialize(0);
          }
        }
        Runtime.getRuntime().load(library);
      }
      catch (UnsatisfiedLinkError localUnsatisfiedLinkError) {}
    }
    libraryLoaded = true;
  }
  
  public boolean setExitData(String sharedId, String data)
  {
    try
    {
      _set_exit_data(sharedId, data);
      return true;
    }
    catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
    {
      if (!libraryLoaded)
      {
        loadLibrary();
        return setExitData(sharedId, data);
      }
    }
    return false;
  }
  
  public boolean setLauncherInfo(String launcher, String name)
  {
    try
    {
      _set_launcher_info(launcher, name);
      return true;
    }
    catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
    {
      if (!libraryLoaded)
      {
        loadLibrary();
        return setLauncherInfo(launcher, name);
      }
    }
    return false;
  }
  
  public boolean showSplash(String bitmap)
  {
    try
    {
      _show_splash(bitmap);
      return true;
    }
    catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
    {
      if (!libraryLoaded)
      {
        loadLibrary();
        return showSplash(bitmap);
      }
    }
    return false;
  }
  
  public boolean updateSplash()
  {
    try
    {
      _update_splash();
      return true;
    }
    catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
    {
      if (!libraryLoaded)
      {
        loadLibrary();
        return updateSplash();
      }
    }
    return false;
  }
  
  public long getSplashHandle()
  {
    try
    {
      return _get_splash_handle();
    }
    catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
    {
      if (!libraryLoaded)
      {
        loadLibrary();
        return getSplashHandle();
      }
    }
    return -1L;
  }
  
  boolean isLibraryLoadedByJava()
  {
    return libraryLoaded;
  }
  
  public boolean takeDownSplash()
  {
    try
    {
      _takedown_splash();
      return true;
    }
    catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
    {
      if (!libraryLoaded)
      {
        loadLibrary();
        return takeDownSplash();
      }
    }
    return false;
  }
  
  public boolean uninitialize()
  {
    if ((libraryLoaded) && (library != null) && 
      (library.indexOf("wpf") != -1)) {
      try
      {
        OleUninitialize();
      }
      catch (UnsatisfiedLinkError localUnsatisfiedLinkError)
      {
        return false;
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.JNIBridge
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Enumeration;

class Main$1
  extends PermissionCollection
{
  private static final long serialVersionUID = 3258131349494708277L;
  final Main.EclipsePolicy this$1;
  
  Main$1(Main.EclipsePolicy paramEclipsePolicy)
  {
    this$1 = paramEclipsePolicy;
  }
  
  public void add(Permission permission) {}
  
  public boolean implies(Permission permission)
  {
    return true;
  }
  
  public Enumeration elements()
  {
    return new Main.2(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.Main.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

import java.util.Enumeration;
import java.util.NoSuchElementException;

class Main$2
  implements Enumeration
{
  int cur;
  final Main.1 this$2;
  
  Main$2(Main.1 param1)
  {
    this$2 = param1;
    cur = 0;
  }
  
  public boolean hasMoreElements()
  {
    return cur < 1;
  }
  
  public Object nextElement()
  {
    if (cur == 0)
    {
      cur = 1;
      return access$0this$2).allPermission;
    }
    throw new NoSuchElementException();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.Main.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

import java.net.URL;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Policy;
import java.security.ProtectionDomain;

class Main$EclipsePolicy
  extends Policy
{
  private Policy policy;
  private URL[] urls;
  private PermissionCollection allPermissions;
  Permission allPermission;
  final Main this$0;
  
  Main$EclipsePolicy(Main paramMain, Policy policy, URL[] urls)
  {
    this$0 = paramMain;allPermission = new AllPermission();
    this.policy = policy;
    this.urls = urls;
    allPermissions = new Main.1(this);
  }
  
  public PermissionCollection getPermissions(CodeSource codesource)
  {
    if (contains(codesource)) {
      return allPermissions;
    }
    return policy == null ? allPermissions : policy.getPermissions(codesource);
  }
  
  public PermissionCollection getPermissions(ProtectionDomain domain)
  {
    if (contains(domain.getCodeSource())) {
      return allPermissions;
    }
    return policy == null ? allPermissions : policy.getPermissions(domain);
  }
  
  public boolean implies(ProtectionDomain domain, Permission permission)
  {
    if (contains(domain.getCodeSource())) {
      return true;
    }
    return policy == null ? true : policy.implies(domain, permission);
  }
  
  public void refresh()
  {
    if (policy != null) {
      policy.refresh();
    }
  }
  
  private boolean contains(CodeSource codeSource)
  {
    if (codeSource == null) {
      return false;
    }
    URL url = codeSource.getLocation();
    if (url == null) {
      return false;
    }
    for (int i = 0; i < urls.length; i++) {
      if (urls[i] == url) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.Main.EclipsePolicy
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

import java.util.StringTokenizer;

class Main$Identifier
{
  private static final String DELIM = ". _-";
  private int major;
  private int minor;
  private int service;
  
  Main$Identifier(int major, int minor, int service)
  {
    this.major = major;
    this.minor = minor;
    this.service = service;
  }
  
  Main$Identifier(String versionString)
  {
    StringTokenizer tokenizer = new StringTokenizer(versionString, ". _-");
    if (tokenizer.hasMoreTokens()) {
      major = Integer.parseInt(tokenizer.nextToken());
    }
    if (tokenizer.hasMoreTokens()) {
      minor = Integer.parseInt(tokenizer.nextToken());
    }
    try
    {
      if (tokenizer.hasMoreTokens()) {
        service = Integer.parseInt(tokenizer.nextToken());
      }
    }
    catch (NumberFormatException localNumberFormatException) {}
  }
  
  boolean isGreaterEqualTo(Identifier minimum)
  {
    if (major < major) {
      return false;
    }
    if (major > major) {
      return true;
    }
    if (minor < minor) {
      return false;
    }
    if (minor > minor) {
      return true;
    }
    return service >= service;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.Main.Identifier
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

public final class Main$SplashHandler
  extends Thread
{
  final Main this$0;
  
  public Main$SplashHandler(Main paramMain)
  {
    this$0 = paramMain;
  }
  
  public void run()
  {
    this$0.takeDownSplash();
  }
  
  public void updateSplash()
  {
    if ((this$0.bridge != null) && (!this$0.splashDown)) {
      this$0.bridge.updateSplash();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.Main.SplashHandler
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory;

class Main$StartupClassLoader
  extends URLClassLoader
{
  final Main this$0;
  
  public Main$StartupClassLoader(Main paramMain, URL[] urls)
  {
    super(urls);
    this$0 = paramMain;
  }
  
  public Main$StartupClassLoader(Main paramMain, URL[] urls, ClassLoader parent)
  {
    super(urls, parent);
    this$0 = paramMain;
  }
  
  public Main$StartupClassLoader(Main paramMain, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)
  {
    super(urls, parent, factory);
    this$0 = paramMain;
  }
  
  protected String findLibrary(String name)
  {
    if (this$0.extensionPaths == null) {
      return super.findLibrary(name);
    }
    String libName = System.mapLibraryName(name);
    for (int i = 0; i < this$0.extensionPaths.length; i++)
    {
      File libFile = new File(this$0.extensionPaths[i], libName);
      if (libFile.isFile()) {
        return libFile.getAbsolutePath();
      }
    }
    return super.findLibrary(name);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.launcher.Main.StartupClassLoader
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.launcher;

import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.net.URLStreamHandlerFactory;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Policy;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main
{
  protected boolean debug = false;
  protected String bootLocation = null;
  protected URL installLocation = null;
  protected URL configurationLocation = null;
  protected String parentConfigurationLocation = null;
  protected String framework = "org.eclipse.osgi";
  protected String devClassPath = null;
  private Properties devClassPathProps = null;
  protected boolean inDevelopmentMode = false;
  protected String os = null;
  protected String ws = null;
  protected String arch = null;
  private String library = null;
  private String exitData = null;
  private String vm = null;
  private String[] vmargs = null;
  private String[] commands = null;
  String[] extensionPaths = null;
  JNIBridge bridge = null;
  private boolean showSplash = false;
  private String splashLocation = null;
  private String endSplash = null;
  private boolean initialize = false;
  protected boolean splashDown = false;
  
  public final class SplashHandler
    extends Thread
  {
    public SplashHandler() {}
    
    public void run()
    {
      takeDownSplash();
    }
    
    public void updateSplash()
    {
      if ((bridge != null) && (!splashDown)) {
        bridge.updateSplash();
      }
    }
  }
  
  private final Thread splashHandler = new SplashHandler();
  public static final String SPLASH_HANDLE = "org.eclipse.equinox.launcher.splash.handle";
  public static final String SPLASH_LOCATION = "org.eclipse.equinox.launcher.splash.location";
  private static final String FRAMEWORK = "-framework";
  private static final String INSTALL = "-install";
  private static final String INITIALIZE = "-initialize";
  private static final String VM = "-vm";
  private static final String VMARGS = "-vmargs";
  private static final String DEBUG = "-debug";
  private static final String DEV = "-dev";
  private static final String CONFIGURATION = "-configuration";
  private static final String NOSPLASH = "-nosplash";
  private static final String SHOWSPLASH = "-showsplash";
  private static final String EXITDATA = "-exitdata";
  private static final String NAME = "-name";
  private static final String LAUNCHER = "-launcher";
  private static final String LIBRARY = "--launcher.library";
  private static final String APPEND_VMARGS = "--launcher.appendVmargs";
  private static final String OVERRIDE_VMARGS = "--launcher.overrideVmargs";
  private static final String NL = "-nl";
  private static final String ENDSPLASH = "-endsplash";
  private static final String SPLASH_IMAGE = "splash.bmp";
  private static final String CLEAN = "-clean";
  private static final String NOEXIT = "-noExit";
  private static final String OS = "-os";
  private static final String WS = "-ws";
  private static final String ARCH = "-arch";
  private static final String STARTUP = "-startup";
  private static final String OSGI = "org.eclipse.osgi";
  private static final String STARTER = "org.eclipse.core.runtime.adaptor.EclipseStarter";
  private static final String PLATFORM_URL = "platform:/base/";
  private static final String ECLIPSE_PROPERTIES = "eclipse.properties";
  private static final String FILE_SCHEME = "file:";
  protected static final String REFERENCE_SCHEME = "reference:";
  protected static final String JAR_SCHEME = "jar:";
  private static final String CONFIG_DIR = "configuration/";
  private static final String CONFIG_FILE = "config.ini";
  private static final String CONFIG_FILE_TEMP_SUFFIX = ".tmp";
  private static final String CONFIG_FILE_BAK_SUFFIX = ".bak";
  private static final String ECLIPSE = "eclipse";
  private static final String PRODUCT_SITE_MARKER = ".eclipseproduct";
  private static final String PRODUCT_SITE_ID = "id";
  private static final String PRODUCT_SITE_VERSION = "version";
  private static final String PROP_USER_HOME = "user.home";
  private static final String PROP_USER_DIR = "user.dir";
  private static final String PROP_INSTALL_AREA = "osgi.install.area";
  private static final String PROP_CONFIG_AREA = "osgi.configuration.area";
  private static final String PROP_CONFIG_AREA_DEFAULT = "osgi.configuration.area.default";
  private static final String PROP_BASE_CONFIG_AREA = "osgi.baseConfiguration.area";
  private static final String PROP_SHARED_CONFIG_AREA = "osgi.sharedConfiguration.area";
  private static final String PROP_CONFIG_CASCADED = "osgi.configuration.cascaded";
  protected static final String PROP_FRAMEWORK = "osgi.framework";
  private static final String PROP_SPLASHPATH = "osgi.splashPath";
  private static final String PROP_SPLASHLOCATION = "osgi.splashLocation";
  private static final String PROP_CLASSPATH = "osgi.frameworkClassPath";
  private static final String PROP_EXTENSIONS = "osgi.framework.extensions";
  private static final String PROP_FRAMEWORK_SYSPATH = "osgi.syspath";
  private static final String PROP_FRAMEWORK_SHAPE = "osgi.framework.shape";
  private static final String PROP_LOGFILE = "osgi.logfile";
  private static final String PROP_REQUIRED_JAVA_VERSION = "osgi.requiredJavaVersion";
  private static final String PROP_PARENT_CLASSLOADER = "osgi.parentClassloader";
  private static final String PROP_FRAMEWORK_PARENT_CLASSLOADER = "osgi.frameworkParentClassloader";
  private static final String PROP_NL = "osgi.nl";
  static final String PROP_NOSHUTDOWN = "osgi.noShutdown";
  private static final String PROP_DEBUG = "osgi.debug";
  private static final String PROP_OS = "osgi.os";
  private static final String PROP_WS = "osgi.ws";
  private static final String PROP_ARCH = "osgi.arch";
  private static final String PROP_EXITCODE = "eclipse.exitcode";
  private static final String PROP_EXITDATA = "eclipse.exitdata";
  private static final String PROP_LAUNCHER = "eclipse.launcher";
  private static final String PROP_LAUNCHER_NAME = "eclipse.launcher.name";
  private static final String PROP_VM = "eclipse.vm";
  private static final String PROP_VMARGS = "eclipse.vmargs";
  private static final String PROP_COMMANDS = "eclipse.commands";
  private static final String PROP_ECLIPSESECURITY = "eclipse.security";
  private static final String READ_ONLY_AREA_SUFFIX = ".readOnly";
  private static final String NONE = "@none";
  private static final String NO_DEFAULT = "@noDefault";
  private static final String USER_HOME = "@user.home";
  private static final String USER_DIR = "@user.dir";
  private static final String INSTALL_HASH_PLACEHOLDER = "@install.hash";
  private static final String PARENT_CLASSLOADER_APP = "app";
  private static final String PARENT_CLASSLOADER_EXT = "ext";
  private static final String PARENT_CLASSLOADER_BOOT = "boot";
  private static final String PARENT_CLASSLOADER_CURRENT = "current";
  protected static final String SESSION = "!SESSION";
  protected static final String ENTRY = "!ENTRY";
  protected static final String MESSAGE = "!MESSAGE";
  protected static final String STACK = "!STACK";
  protected static final int ERROR = 4;
  protected static final String PLUGIN_ID = "org.eclipse.equinox.launcher";
  protected File logFile = null;
  protected BufferedWriter log = null;
  protected boolean newSession = true;
  public static final String VARIABLE_DELIM_STRING = "$";
  public static final char VARIABLE_DELIM_CHAR = '$';
  
  static class Identifier
  {
    private static final String DELIM = ". _-";
    private int major;
    private int minor;
    private int service;
    
    Identifier(int major, int minor, int service)
    {
      this.major = major;
      this.minor = minor;
      this.service = service;
    }
    
    Identifier(String versionString)
    {
      StringTokenizer tokenizer = new StringTokenizer(versionString, ". _-");
      if (tokenizer.hasMoreTokens()) {
        major = Integer.parseInt(tokenizer.nextToken());
      }
      if (tokenizer.hasMoreTokens()) {
        minor = Integer.parseInt(tokenizer.nextToken());
      }
      try
      {
        if (tokenizer.hasMoreTokens()) {
          service = Integer.parseInt(tokenizer.nextToken());
        }
      }
      catch (NumberFormatException localNumberFormatException) {}
    }
    
    boolean isGreaterEqualTo(Identifier minimum)
    {
      if (major < major) {
        return false;
      }
      if (major > major) {
        return true;
      }
      if (minor < minor) {
        return false;
      }
      if (minor > minor) {
        return true;
      }
      return service >= service;
    }
  }
  
  private String getWS()
  {
    if (ws != null) {
      return ws;
    }
    String osgiWs = System.getProperty("osgi.ws");
    if (osgiWs != null)
    {
      ws = osgiWs;
      return ws;
    }
    String osName = getOS();
    if (osName.equals("win32")) {
      return "win32";
    }
    if (osName.equals("linux")) {
      return "gtk";
    }
    if (osName.equals("macosx")) {
      return "cocoa";
    }
    if (osName.equals("hpux")) {
      return "motif";
    }
    if (osName.equals("aix")) {
      return "motif";
    }
    if (osName.equals("solaris")) {
      return "gtk";
    }
    if (osName.equals("qnx")) {
      return "photon";
    }
    return "unknown";
  }
  
  private String getAlternateWS(String defaultWS)
  {
    if ("cocoa".equals(defaultWS)) {
      return "carbon";
    }
    if ("gtk".equals(defaultWS)) {
      return "motif";
    }
    if ("win32".equals(defaultWS)) {
      return "wpf";
    }
    return "unknown";
  }
  
  private String getOS()
  {
    if (os != null) {
      return os;
    }
    String osgiOs = System.getProperty("osgi.os");
    if (osgiOs != null)
    {
      os = osgiOs;
      return os;
    }
    String osName = System.getProperties().getProperty("os.name");
    if (osName.regionMatches(true, 0, "win32", 0, 3)) {
      return "win32";
    }
    if (osName.equalsIgnoreCase("SunOS")) {
      return "solaris";
    }
    if (osName.equalsIgnoreCase("Linux")) {
      return "linux";
    }
    if (osName.equalsIgnoreCase("QNX")) {
      return "qnx";
    }
    if (osName.equalsIgnoreCase("AIX")) {
      return "aix";
    }
    if (osName.equalsIgnoreCase("HP-UX")) {
      return "hpux";
    }
    if (osName.equalsIgnoreCase("OS/400")) {
      return "os/400";
    }
    if (osName.equalsIgnoreCase("OS/390")) {
      return "os/390";
    }
    if (osName.equalsIgnoreCase("z/OS")) {
      return "z/os";
    }
    if (osName.regionMatches(true, 0, "Mac OS", 0, "Mac OS".length())) {
      return "macosx";
    }
    return "unknown";
  }
  
  private String getArch()
  {
    if (arch != null) {
      return arch;
    }
    String osgiArch = System.getProperty("osgi.arch");
    if (osgiArch != null)
    {
      arch = osgiArch;
      return arch;
    }
    String name = System.getProperties().getProperty("os.arch");
    if (name.equalsIgnoreCase("i386")) {
      return "x86";
    }
    if (name.equalsIgnoreCase("amd64")) {
      return "x86_64";
    }
    return name;
  }
  
  private String getFragmentString(String fragmentOS, String fragmentWS, String fragmentArch)
  {
    StringBuffer buffer = new StringBuffer("org.eclipse.equinox.launcher");
    buffer.append('.');
    buffer.append(fragmentWS);
    buffer.append('.');
    buffer.append(fragmentOS);
    if ((!fragmentOS.equals("macosx")) || ("x86_64".equals(fragmentArch)))
    {
      buffer.append('.');
      buffer.append(fragmentArch);
    }
    return buffer.toString();
  }
  
  private void setupJNI(URL[] defaultPath)
  {
    String libPath = null;
    if (library != null)
    {
      File lib = new File(library);
      if (lib.isDirectory()) {
        libPath = searchFor("eclipse", lib.getAbsolutePath());
      } else if (lib.exists()) {
        libPath = lib.getAbsolutePath();
      }
    }
    if (libPath == null)
    {
      String fragmentOS = getOS();
      String fragmentWS = getWS();
      String fragmentArch = getArch();
      
      libPath = getLibraryPath(getFragmentString(fragmentOS, fragmentWS, fragmentArch), defaultPath);
      if ((libPath == null) && (ws == null))
      {
        String alternateWS = getAlternateWS(fragmentWS);
        libPath = getLibraryPath(getFragmentString(fragmentOS, alternateWS, fragmentArch), defaultPath);
        if (libPath != null) {
          System.getProperties().put("osgi.ws", alternateWS);
        }
      }
    }
    library = libPath;
    if (library != null) {
      bridge = new JNIBridge(library);
    }
  }
  
  private String getLibraryPath(String fragmentName, URL[] defaultPath)
  {
    String libPath = null;
    String fragment = null;
    if ((inDevelopmentMode) && (devClassPathProps != null))
    {
      String devPathList = devClassPathProps.getProperty("org.eclipse.equinox.launcher");
      String[] locations = getArrayFromList(devPathList);
      if (locations.length > 0)
      {
        File location = new File(locations[0]);
        if (location.isAbsolute())
        {
          String dir = location.getParent();
          fragment = searchFor(fragmentName, dir);
          if (fragment != null) {
            libPath = getLibraryFromFragment(fragment);
          }
        }
      }
    }
    if ((libPath == null) && (bootLocation != null))
    {
      URL[] urls = defaultPath;
      if ((urls != null) && (urls.length > 0)) {
        for (int i = urls.length - 1; (i >= 0) && (libPath == null); i--)
        {
          File entryFile = new File(urls[i].getFile());
          String dir = entryFile.getParent();
          if (inDevelopmentMode)
          {
            String devDir = dir + "/" + "org.eclipse.equinox.launcher" + "/fragments";
            fragment = searchFor(fragmentName, devDir);
          }
          if (fragment == null) {
            fragment = searchFor(fragmentName, dir);
          }
          if (fragment != null) {
            libPath = getLibraryFromFragment(fragment);
          }
        }
      }
    }
    if (libPath == null)
    {
      URL install = getInstallLocation();
      String location = install.getFile();
      location = location + "/plugins/";
      fragment = searchFor(fragmentName, location);
      if (fragment != null) {
        libPath = getLibraryFromFragment(fragment);
      }
    }
    return libPath;
  }
  
  private String getLibraryFromFragment(String fragment)
  {
    if (fragment.startsWith("file:")) {
      fragment = fragment.substring(5);
    }
    File frag = new File(fragment);
    if (!frag.exists()) {
      return null;
    }
    if (frag.isDirectory()) {
      return searchFor("eclipse", fragment);
    }
    ZipFile fragmentJar = null;
    try
    {
      fragmentJar = new ZipFile(frag);
    }
    catch (IOException e)
    {
      log("Exception opening JAR file: " + fragment);
      log(e);
      return null;
    }
    Enumeration entries = fragmentJar.entries();
    String entry = null;
    while (entries.hasMoreElements())
    {
      ZipEntry zipEntry = (ZipEntry)entries.nextElement();
      if (zipEntry.getName().startsWith("eclipse_"))
      {
        entry = zipEntry.getName();
        try
        {
          fragmentJar.close();
        }
        catch (IOException localIOException1) {}
      }
    }
    if (entry != null)
    {
      String lib = extractFromJAR(fragment, entry);
      if (!getOS().equals("win32")) {
        try
        {
          Runtime.getRuntime().exec(new String[] { "chmod", "755", lib }).waitFor();
        }
        catch (Throwable localThrowable) {}
      }
      return lib;
    }
    return null;
  }
  
  protected void basicRun(String[] args)
    throws Exception
  {
    System.getProperties().put("eclipse.startTime", Long.toString(System.currentTimeMillis()));
    commands = args;
    String[] passThruArgs = processCommandLine(args);
    if (!debug) {
      debug = (System.getProperty("osgi.debug") != null);
    }
    setupVMProperties();
    processConfiguration();
    
    getInstallLocation();
    
    URL[] bootPath = getBootPath(bootLocation);
    
    setupJNI(bootPath);
    if (!checkVersion(System.getProperty("java.version"), System.getProperty("osgi.requiredJavaVersion"))) {
      return;
    }
    if (!checkConfigurationLocation(configurationLocation)) {
      return;
    }
    setSecurityPolicy(bootPath);
    
    handleSplash(bootPath);
    
    beforeFwkInvocation();
    invokeFramework(passThruArgs, bootPath);
  }
  
  protected void beforeFwkInvocation() {}
  
  protected void setSecurityPolicy(URL[] bootPath)
  {
    String eclipseSecurity = System.getProperty("eclipse.security");
    if (eclipseSecurity != null)
    {
      ProtectionDomain domain = Main.class.getProtectionDomain();
      CodeSource source = null;
      if (domain != null) {
        source = Main.class.getProtectionDomain().getCodeSource();
      }
      if ((domain == null) || (source == null))
      {
        log("Can not automatically set the security manager. Please use a policy file.");
        return;
      }
      URL[] rootURLs = new URL[bootPath.length + 1];
      rootURLs[0] = source.getLocation();
      System.arraycopy(bootPath, 0, rootURLs, 1, bootPath.length);
      
      Policy eclipsePolicy = new EclipsePolicy(Policy.getPolicy(), rootURLs);
      Policy.setPolicy(eclipsePolicy);
    }
  }
  
  private void invokeFramework(String[] passThruArgs, URL[] bootPath)
    throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, Error, Exception, InvocationTargetException
  {
    String type = System.getProperty("osgi.frameworkParentClassloader", System.getProperty("osgi.parentClassloader", "boot"));
    ClassLoader parent = null;
    if ("app".equalsIgnoreCase(type))
    {
      parent = ClassLoader.getSystemClassLoader();
    }
    else if ("ext".equalsIgnoreCase(type))
    {
      ClassLoader appCL = ClassLoader.getSystemClassLoader();
      if (appCL != null) {
        parent = appCL.getParent();
      }
    }
    else if ("current".equalsIgnoreCase(type))
    {
      parent = getClass().getClassLoader();
    }
    URLClassLoader loader = new StartupClassLoader(bootPath, parent);
    Class clazz = loader.loadClass("org.eclipse.core.runtime.adaptor.EclipseStarter");
    Method method = clazz.getDeclaredMethod("run", new Class[] { String[].class, Runnable.class });
    try
    {
      method.invoke(clazz, new Object[] { passThruArgs, splashHandler });
    }
    catch (InvocationTargetException e)
    {
      if ((e.getTargetException() instanceof Error)) {
        throw ((Error)e.getTargetException());
      }
      if ((e.getTargetException() instanceof Exception)) {
        throw ((Exception)e.getTargetException());
      }
      throw e;
    }
  }
  
  private boolean checkVersion(String availableVersion, String requiredVersion)
  {
    if ((requiredVersion == null) || (availableVersion == null)) {
      return true;
    }
    try
    {
      Identifier required = new Identifier(requiredVersion);
      Identifier available = new Identifier(availableVersion);
      boolean compatible = available.isGreaterEqualTo(required);
      if (!compatible)
      {
        System.getProperties().put("eclipse.exitcode", "14");
        System.getProperties().put("eclipse.exitdata", "<title>Incompatible JVM</title>Version " + availableVersion + " of the JVM is not suitable for this product. Version: " + requiredVersion + " or greater is required.");
      }
      return compatible;
    }
    catch (SecurityException localSecurityException)
    {
      return true;
    }
    catch (NumberFormatException localNumberFormatException) {}
    return true;
  }
  
  private boolean checkConfigurationLocation(URL locationUrl)
  {
    if ((locationUrl == null) || (!"file".equals(locationUrl.getProtocol()))) {
      return true;
    }
    if (Boolean.valueOf(System.getProperty("osgi.configuration.area.readOnly")).booleanValue()) {
      return true;
    }
    File configDir = new File(locationUrl.getFile()).getAbsoluteFile();
    if (!configDir.exists())
    {
      configDir.mkdirs();
      if (!configDir.exists())
      {
        System.getProperties().put("eclipse.exitcode", "15");
        System.getProperties().put("eclipse.exitdata", "<title>Invalid Configuration Location</title>The configuration area at '" + configDir + 
          "' could not be created.  Please choose a writable location using the '-configuration' command line option.");
        return false;
      }
    }
    if (!canWrite(configDir))
    {
      System.getProperties().put("eclipse.exitcode", "15");
      System.getProperties().put("eclipse.exitdata", "<title>Invalid Configuration Location</title>The configuration area at '" + configDir + 
        "' is not writable.  Please choose a writable location using the '-configuration' command line option.");
      return false;
    }
    return true;
  }
  
  protected String decode(String urlString)
  {
    try
    {
      Class clazz = URLDecoder.class;
      Method method = clazz.getDeclaredMethod("decode", new Class[] { String.class, String.class });
      if (urlString.indexOf('+') >= 0)
      {
        int len = urlString.length();
        StringBuffer buf = new StringBuffer(len);
        for (int i = 0; i < len; i++)
        {
          char c = urlString.charAt(i);
          if (c == '+') {
            buf.append("%2B");
          } else {
            buf.append(c);
          }
        }
        urlString = buf.toString();
      }
      Object result = method.invoke(null, new Object[] { urlString, "UTF-8" });
      if (result != null) {
        return (String)result;
      }
    }
    catch (Exception localException)
    {
      boolean replaced = false;
      byte[] encodedBytes = urlString.getBytes();
      int encodedLength = encodedBytes.length;
      byte[] decodedBytes = new byte[encodedLength];
      int decodedLength = 0;
      for (int i = 0; i < encodedLength; i++)
      {
        byte b = encodedBytes[i];
        if (b == 37)
        {
          if (i + 2 >= encodedLength) {
            throw new IllegalArgumentException("Malformed URL (\"" + urlString + "\"): % must be followed by 2 digits.");
          }
          byte enc1 = encodedBytes[(++i)];
          byte enc2 = encodedBytes[(++i)];
          b = (byte)((hexToByte(enc1) << 4) + hexToByte(enc2));
          replaced = true;
        }
        decodedBytes[(decodedLength++)] = b;
      }
      if (!replaced) {
        return urlString;
      }
      try
      {
        return new String(decodedBytes, 0, decodedLength, "UTF-8");
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
      return new String(decodedBytes, 0, decodedLength);
    }
  }
  
  protected String[] getArrayFromList(String prop)
  {
    if ((prop == null) || (prop.trim().equals(""))) {
      return new String[0];
    }
    Vector list = new Vector();
    StringTokenizer tokens = new StringTokenizer(prop, ",");
    while (tokens.hasMoreTokens())
    {
      String token = tokens.nextToken().trim();
      if (!token.equals("")) {
        list.addElement(token);
      }
    }
    return list.isEmpty() ? new String[0] : (String[])list.toArray(new String[list.size()]);
  }
  
  private URL[] getDevPath(URL base)
    throws IOException
  {
    ArrayList result = new ArrayList(5);
    if (inDevelopmentMode) {
      addDevEntries(base, result, "org.eclipse.osgi");
    }
    addBaseJars(base, result);
    return (URL[])result.toArray(new URL[result.size()]);
  }
  
  URL constructURL(URL url, String name)
  {
    String externalForm = url.toExternalForm();
    if (externalForm.endsWith(".jar")) {
      try
      {
        return new URL("jar:" + url + "!/" + name);
      }
      catch (MalformedURLException localMalformedURLException1) {}
    }
    try
    {
      return new URL(url, name);
    }
    catch (MalformedURLException localMalformedURLException2) {}
    return null;
  }
  
  private void readFrameworkExtensions(URL base, ArrayList result)
    throws IOException
  {
    String[] extensions = getArrayFromList(System.getProperties().getProperty("osgi.framework.extensions"));
    String parent = new File(base.getFile()).getParent().toString();
    ArrayList extensionResults = new ArrayList(extensions.length);
    for (int i = 0; i < extensions.length; i++)
    {
      String path = searchForBundle(extensions[i], parent);
      if (path == null)
      {
        log("Could not find extension: " + extensions[i]);
      }
      else
      {
        if (debug) {
          System.out.println("Loading extension: " + extensions[i]);
        }
        URL extensionURL = null;
        if (installLocation.getProtocol().equals("file"))
        {
          extensionResults.add(path);
          extensionURL = new File(path).toURL();
        }
        else
        {
          extensionURL = new URL(installLocation.getProtocol(), installLocation.getHost(), installLocation.getPort(), path);
        }
        Properties extensionProperties = null;
        try
        {
          extensionProperties = loadProperties(constructURL(extensionURL, "eclipse.properties"));
        }
        catch (IOException localIOException)
        {
          if (debug) {
            System.out.println("\teclipse.properties not found");
          }
        }
        String extensionClassPath = null;
        if (extensionProperties != null) {
          extensionClassPath = extensionProperties.getProperty("osgi.frameworkClassPath");
        } else {
          extensionProperties = new Properties();
        }
        String[] entries = (extensionClassPath == null) || (extensionClassPath.length() == 0) ? new String[] { "" } : getArrayFromList(extensionClassPath);
        String qualifiedPath;
        String qualifiedPath;
        if (System.getProperty("osgi.frameworkClassPath") == null) {
          qualifiedPath = ".";
        } else {
          qualifiedPath = "";
        }
        for (int j = 0; j < entries.length; j++) {
          qualifiedPath = qualifiedPath + ", file:" + path + entries[j];
        }
        extensionProperties.put("osgi.frameworkClassPath", qualifiedPath);
        mergeProperties(System.getProperties(), extensionProperties, null);
        if (inDevelopmentMode)
        {
          String name = extensions[i];
          if (name.startsWith("reference:")) {
            name = new File(path).getName();
          }
          addDevEntries(extensionURL, result, name);
        }
      }
    }
    extensionPaths = ((String[])extensionResults.toArray(new String[extensionResults.size()]));
  }
  
  private void addBaseJars(URL base, Array
1 2 3 4

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