1

When making a subclass in Clojure using gen-class, you can expose protected virtual(non-final) methods through exposes-methods, however it is implemented through overriding, which cannot work for non-virtual(final) methods.

Is the only way to call a protected method this way through reflection?

Can reify or proxy do this better than gen-class?

2
  • What do you mean by "non-vritual methods" here? Static? Final? Commented Mar 8, 2013 at 9:41
  • In c# the term is virtual. In java I believe methods are virtual by default, but final means non-virtual. Commented Mar 8, 2013 at 9:42

1 Answer 1

1

This turned out to be a bug in clojure-clr. It probably works fine in the JVM version. Clojure does allow calling non-virtual/final methods if they're protected/public. However, the method I was trying to call was protected internal, which actually means protected or internal. clojure-clr was incorrectly interpreting this as protected and internal, internal meaning only accessible within the same assembly. Due to this, my method call was failing.

This has been fixed in the latest version of clojure-clr.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.