RFR(S): JDK-8033911 Simplify instrumentation of FileInputStream and RandomAccessFile

Staffan Larsen staffan.larsen at oracle.com
Fri Feb 7 11:27:46 UTC 2014

On 7 feb 2014, at 11:56, Alan Bateman <Alan.Bateman at oracle.com> wrote:

> On 07/02/2014 10:46, Staffan Larsen wrote:
>> A few of the public read and write methods in FileInputStream and RandomAccessFile are declared native. This means that it is hard to instrument them using byte code instrumentation. Changing the public methods to be to non-native and instead calling private native methods simplifies instrumentation.
>> webrev: http://cr.openjdk.java.net/~sla/8033911/webrev.00/
>> bug: https://bugs.openjdk.java.net/browse/JDK-8033911
> I assume you know this already but both JVM TI and java.lang.instrument do have support for hooking into the resolution of native methods. It is of course more complicated and not for the fainthearted.

Yes, but a large drawback of using SetNativeMethodPrefix is that it requires schema changes to the class file (adding a method). This is not possible when dynamically attaching an instrumentation agent.

> The proposed changes look okay. The only thing is that it might not be complete but perhaps it's not too interesting to instrument methods such as skip or available.

That was my thinking, too.


More information about the core-libs-dev mailing list