Groovy
  1. Groovy
  2. GROOVY-2801

Override toString in coerced Map fails for interfaces but is ok for concrete classes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Component/s: None
    • Labels:
      None
    1. 2801Patch.txt
      0.6 kB
      Roshan Dawrani

      Issue Links

        Activity

        Maurice Nicholson created issue -
        Jochen Theodorou made changes -
        Field Original Value New Value
        Fix Version/s 1.6-beta-2 [ 14261 ]
        Fix Version/s 1.5.7 [ 14242 ]
        Guillaume Delcroix made changes -
        Fix Version/s 1.5.8 [ 14630 ]
        Fix Version/s 1.5.7 [ 14242 ]
        Fix Version/s 1.6-beta-2 [ 14261 ]
        Hide
        Roshan Dawrani added a comment -

        Currently, the delegate for the proxy created, when a map of closures is coerced into an interface, treats methods of java.lang.Object class a little differently. Such methods are not relayed to the map of closures that is being coerced. Instead they are called on the proxy delegate itself.

        If toString() is to be excused from this behavior, the attached patch can probably be used for it (for 1.5.8).

        rgds,
        Roshan

        Show
        Roshan Dawrani added a comment - Currently, the delegate for the proxy created, when a map of closures is coerced into an interface, treats methods of java.lang.Object class a little differently. Such methods are not relayed to the map of closures that is being coerced. Instead they are called on the proxy delegate itself. If toString() is to be excused from this behavior, the attached patch can probably be used for it (for 1.5.8). rgds, Roshan
        Roshan Dawrani made changes -
        Attachment 2801Patch.txt [ 37600 ]
        Hide
        Roshan Dawrani added a comment -

        Hi,
        Wanted to check if I can go ahead with the solution suggested in the previous comment.

        Currently, the way "mapOfClosures as AnInterface" works is that, if it receives a call to the method that is present on java.lang.Object, the implementation provided in mapOfClosures is not used.

        If overriding of toString() is to be allowed, while checking if can handle toString() a little differently from other methods of java.lang.Object so that it is dispatched to mapOfClosures.

        Show
        Roshan Dawrani added a comment - Hi, Wanted to check if I can go ahead with the solution suggested in the previous comment. Currently, the way "mapOfClosures as AnInterface" works is that, if it receives a call to the method that is present on java.lang.Object, the implementation provided in mapOfClosures is not used. If overriding of toString() is to be allowed, while checking if can handle toString() a little differently from other methods of java.lang.Object so that it is dispatched to mapOfClosures.
        Hide
        Jochen Theodorou added a comment -

        sounds reasonable to me... in fact I don't remember why we checked for methods declared on Object

        Show
        Jochen Theodorou added a comment - sounds reasonable to me... in fact I don't remember why we checked for methods declared on Object
        Paul King made changes -
        Link This issue is related to GROOVY-2599 [ GROOVY-2599 ]
        Hide
        Paul King added a comment -

        Linking another toString() issue. Probably solved by different changes but we should think about consistency between them.

        Show
        Paul King added a comment - Linking another toString() issue. Probably solved by different changes but we should think about consistency between them.
        Roshan Dawrani made changes -
        Assignee Roshan Dawrani [ roshandawrani ]
        Hide
        Roshan Dawrani added a comment -

        Fixed. Now allows overriding toString() in a 'map-of-closures as AnInterface' implementation.

        Show
        Roshan Dawrani added a comment - Fixed. Now allows overriding toString() in a 'map-of-closures as AnInterface' implementation.
        Roshan Dawrani made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Fix Version/s 1.6-rc-1 [ 14009 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12731823 ] Default workflow, editable Closed status [ 12743655 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12969784 ] Default workflow, editable Closed status [ 12977523 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        227d 7h 42m 1 Roshan Dawrani 15/Dec/08 20:45
        Resolved Resolved Closed Closed
        7d 9h 12m 1 Paul King 23/Dec/08 05:58

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Maurice Nicholson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development