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

CompileStatic selects wrong constructor when GString is a parameter

    Details

      Description

      This JavaFX program runs fine on Java 8:

      //@CompileStatic
      class ImageCompStatic
      {
        public static void main(String[] args)
        {
          PlatformImpl.startup({})   // quick hack to start up the JavaFX runtime
          String path = "image.png"
          Image img = new Image("$path")
          println img.height
        }
      }
      

      If CompileStatic is not commented out, you get the following error at run time:
      Exception in thread "main" java.lang.IllegalAccessError: tried to access method javafx.scene.image.Image.<init>(Ljava/lang/Object;)V from class ImageCompStatic

      CompileStatic seems to change the selected constructor from the correct one:

      public Image(String)
      

      to the wrong one:

      private Image(Object)
      

      Changing the constructor invocation to:

          Image img = new Image("$path" as String)
      

      also works.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                daniel_sun Daniel Sun
                Reporter:
                ngalarneau Neil Galarneau
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: