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

I am unable to instantiate objects using the "new" keyword

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.0-beta-3
    • Fix Version/s: 2.4.0-rc-1
    • Component/s: Groovysh
    • Labels:
      None
    • Environment:
      Linux - Debian jessie/sid 64 bits

      Description

      I am embedding Groovysh in a java application. After some tests, I realized that the "new" keyword seems to not work in the last groovysh version. When I try to do:
      a = new A()
      I obtain: "unable to resolve class A"

      This is an example:

      groovy:000> class A {
      class A {
      groovy:001> public A() {
      public A()

      { groovy:002> name = "default" name = "default" groovy:003> }

      }
      groovy:004> String name;
      String name;
      groovy:005> }
      }
      ===> true
      groovy:000> a = new A()
      a = new A()
      ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException:
      startup failed:
      script14159599676571305654112.groovy: 1: unable to resolve class A
      @ line 1, column 5.
      a = new A()
      ^

      1 error

      However, if I use the newInstance method it works:
      groovy:000> a = A.newInstance()
      a = A.newInstance()
      ===> A@2154cecb

      I tested the same code in the previous version (2.3.7) and it works

        Attachments

        1. testA.groovy
          0.1 kB
          Hector Satizabal

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                itzkha Hector Satizabal
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: