[ https://issues.apache.org/jira/browse/SLING-7207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16597593#comment-16597593 ]
Robert Munteanu commented on SLING-7207: ---------------------------------------- Some (more) years ago we hit a similar program in a non-Sling related program - large performance hit due to method lookups using reflection. We added a method lookup cache which greatly improved performance all over the board. Granted, we had a definite upper bound in terms of the number of methods and also did not have to take into account dynamic class loading. > Get rid of runtime reflection in HTL expression evaluation > ---------------------------------------------------------- > > Key: SLING-7207 > URL: https://issues.apache.org/jira/browse/SLING-7207 > Project: Sling > Issue Type: Improvement > Components: Scripting > Affects Versions: Scripting HTL Engine 1.0.20, Scripting HTL Compiler > 1.0.0, Scripting HTL Java Compiler 1.0.0 > Reporter: Vlad Bailescu > Assignee: Radu Cotescu > Priority: Major > > At the moment the following expression > {code} > <sly data-sly-use.obj="com.my.Obj">${obj.message}</sly> > {code} > generates this Java code: > {code} > Object _global_obj = null; > _global_obj = renderContext.call("use", "com.my.Obj", obj()); > { > Object var_0 = renderContext.call("xss", > renderContext.getObjectModel().resolveProperty(_global_obj, "message"), > "text"); > out.write(renderContext.getObjectModel().toString(var_0)); > } > {code} > Resolving the property is done via reflection at runtime. Given the fact that > for most use providers (JS is an exception) we know the type of > {{_global_obj}} we could determine the right method to call at compile time. > Resulting code might look something like: > {code} > com.my.Obj _global_obj = renderContext.call("use", com.my.Obj.class, obj()); > { > Object var_0 = renderContext.call("xss", _global_obj.getMessage()), > "text"); > out.write(renderContext.getObjectModel().toString(var_0)); > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)