Пример #1
0
  private void printInfo() {
    if (debug) {; // System.out.println("/n/n");

      Vector vThere = (Vector) ReflectionTools.illegalGetObject(deferTo, "classes");
      ; // System.out.println("local: " + loader.already);

      for (int i = 0; i < vThere.size(); i++) ; // System.out.println("global:" + vThere.get(i)
      // + " " +
      // loader.already.containsValue(vThere.get(i)));
    }
  }
Пример #2
0
 protected boolean check() {
   // if (!debug)
   if (true) return true;
   Vector vThere = (Vector) ReflectionTools.illegalGetObject(deferTo, "classes");
   for (int i = 0; i < vThere.size(); i++) {
     String s = ((Class) vThere.get(i)).getName();
     boolean failed = !shouldLoadLocal(s);
     if (!failed) {; // System.out.println("illegally loaded class <"
       // + s + "> <" + vThere + ">");
       System.exit(1);
     }
   }
   return true;
 }
Пример #3
0
    public Set<Class> getAllLoadedClasses() {
      try {
        HashSet<Class> al = new HashSet<Class>();
        al.addAll(previous.values());
        al.addAll(already.values());

        Vector vThere = (Vector) ReflectionTools.illegalGetObject(deferTo, "classes");
        al.addAll(vThere);
        return al;
      } catch (ConcurrentModificationException e) {
        try {
          Thread.sleep(1);
        } catch (InterruptedException e1) {
          e1.printStackTrace();
        }
        return getAllLoadedClasses();
      }
    }
Пример #4
0
  public void launch() {
    System.out.println(
        "## trampoline <" + this.getClass() + ":" + this.getClass().getClassLoader() + ">");
    trampoline = this;

    String exceptions = SystemProperties.getProperty("trampolineExceptions", null);
    ignored =
        new String[] {
          "apple.",
          "java.",
          "javax.",
          "sun.",
          "com.apple",
          "apple.",
          "field.namespace",
          "field.math",
          "field.launch.",
          "org.objectweb",
          "com.sun",
          "org.xml",
          "org.w3c",
          "$Prox",
          "org.eclipse",
          "main",
          "field.util.BetterWeak",
          "field.misc.ANSIColorUtils",
          "ch.rand",
          "org.python",
          "org.apache.batik",
          "org.antlr",
          "field.util.TaskQueue",
          "com.lowagie",
          "net.sf.cglib.proxy",
          "com.seaglasslookandfeel",
          "org.pushingpixels",
          "net.sourceforge.napkinlaf.",
          "com.kenai.jaffl"
        };
    allowed =
        new String[] {
          "phobos",
          "com.sun.script.",
          "com.sun.scenario",
          "com.sun.stylesheet",
          "com.sun.opengl",
          "com.sun.gluegen",
          "javax.media.opengl",
          "javax.media.nativewindow",
          "javax.jmdns"
        };

    if (exceptions != null) {

      ArrayList a = new ArrayList(Arrays.asList(ignored));
      a.addAll(Arrays.asList(exceptions.split(":")));
      ignored = (String[]) a.toArray(ignored);
    }

    loader =
        new MyClassLoader(
            ((URLClassLoader) this.getClass().getClassLoader()).getURLs(),
            (this.getClass().getClassLoader()));
    System.setSecurityManager(new PermissiveSecurityManager());

    String extendedJars = SystemProperties.getProperty("extendedJars", null);
    if (extendedJars != null) {
      String[] ex = extendedJars.split(":");
      for (String e : ex) {; // System.out.println(" adding jar <" + e +
        // ">");
        addJar(e);
      }
    }

    Vector v =
        (Vector) ReflectionTools.illegalGetObject(this.getClass().getClassLoader(), "classes");
    if (debug) ; // System.out.println(" already loaded all of <" + v +
    // ">");

    if (!System.getProperty("asserts", "none").equals("none"))
      loader.setDefaultAssertionStatus(true);

    Thread.currentThread().setContextClassLoader(loader);

    String extensionsDir = SystemProperties.getProperty("extensions.dir", "../../extensions/");
    Trampoline2.trampoline.addExtensionsDirectory(new File(extensionsDir));
    String extensionsDir2 =
        System.getProperty("user.home") + "/Library/Application Support/Field/extensions";

    if (!new File(extensionsDir2).exists()) new File(extensionsDir2).mkdirs();

    if (new File(extensionsDir2).exists())
      Trampoline2.trampoline.addExtensionsDirectory(new File(extensionsDir2));

    try {; // System.out.println(Arrays.asList(loader.getURLs()));
      final Class c = (loader.loadClass(classToLaunch));
      ; // System.out.println(" c = " + c + " " +
      // c.getClassLoader() + " " + loader);
      try {
        Method main = c.getDeclaredMethod("main", new Class[] {new String[0].getClass()});
        try {
          main.invoke(null, new Object[] {null});
          return;
        } catch (IllegalArgumentException e) {
          e.printStackTrace();
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        } catch (InvocationTargetException e) {
          e.printStackTrace();
        }
        return;
      } catch (SecurityException e) {
        e.printStackTrace();
        return;
      } catch (NoSuchMethodException e) {
      }

      Launcher.getLauncher().mainThread = Thread.currentThread();
      printInfo();
      Launcher.mainInstance = (iLaunchable) c.newInstance();
      printInfo();
      Launcher.mainInstance.launch();
      printInfo();
      printInfo();

    } catch (Throwable e) {
      e.printStackTrace();
      if (SystemProperties.getIntProperty("exitOnException", 0) == 1
          || e instanceof Error
          || e.getCause() instanceof Error) System.exit(1);
    }

    if (SystemProperties.getIntProperty("nosave", 0) == 1)
      System.setSecurityManager(new NoWriteSecurityManager());
    else if (SystemProperties.getIntProperty("collectResources", 0) == 1)
      System.setSecurityManager(new CollectResourcesSecurityManager());
    else System.setSecurityManager(new NoopSecurityManager());
  }