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

Calling intValue on a bound variable fails with java.lang.IncompatibleClassChangeError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-JSR-6
    • None
    • None
    • any java platform

    Description

      How does one call methods on variables passed via a Binding object? The following simple example where y is a variable passed in Binding object and is an Integer object fails to run in the script line "foo"

      //-----------------------------java code-----------------------------
      package groovytest;

      import groovy.lang.Binding;
      import groovy.lang.GroovyShell;
      import groovy.lang.Script;
      import java.util.HashMap;

      public class GroovyJavaInterOpTest {
      final static int NUMRUNNERS = 2;
      static String scrStr1 =
      "def foo\n" +
      "

      {\n" + " println x;\n" + "}

      \n" +
      "foo\n" +
      "";
      public static void main(String[] args) throws Exception

      { GroovyShell gr = new GroovyShell(); Script sc = gr.parse(scrStr1); HashMap map = new HashMap(); map.put("y", new Integer(4)); sc.setBinding(new Binding(map)); sc.run(); }

      }
      //----------------------------end-java-code---------------------------------

      Attachments

        1. GroovyJavaInterOpTest.java
          0.7 kB
          S Vinayaka

        Activity

          People

            guillaume Guillaume Sauthier
            svinayak S Vinayaka
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: