Clojure

proxy hides protected final methods

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: Release 1.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

When using proxy to override a class that has a protected final method, that method is not exposed.

For example, given the class:

ProxyMe.java
public class ProxyMe {
    public final void publicFinal() {}
    protected void protectedNonFinal() {}
    protected final void protectedFinal() {}
}

And the Clojure code:

proxy_me.clj
(ns proxy-me
  (:import ProxyMe))

(def proxied-class (class (proxy [ProxyMe] [])))
(def no-args (into-array Class []))

; both are ok
(.getMethod proxied-class "publicFinal" no-args)
(.getMethod proxied-class "protectedNonFinal" no-args)

; throws NoSuchMethodException
(.getMethod proxied-class "protectedFinal" no-args)

Any attempt to access protectedFinal() fails.

Activity

Hide
Daniel Solano Gómez added a comment -

I should have re-read the documentation.

Show
Daniel Solano Gómez added a comment - I should have re-read the documentation.
Hide
Daniel Solano Gómez added a comment -

Okay, someone on #clojure ran into this problem as well, and I have verified it's an actual bug for both gen-class and proxy. Neither one has access to protected final methods.

Show
Daniel Solano Gómez added a comment - Okay, someone on #clojure ran into this problem as well, and I have verified it's an actual bug for both gen-class and proxy. Neither one has access to protected final methods.
Hide
Daniel Solano Gómez added a comment -

I've looked into this a bit more, and I think it's difficult for proxy to be able to call protected final methods. It would be nice to be able to do, but for now I think it's best allow that functionality through gen-class.

I will open a new ticket with a patch to allow gen-class to expose protected final methods.

Show
Daniel Solano Gómez added a comment - I've looked into this a bit more, and I think it's difficult for proxy to be able to call protected final methods. It would be nice to be able to do, but for now I think it's best allow that functionality through gen-class. I will open a new ticket with a patch to allow gen-class to expose protected final methods.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: