David Paul BELANGER wrote:
> Hello,
>
> I am wondering if there a high-level function in sablevm that
> given the name of a
> class, it will load/link/initialize (if necessary) then create an
> instance?
No, there isn't. But, you might be interested to look at the implementation of
the PREPARE_NEW instruction in instructions.m4.c which does what you are looking
for.
The reason such function isn't made available is that it is a very bad idea to
check if a class should be initialized on every instance creation. You should,
instead, remember that you have loaded/../initialized a class.
The JNI interace makes this explicit by providing "cache-able" method ids (used
for the instance constructor).
> I did not find any and I will start implementing my own. Let me know if
> one already exists.
Please don't implement such function. Instead, create (e.g. load, link,
initialize) all classes you need and cache them.
Etienne
--
Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/
SableVM: http://www.sablevm.org/
SableCC: http://www.sablecc.org/
|