[stringtemplate-interest] StringTemplate + Doclet

Brian Clapper bmc at clapper.org
Wed Dec 22 10:01:21 PST 2010


On 12/22/10 12:51 PM, Terence Parr wrote:
> 
> On Dec 22, 2010, at 9:38 AM, Brian Clapper wrote:
>>> contract), I ended up using ASM to generate interfaces on the fly, which I then
>> implement via java.lang.reflect.Proxy.
> 
> BTW, for renderers i did == on obj.getClass() not instanceof (which only works
> on class names not Class ptrs).  Is it a serious problem if i don't allow
> instanceof?  Maybe if the model object is hidden by interfaces like jdbc.
> hmm... i'd rather avoid the java.lang.reflect.Proxy stuff.

I don't use instanceof, so it won't affect me.

I deliberately chose java.lang.reflect.Proxy, for a couple reasons. First,
generating the byte code for an interface, via ASM, is straightforward and
simple. Generating a wrapper class, on the other hand, is more complicated and
annoying. Second, using Proxy to implement an interface on the fly is also
straightforward.

This technique allows for more maintainable code, in my opinion. If I'm going
to resort to generating byte code on the fly, I'd like that part of the
solution to be a dead-simple as possible. Use of Proxy made that possible. If I
weren't generating the byte code for the wrapper interface on the fly, I
wouldn't be using Proxy at all.

If I could get rid of byte code generation entirely, it'd be a real win.
-- 
-Brian

Brian Clapper, http://www.clapper.org/bmc/


More information about the stringtemplate-interest mailing list