Uploaded image for project: 'Javassist'
  1. Javassist
  2. JASSIST-144

ProxyObject#setHandler interferes with business methods of the same name

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.12.0.GA
    • Fix Version/s: 3.16.0-GA
    • Labels:
      None

      Description

      Being reported by Hibernate/JPA users -> https://hibernate.onjira.com/browse/HHH-5731

        Gliffy Diagrams

          Activity

          Hide
          chiba Shigeru Chiba added a comment -

          Yes, Paul's suggestion is a good approach but, if possible, I would like to solve the problem without changing the API. I am not sure how, though.

          Show
          chiba Shigeru Chiba added a comment - Yes, Paul's suggestion is a good approach but, if possible, I would like to solve the problem without changing the API. I am not sure how, though.
          Hide
          sebersole Steve Ebersole added a comment -

          Well considering the API (ProxyObject#setHandler) is in fact the problem, I also do not see how you can do this without changing the API

          Show
          sebersole Steve Ebersole added a comment - Well considering the API ( ProxyObject#setHandler ) is in fact the problem, I also do not see how you can do this without changing the API
          Hide
          chiba Shigeru Chiba added a comment -

          I think I found a solution.
          I introduced Proxy, a super interface of ProxyObject. Proxy only provides setHandler().
          Then I modified Javassist so that a proxy object will implement the Proxy interface instead of ProxyObject if the original object (= the super class of the proxy) has getHandler(). If not, a proxy object will implement ProxyObject and getHandler() as before.

          This implies slight API incompatibility but its impacts would be minimized.

          Can anyone check Hibernate with the latest snapshot of Javassist?

          Show
          chiba Shigeru Chiba added a comment - I think I found a solution. I introduced Proxy, a super interface of ProxyObject. Proxy only provides setHandler(). Then I modified Javassist so that a proxy object will implement the Proxy interface instead of ProxyObject if the original object (= the super class of the proxy) has getHandler(). If not, a proxy object will implement ProxyObject and getHandler() as before. This implies slight API incompatibility but its impacts would be minimized. Can anyone check Hibernate with the latest snapshot of Javassist?
          Hide
          sebersole Steve Ebersole added a comment -

          Shigeru, sorry I missed the earlier notifications...

          I am not following what the expected fix is here. As I understand it, the proxy object still requires a method setHandler to inject the Javassist handler object. If the class being proxied also defines a setHandler method we still have this problem. What am I missing?

          Show
          sebersole Steve Ebersole added a comment - Shigeru, sorry I missed the earlier notifications... I am not following what the expected fix is here. As I understand it, the proxy object still requires a method setHandler to inject the Javassist handler object. If the class being proxied also defines a setHandler method we still have this problem. What am I missing?
          Hide
          chiba Shigeru Chiba added a comment -

          If a target class has getHandler, Javassist does not add getHandler(). So proxifying that class does not cause any problem. On the other hand, since setHandler added by Javassist takes a javassist.util.proxy.MethodHandler object, it should be able to coexist with other setHandler methods, which take different type of parameters. I mean, it would safely overload other setHandler methods.

          Sorry, this workaround is slightly complex but I hope the description above makes the trick clear.

          Show
          chiba Shigeru Chiba added a comment - If a target class has getHandler, Javassist does not add getHandler(). So proxifying that class does not cause any problem. On the other hand, since setHandler added by Javassist takes a javassist.util.proxy.MethodHandler object, it should be able to coexist with other setHandler methods, which take different type of parameters. I mean, it would safely overload other setHandler methods. Sorry, this workaround is slightly complex but I hope the description above makes the trick clear.

            People

            • Assignee:
              chiba Shigeru Chiba
              Reporter:
              sebersole Steve Ebersole
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development