jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Huw Evans <...@dcs.gla.ac.uk>
Subject Re: wrapping native methods
Date Tue, 08 Oct 2002 13:58:02 GMT

> System.currentTimeMillis();

Hello everyone,  I've just tried to fool the VM into loading my version of 
System which has a modified currentTimeMillis().  However, I get this response 
from the VM:

Error occurred during initialization of VM
java.lang.ExceptionInInitializerError

This is probably because the System class when it is initialized, registered 
its native methods.  The currentTimeMillis() is a native method in the 
original System and a non-native in my hacked version.  Some code in the VM 
may explicitly check for the native version on currentTimeMillis.  I took the 
native registration code out, but still got the same error.

Therefore, I don't think this approach is possible, at least, given the Vm I 
am using (Sun's java version for 1.3.1).

One other approach would be to provide a different native library which would 
be called.  You would need to work out how to substitute a different native 
library, call yours, and do yout stuff in it, possibly calling up into the VM 
to get access to Java level code.  In your native library, you would then have 
to call the original native library to get the actual time --- or just call 
the C function that returns this information, which *I think* is 
gettimeofday(3C).  Once you've got the real time, you would then return this.

Regards
Huw Evans



--
To unsubscribe, e-mail:   <mailto:bcel-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:bcel-user-help@jakarta.apache.org>


Mime
View raw message