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

Problem when accessing arrays of arrays from groovy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-2
    • 1.0-JSR-5
    • None
    • Windows, Java 1.5.0_03

    Description

      If I create a Java class which contains a field declared as:

      int[][] x;

      then pass an object to groovy and ask it to execute:

      println (the object).x[0]

      it throws:

      Exception in thread "main" java.lang.ClassFormatError: Illegal class name "gjdk/[I_GroovyReflectorArray" in class file gjdk/[I_GroovyReflectorArray

      Printing just (the object).x works fine.

      The full code which reproduces this error is:

      bug4.groovy:
      class bug4 {
      def bubbles(a)

      { println a.x[0]; }

      }

      bug4j.java:
      import groovy.lang.*;

      import java.io.*;

      import org.codehaus.groovy.control.CompilationFailedException;

      public class bug4j {
      public int[][] x;

      void ricky() throws CompilationFailedException, InstantiationException,
      IOException, IllegalAccessException {
      x = new int[][]

      {new int[5], new int[4], new int[3]}

      ;

      // Create the groovy object
      ClassLoader parent = getClass().getClassLoader();
      GroovyClassLoader loader = new GroovyClassLoader(parent);
      Class groovyClass = loader.parseClass(new File("bug4.groovy"));
      GroovyObject bug4 = (GroovyObject) groovyClass.newInstance();

      Object[] args =

      {this}

      ;
      bug4.invokeMethod("bubbles", args);
      }

      public static void main(String[] args) throws CompilationFailedException,
      InstantiationException, IOException, IllegalAccessException

      { (new bug4j()).ricky(); }

      }

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              mcspanky Martin C. Martin
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: