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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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

        Hide
        roshandawrani 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
        roshandawrani 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
        Hide
        roshandawrani 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
        roshandawrani 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
        blackdrag Jochen Theodorou added a comment -

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

        Show
        blackdrag Jochen Theodorou added a comment - sounds reasonable to me... in fact I don't remember why we checked for methods declared on Object
        Hide
        paulk Paul King added a comment -

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

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

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

        Show
        roshandawrani Roshan Dawrani added a comment - Fixed. Now allows overriding toString() in a 'map-of-closures as AnInterface' implementation.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development