Groovy
  1. Groovy
  2. GROOVY-1395

GroovyEclipse RunAs Groovy doesn't check for a main method with the wrong kind of arguments

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-6
    • Fix Version/s: 1.0-JSR-6
    • Component/s: None
    • Labels:
      None

      Description

      GroovyEclipse tries to run:

      class MyClass {
      static void main()

      { println "I am running" }

      }

      And then fails with:
      java.lang.NoSuchMethodError: main
      Exception in thread "main"

      Both the commandline and GroovyJ have a more meaningful message:
      Caught: groovy.lang.GroovyRuntimeException: This script or class could not be run.
      It should either:

      • have a main method,
      • be a class extending GroovyTestCase,
      • or implement the Runnable interface.

      GroovyJ also lets you select this class as a runnable class when
      setting up a run configuration. This class should be weeded out of
      the list of available classes.

      The main reason behind this is that EclipsePlugin is doing a partial
      check look for main and then static (and currently also incorrectly void - See Groovy-1394)
      but doesn't check for Object[] args.

        Activity

        paulk@asert.com.au created issue -
        Hide
        Paul King added a comment -

        Combined patch for Groovy-1391 through Groovy-1395.
        Will require someone to check as this is my first eclipse plugin patch.

        Show
        Paul King added a comment - Combined patch for Groovy-1391 through Groovy-1395. Will require someone to check as this is my first eclipse plugin patch.
        Paul King made changes -
        Field Original Value New Value
        Attachment GroovyEclipse.patch [ 21298 ]
        Scott Hickey made changes -
        Assignee Guillaume Laforge [ guillaume ] Scott Hickey [ jshickey ]
        Hide
        Scott Hickey added a comment -

        applied patch and added the code back in to check for return type of void. As best I can tell, it appears that the Eclipse VM launcher expects void as the return type or it sends back the error. It's not apparent to me how we can work around this within the Eclipse framework, unless we launch a groovy shell which invokes main of the class specified, instead of launching the class directly. I'm neutral on whether this is good idea or not.

        It's good to be constistent with the command line behavior, but I'm not sure that I like how it wouldn't be obvious whether I'm directly invoking main() on the generated class or ask a wrapper class to instantiate and invoke it for me.

        Show
        Scott Hickey added a comment - applied patch and added the code back in to check for return type of void. As best I can tell, it appears that the Eclipse VM launcher expects void as the return type or it sends back the error. It's not apparent to me how we can work around this within the Eclipse framework, unless we launch a groovy shell which invokes main of the class specified, instead of launching the class directly. I'm neutral on whether this is good idea or not. It's good to be constistent with the command line behavior, but I'm not sure that I like how it wouldn't be obvious whether I'm directly invoking main() on the generated class or ask a wrapper class to instantiate and invoke it for me.
        Scott Hickey made changes -
        Fix Version/s 1.0-JSR-6 [ 12103 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        Paul King added a comment -

        Previous comment copied back to 1394 since it is mostly related to that issue. (Due to my lazy combined patch)

        Show
        Paul King added a comment - Previous comment copied back to 1394 since it is mostly related to that issue. (Due to my lazy combined patch)
        Hide
        Paul King added a comment -

        Works for me. Thanks.

        Show
        Paul King added a comment - Works for me. Thanks.
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Jochen Theodorou made changes -
        Component/s eclipse-plugin [ 10635 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12730534 ] Default workflow, editable Closed status [ 12742503 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12972568 ] Default workflow, editable Closed status [ 12980409 ]
        Mark Thomas made changes -
        Reporter Paul King [ paulk@asert.com.au ] Paul King [ paulk ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        4d 14h 46m 1 Scott Hickey 06/Jul/06 14:05
        Resolved Resolved Closed Closed
        15h 38m 1 Paul King 07/Jul/06 05:43

          People

          • Assignee:
            Scott Hickey
            Reporter:
            Paul King
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development