jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rreye...@attbi.com
Subject Re: wrapping native methods
Date Mon, 07 Oct 2002 17:21:58 GMT
AFAIK, it is not possible to modify core Java classes
(not without cheating anyway). 

You can, however, modify all other classes. For example,
scan the classes for calls to invokestatic
System.currentTimeMillis (very easy with BCEL), and
replace them with invokestatic <your_class.your_method>.
This simple replacement (as opposed to adding the code
inline) would be your best bet, as it shouldn't require
any other changes.

You can do this ahead of time, or at run time with your
own ClassLoader.

God bless,
-Toby Reyelts
> >> This may be a stupid question, but is it possible to
> >> use BCEL to wrap> a native method?
> >
> > In what sense?
> I mean insert java code that will run before and/or after the native
> method executes.
> For time related testing of our system I'd like to fool it to think
> its running in the future, I wondered if BCEL could be used to modify
> the value returned by java.lang.System.currentTimeMillis();
> transparently to the rest of the program
> > You can't modify system classes
> Is this true if I used something like the JavaWrapper example class to
> replace the class loader for the application?
> Thanks
> Andrew
> -- 
> Andrew Smallbone <andrew.smallbone@iee.org>
> --
> To unsubscribe, e-mail:   <mailto:bcel-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:bcel-user-help@jakarta.apache.org>

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