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

Cannot extend a Java inner class with a Map

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.5.6
    • Fix Version/s: None
    • Component/s: parser
    • Labels:
      None

      Description

      For example

      public class Outer {
      public class Inner {
      public String debug()

      { return "inner debug"; }

      }
      }

      The following won't compile:
      def outerinner = ['debug':

      {return "overridden debug"}] as Outer.Inner
      println outerinner .debug()

      Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Error casting map to TestInner$Inner, Reason: Error creating proxy: startup failed, Script1.groovy: 1: unexpected token: $ @ line 1, column 12.

      Tried to use:
      import Outer.Inner as MyInner;
      def outerinner = ['debug':{return "overridden debug"}

      ] as MyInner

      import Outer.Inner;
      def outerinner = ['debug':

      {return "overridden debug"}

      ] as Inner

      both do not work.

      Reference:
      http://www.nabble.com/Cannot-use-Map-to-"extend"-a-Java-inner-class-td19801928.html

        Attachments

          Activity

            People

            • Assignee:
              blackdrag Jochen Theodorou
              Reporter:
              mingfai Mingfai Ma
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: