jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@mwm.lt>
Subject Re: wrapping native methods
Date Tue, 08 Oct 2002 14:38:19 GMT

Yes, it depends on JVM implementation and I do not think it is some good way
to change
native methods. I am afraid SUN's JVM will try to find native method
implementations in
jvm.dll or jvm.so for System class and I think it can be a problem to
redistribute modified SUN's JVM.
I think it is better to use some utility and change system time in OS level,
it is not good for production,
but it must be good and trivial way for testing:
  Runtime.exec("settime.exe " +  myTime ) .

> > 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
> from the VM:
> Error occurred during initialization of VM
> java.lang.ExceptionInInitializerError
> This is probably because the System class when it is initialized,
> 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
> may explicitly check for the native version on currentTimeMillis.  I took
> native registration code out, but still got the same error.
> Therefore, I don't think this approach is possible, at least, given the Vm
> am using (Sun's java version for 1.3.1).
> One other approach would be to provide a different native library which
> be called.  You would need to work out how to substitute a different
> library, call yours, and do yout stuff in it, possibly calling up into the
> to get access to Java level code.  In your native library, you would then
> to call the original native library to get the actual time --- or just
> the C function that returns this information, which *I think* is
> gettimeofday(3C).  Once you've got the real time, you would then return
> Regards
> Huw Evans
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message