Fantazies on "final"

Yesterday I was playing with unification algorithms and decided to implement one for general Java "terms" (object instances). This naive attempt stopped after 10 minutes when I understood that to make logical variables transparent to user I have to be able to create proxies for objects of any type. Even if I outlaw unboxed types, unfortunately this is not possible also for final classes... Which are expected to form the bulk of typical business objects (they are strings, numbers, ...).

This failure caused me to exercise my English in not very creative ways - I understand the original considerations of the JDK standard libraries, but history aside - is it reasonable to even wish to create a dynamic (or for that matter even static) proxy for an instance of a final class? Does not it contradict the semantic of final (that is - not inheritable)? Should not ability to intercept be separated from implementation reuse?

PS: lack of proxies for any class is not the only problem for this micro-project - mutability by default instead of having explicit cells kills any chances for transparency of such manipulations in Java - one has to proxy all objects, not just cells and transients. Ironically, both problems are related to word "final" - the first for classes and the second for variables.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Not a problem for AOP

Proxies are heavily used by AOP, but for different goal.
AOP proxies aim to intercept messages and behavior.
Transients' proxies aim to intercept read/write access. In a way, they both perform delegation of "object identity" (remotely similar to Smalltalk's become).

Loving long and clever words, I would like to call them coalgebraic resp. algebraic proxies... :-)
The problems I mentioned for APs are not so pronounced for CPs, that may be the reason AOP is used for Java, but Oz would probably find JVM too restrictive (I am taking my chance to speculate while PVR is on the vacation :-) ).

[EDIT: "transient" in this thread is used in Oz/Alice, not Java sense]

Sounds like you need the Unfinalizer

In his Scratch Where It's Itching weblog, David Shay wrote a couple of versions of "The Unfinalizer".


Did you ever need to extend a class, but found out it is final? And you do not have the source code for it? Well, the class file format being public, you could just write an Unfinalizer class...

Some classes are more final than others

This month my weapon of choice for such tricks is CGLIB.
But none of "bytecode enhancing" techniques works for classes from the bootstrap classloader. This includes strings, numbers, etc. There are good reasons for that, given existing classloading semantics.
:-(

No, man.

The Unfinalizer is a pussy. What you need is The Equalizer.

[Robert McCall, The Equalizer, is an] ex-senior operative for an espionage agency known as “The Company.” He is well-dressed, divorced, 5’10” tall, 175 pounds, with gray hair, hazel eyes and in his mid-fifties. Disillusioned with his 30 year career of fighting terrorists and playing the spy game, Robert voluntarily retired in 1985 from an occupation that usually doesn’t let its employees leave...alive.

He now hires himself out as an urban vigilante and advertises in the local newspaper with an ad that reads "Got a problem? Odds against you? Call the Equalizer 212-555-4200."

I hear that even The Terminator is scared of The Equalizer.

Universal Equalizer?

In what category then?

I've seen you already buried a guy in the neighboring thread, and I was trembling... But you are quite peaceful today :-)

Category

In what category then?

The category BMF, of Bad Mother-Fuckers.

I've seen you already buried a guy in the neighboring thread, and I was trembling... But you are quite peaceful today :-)

I have a mercurial personality.

What angered you?

I thought you are fond of generic programming.
Or is your hatred towards Java so much stronger?
Or was it the spelling bug in the title?

Sorry if I made you mad for some reason...

Huh?

I'm not angry; what makes you think so?