Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1395

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.0-JSR-6
    • None
    • 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.

      Attachments

        1. GroovyEclipse.patch
          9 kB
          Paul King

        Activity

          People

            jshickey Scott Hickey
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: