This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Inverting Brian's Mind
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
In Inverting the Inversion of Control he discusses an interesting melding of AOP.
He mentions a mechanism where you tweak bytecode so doing a new() doesn't just create a new type.
I have seen this before, especially in the AOP world where some people use this to make new a factory. It also opens up the power that you get in more dynamic languages. When you do a new it may do some logic and return a subclass of the actual class you asked for etc.
The worry that I have had in Java is when people make new act like a singleton. That is scary as when you say new you really think that it will mean new memory on the heap etc etc.
However, back to Brian. How cool would this be:
update
methods
set
method_body='return new Integer(42);'
where
package = 'org.example.foo' and
name = 'getDayOfWeek';
i love adding fuel to fires :) :) :)