Changes between Version 3 and Version 4 of LoadingCompileFunctions


Ignore:
Timestamp:
10/30/09 22:22:36 (5 years ago)
Author:
astalla
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LoadingCompileFunctions

    v3 v4  
    2626}
    2727}}}
    28 then, after loading the class, ABCL could fetch the function instance with
     28  then, after loading the class, ABCL could fetch the function instance with
    2929{{{
    3030Lisp.recall(loadedClass.getName());
    3131}}}
    32 Unfortunately, there's a catch: the static initialization block (implemented in the method <clinit> at the bytecode level) is only executed when the class is initialized, and that happens only just before an instance of the class is created, or one of its static members is accessed (http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html#19075
    33 ) - but to do one of those things on an unknown class you need reflection. So it appears reflection can not be avoided.
     32  Unfortunately, there's a catch: the static initialization block (implemented in the method <clinit> at the bytecode level) is only executed when the class is initialized, and that happens only just before an instance of the class is created, or one of its static members is accessed (http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html#19075) - but to do one of those things on an unknown class you need reflection. So it appears reflection can not be avoided.
    3433 * Class.forName(className) should initialize the class too, and thus execute its static initialization code. From another test of mine, forName() is around 10 times faster than newInstance(). However, Erik profiled it on ABCL and it seems this technique is as slow as using newInstance(), presumably because class initialization time for complex classes as ABCL's is the dominant performance bottleneck.