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

@Compile static Sql.newInstance

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1, 2.1.0-beta-1
    • Static compilation
    • None
    • Windows 7 x64, Java 7 x64

    Description

      Don't know if this bug has been reported before (didn't find anything while looking)

      @CompileStatic
      class M
      {
      	public void r()
      	{
      	     Sql sql = Sql.newInstance("jdbc:mysql://localhost/dummy", "dummy", "dummy", "com.mysql.jdbc.Driver")
      	}
      }
      
      (new M()).r()
      

      fails with

      Caught: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: groovy.sql.Sql(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
      groovy.lang.GroovyRuntimeException: Could not find matching constructor for: groovy.sql.Sql(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
      	at M.r(Test2.groovy:11)
      	at M$r.call(Unknown Source)
      	at Test2.run(Test2.groovy:18)
      

      Looks like DefaultGroovyMethods.newInstance get's called instead.

      Removing @CompileStatic fixes the problem

      Attachments

        Issue Links

          Activity

            People

              guillaume Guillaume Sauthier
              gordon277 Gordon Brown
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: