Return-Path: Delivered-To: apmail-jakarta-bcel-user-archive@apache.org Received: (qmail 28389 invoked from network); 8 Oct 2002 14:32:56 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 8 Oct 2002 14:32:56 -0000 Received: (qmail 28820 invoked by uid 97); 8 Oct 2002 14:33:40 -0000 Delivered-To: qmlist-jakarta-archive-bcel-user@jakarta.apache.org Received: (qmail 28775 invoked by uid 97); 8 Oct 2002 14:33:40 -0000 Mailing-List: contact bcel-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "BCEL Users List" Reply-To: "BCEL Users List" Delivered-To: mailing list bcel-user@jakarta.apache.org Received: (qmail 28725 invoked by uid 98); 8 Oct 2002 14:33:37 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <01ce01c26ed8$586ee890$a901a8c0@juozas> From: "Juozas Baliuka" To: "BCEL Users List" References: Subject: Re: wrapping native methods Date: Tue, 8 Oct 2002 16:38:19 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 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: > For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: