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

Error messages when a depended on class is not found are not very informative

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.0-JSR-3
    • 1.0-JSR-6
    • None
    • None
    • groovy jsr03, jdk 142_09

    Description

      When using a class that depends on another class that is not available, e.g. like this:

      myjar1.jar : contains foo.MyClass1, which depends on bar.MyClass2
      myjar2.jar : contains bar.MyClass2

      A method in MyClass1:
      public MyClass2 amethod(MyClass2 arg) { //...

      and only myjar1.jar is on the classpath.

      Now, if you do:
      def cls = Class.forName('foo.MyClass1')
      def m = cls.methods

      you get:

      Caught: groovy.lang.GroovyRuntimeException: Cannot read property: methods

      which is not very informative. The property "methods" exists (i.e. the method getMethods()).

      A simple improvement would be to tell what exception caused the reading of the given property to fail. At the moment getCause() on the thrown GroovyRuntimeException returns null.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            antti.karanta@napa.fi Antti Karanta
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: