proxy'ing a final class

52 views
Skip to first unread message

Steffen Glückselig

unread,
Jul 26, 2009, 7:22:39 AM7/26/09
to Clojure
Hello,

I was going to extend java.util.regex.Matcher for named groups and
came to a point where I wanted to proxy the Matcher-class so that my
extension was usable in-place of the original implementation.

I realized - via "java.lang.VerifyError: Cannot inherit from final
class" - that it isn't possible to do that.

Is there another way to 'inject' the extended implementation in common
code?

Maybe 'proxy' should be able to handle even final classes?


best,
Steffen

pmf

unread,
Jul 26, 2009, 11:16:05 AM7/26/09
to Clojure
On Jul 26, 1:22 pm, Steffen Glückselig <goo...@gungfu.de> wrote:
> Hello,
>
> I was going to extend java.util.regex.Matcher for named groups and
> came to a point where I wanted to proxy the Matcher-class so that my
> extension was usable in-place of the original implementation.
>
> I realized - via "java.lang.VerifyError: Cannot inherit from final
> class" - that it isn't possible to do that.
>
> [...]
>
> Maybe 'proxy' should be able to handle even final classes?

The enforcement of the 'final' restriction is done by the JVM (unlike
some other things that are enforced by a Java-compiler but not the
JVM); subclassing for some classes must be prohibited for security
reasons.

> Is there another way to 'inject' the extended implementation in common
> code?

You could pack your own RT.jar (not really very practical).
Reply all
Reply to author
Forward
0 new messages