コード例 #1
0
ファイル: Main.java プロジェクト: ratnikov/jruby
  /** Print a nicer stack size error since Rubyists aren't used to seeing this. */
  private Status handleStackOverflow(StackOverflowError soe) {
    String memoryMax = getRuntimeFlagValue("-Xss");

    if (memoryMax != null) {
      config
          .getError()
          .println(
              "Error: Your application used more stack memory than the safety cap of "
                  + memoryMax
                  + ".");
    } else {
      config
          .getError()
          .println("Error: Your application used more stack memory than the default safety cap.");
    }
    config.getError().println("Specify -J-Xss####k to increase it (#### = cap size in KB).");

    if (config.isVerbose()) {
      config.getError().println("Exception trace follows:");
      soe.printStackTrace(config.getError());
    } else {
      config.getError().println("Specify -w for full StackOverflowError stack trace");
    }

    return new Status(1);
  }
コード例 #2
0
ファイル: Main.java プロジェクト: rebx/jruby
 private Status handleStackOverflow(StackOverflowError soe) {
   // produce a nicer error since Rubyists aren't used to seeing this
   System.gc();
   String stackMax = SafePropertyAccessor.getProperty("jruby.stack.max");
   String message = "";
   if (stackMax != null) {
     message = " of " + stackMax;
   }
   config
       .getError()
       .println(
           "Error: Your application used more stack memory than the safety cap" + message + ".");
   config.getError().println("Specify -J-Xss####k to increase it (#### = cap size in KB).");
   if (config.isVerbose()) {
     config.getError().println("Exception trace follows:");
     soe.printStackTrace();
   } else {
     config.getError().println("Specify -w for full StackOverflowError stack trace");
   }
   return new Status(1);
 }
コード例 #3
0
ファイル: Main.java プロジェクト: aslakhellesoy/jruby
  public int run(String[] args) {
    try {
      config.processArguments(args);
      return run();
    } catch (MainExitException mee) {
      if (!mee.isAborted()) {
        config.getOutput().println(mee.getMessage());
        if (mee.isUsageError()) {
          printUsage();
        }
      }
      return mee.getStatus();
    } catch (OutOfMemoryError oome) {
      // produce a nicer error since Rubyists aren't used to seeing this
      System.gc();

      String memoryMax = SafePropertyAccessor.getProperty("jruby.memory.max");
      String message = "";
      if (memoryMax != null) {
        message = " of " + memoryMax;
      }
      config
          .getError()
          .println("Error: Your application used more memory than the safety cap" + message + ".");
      config.getError().println("Specify -J-Xmx####m to increase it (#### = cap size in MB).");

      if (config.getVerbose()) {
        config.getError().println("Exception trace follows:");
        oome.printStackTrace();
      } else {
        config.getError().println("Specify -w for full OutOfMemoryError stack trace");
      }
      return 1;
    } catch (StackOverflowError soe) {
      // produce a nicer error since Rubyists aren't used to seeing this
      System.gc();

      String stackMax = SafePropertyAccessor.getProperty("jruby.stack.max");
      String message = "";
      if (stackMax != null) {
        message = " of " + stackMax;
      }
      config
          .getError()
          .println(
              "Error: Your application used more stack memory than the safety cap" + message + ".");
      config.getError().println("Specify -J-Xss####k to increase it (#### = cap size in KB).");

      if (config.getVerbose()) {
        config.getError().println("Exception trace follows:");
        soe.printStackTrace();
      } else {
        config.getError().println("Specify -w for full StackOverflowError stack trace");
      }
      return 1;
    } catch (UnsupportedClassVersionError ucve) {
      config
          .getError()
          .println("Error: Some library (perhaps JRuby) was built with a later JVM version.");
      config
          .getError()
          .println(
              "Please use libraries built with the version you intend to use or an earlier one.");

      if (config.getVerbose()) {
        config.getError().println("Exception trace follows:");
        ucve.printStackTrace();
      } else {
        config.getError().println("Specify -w for full UnsupportedClassVersionError stack trace");
      }
      return 1;
    } catch (ThreadKill kill) {
      return 0;
    }
  }
コード例 #4
0
  // http://dev.eclipse.org/bugs/show_bug.cgi?id=27658
  public void testObjectWithSuperInterfaces() throws JavaModelException {
    try {
      IPath projectPath = env.addProject("Project"); // $NON-NLS-1$
      env.addExternalJars(projectPath, Util.getJavaClassLibs());

      // remove old package fragment root so that names don't collide
      env.removePackageFragmentRoot(projectPath, ""); // $NON-NLS-1$

      IPath root = env.addPackageFragmentRoot(projectPath, "src"); // $NON-NLS-1$
      env.setOutputFolder(projectPath, "bin"); // $NON-NLS-1$

      env.addClass(
          root,
          "java.lang",
          "Object", //$NON-NLS-1$ //$NON-NLS-2$
          "package java.lang; \n"
              + //$NON-NLS-1$
              "public class Object implements I {} \n"
              + //$NON-NLS-1$
              "interface I {}	\n"); //$NON-NLS-1$

      fullBuild(projectPath);

      expectingOnlySpecificProblemsFor(
          root,
          new Problem[] {
            new Problem(
                "",
                "The type java.lang.Object cannot have a superclass or superinterfaces",
                new Path("/Project/src/java/lang/Object.java"),
                33,
                39,
                CategorizedProblem.CAT_INTERNAL,
                IMarker.SEVERITY_ERROR), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$		
          });

      env.addClass(
          root,
          "p",
          "X", //$NON-NLS-1$ //$NON-NLS-2$
          "package p; \n"
              + //$NON-NLS-1$
              "public class X {}\n"); //$NON-NLS-1$

      incrementalBuild(projectPath);

      expectingOnlySpecificProblemsFor(
          root,
          new Problem[] {
            new Problem(
                "",
                "The type java.lang.Object cannot have a superclass or superinterfaces",
                new Path("/Project/src/java/lang/Object.java"),
                33,
                39,
                CategorizedProblem.CAT_INTERNAL,
                IMarker.SEVERITY_ERROR), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$		
          });

      env.addClass(
          root,
          "p",
          "Y", //$NON-NLS-1$ //$NON-NLS-2$
          "package p; \n"
              + //$NON-NLS-1$
              "public class Y extends X {}\n"); //$NON-NLS-1$

      incrementalBuild(projectPath);

      expectingOnlySpecificProblemsFor(
          root,
          new Problem[] {
            new Problem(
                "",
                "The type java.lang.Object cannot have a superclass or superinterfaces",
                new Path("/Project/src/java/lang/Object.java"),
                33,
                39,
                CategorizedProblem.CAT_INTERNAL,
                IMarker.SEVERITY_ERROR), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$		
          });

    } catch (StackOverflowError e) {
      assertTrue("Infinite loop in cycle detection", false); // $NON-NLS-1$
      e.printStackTrace();
    }
  }