[stringtemplate-interest] it's 60% of time in ObjectModelAdaptor.getProperty()

Johan Stuyts j.stuyts at javathinker.com
Fri Feb 4 23:24:16 PST 2011


> yeah,I like the idea a lot too, but I'm also worried about the tools.jar  
> thing.
>
> when it comes down to it, ST v3 was the fastest in the world but it  
> worked for most people. STv4 is at least two times faster so I think  
> perhaps we can just leave it is as-is for now. The easier thing to do  
> might be to generate Java code from the templates and give people a jar  
> to include in their application. The only problem is dynamic  field and  
> method eval is still there. without static types, I'm not sure there's a  
> real reason to add the complexity of generating java.

You may also consider using a custom class loader. The only thing you  
would have to do is replace a number of byte strings in a byte array for  
each adapter, and then use defineClass(...):
- build the byte array by concatenating template parts and  
instance-specific parts
- tell the custom class loader to define the class
- use newInstance() on the resulting class
- cast the object to the interface you have defined for this purpose
- invoke the method

Johan


More information about the stringtemplate-interest mailing list