diff --git a/make/mapfiles/libjava/mapfile-vers b/make/mapfiles/libjava/mapfile-vers index d3fe7cede15d46cc50404605b3cf94f150a8a072..9c82cb1017c76ec506e369cc73bfcb4a5ed39531 100644 --- a/make/mapfiles/libjava/mapfile-vers +++ b/make/mapfiles/libjava/mapfile-vers @@ -78,13 +78,13 @@ SUNWprivate_1.1 { Java_java_io_FileInputStream_available; Java_java_io_FileInputStream_close0; Java_java_io_FileInputStream_initIDs; - Java_java_io_FileInputStream_open; + Java_java_io_FileInputStream_open0; Java_java_io_FileInputStream_read0; Java_java_io_FileInputStream_readBytes; Java_java_io_FileInputStream_skip; Java_java_io_FileOutputStream_close0; Java_java_io_FileOutputStream_initIDs; - Java_java_io_FileOutputStream_open; + Java_java_io_FileOutputStream_open0; Java_java_io_FileOutputStream_write; Java_java_io_FileOutputStream_writeBytes; Java_java_io_ObjectInputStream_bytesToDoubles; @@ -97,7 +97,7 @@ SUNWprivate_1.1 { Java_java_io_RandomAccessFile_getFilePointer; Java_java_io_RandomAccessFile_initIDs; Java_java_io_RandomAccessFile_length; - Java_java_io_RandomAccessFile_open; + Java_java_io_RandomAccessFile_open0; Java_java_io_RandomAccessFile_read0; Java_java_io_RandomAccessFile_readBytes; Java_java_io_RandomAccessFile_seek0; diff --git a/make/mapfiles/libjava/reorder-sparc b/make/mapfiles/libjava/reorder-sparc index 4a5cbf45018d74b180a67f017703eab1297c8b3a..d10037652d1cf18ccc8c08496a7c3101cb0692fb 100644 --- a/make/mapfiles/libjava/reorder-sparc +++ b/make/mapfiles/libjava/reorder-sparc @@ -44,7 +44,7 @@ text: .text%Java_java_io_UnixFileSystem_initIDs; text: .text%Java_java_io_UnixFileSystem_canonicalize; text: .text%JNU_GetStringPlatformChars; text: .text%JNU_ReleaseStringPlatformChars; -text: .text%Java_java_io_FileInputStream_open; +text: .text%Java_java_io_FileInputStream_open0; text: .text%fileOpen; text: .text%Java_java_io_FileInputStream_readBytes; text: .text%readBytes; diff --git a/make/mapfiles/libjava/reorder-sparcv9 b/make/mapfiles/libjava/reorder-sparcv9 index 81cbfcb241042ad64a7d8a23da4d1483cb492643..2609711c21fc17509f9cbe33e338c479cc71213f 100644 --- a/make/mapfiles/libjava/reorder-sparcv9 +++ b/make/mapfiles/libjava/reorder-sparcv9 @@ -47,7 +47,7 @@ text: .text%Java_java_io_UnixFileSystem_initIDs; text: .text%Java_java_io_UnixFileSystem_canonicalize; text: .text%JNU_GetStringPlatformChars; text: .text%JNU_ReleaseStringPlatformChars; -text: .text%Java_java_io_FileInputStream_open; +text: .text%Java_java_io_FileInputStream_open0; text: .text%fileOpen; text: .text%Java_java_io_FileInputStream_readBytes; text: .text%readBytes; diff --git a/make/mapfiles/libjava/reorder-x86 b/make/mapfiles/libjava/reorder-x86 index 1c971b80eda92901afa8e653b6b72583992aa54e..b8ea2d43dae7cd38d7b9052fad4a776906a9d206 100644 --- a/make/mapfiles/libjava/reorder-x86 +++ b/make/mapfiles/libjava/reorder-x86 @@ -57,7 +57,7 @@ text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load; text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find; text: .text%Java_java_lang_Float_floatToIntBits; text: .text%Java_java_lang_Double_doubleToLongBits; -text: .text%Java_java_io_FileInputStream_open; +text: .text%Java_java_io_FileInputStream_open0; text: .text%fileOpen; text: .text%Java_java_io_UnixFileSystem_getLength; text: .text%Java_java_io_FileInputStream_readBytes; @@ -90,7 +90,7 @@ text: .text%JNU_NotifyAll; text: .text%JNU_CallMethodByName; text: .text%JNU_CallMethodByNameV; text: .text%Java_java_util_logging_FileHandler_lockFile; -text: .text%Java_java_io_FileOutputStream_open; +text: .text%Java_java_io_FileOutputStream_open0; text: .text%Java_java_io_UnixFileSystem_createDirectory; text: .text%Java_java_io_UnixFileSystem_getLastModifiedTime; text: .text%Java_java_util_prefs_FileSystemPreferences_lockFile0; diff --git a/src/share/classes/java/io/FileInputStream.java b/src/share/classes/java/io/FileInputStream.java index cc6710e8fdaa789e4387673a47bf1b62c6d8bbce..47d13a99a9a81d0406ae3d5d1fdc748706273d18 100644 --- a/src/share/classes/java/io/FileInputStream.java +++ b/src/share/classes/java/io/FileInputStream.java @@ -184,7 +184,16 @@ class FileInputStream extends InputStream * Opens the specified file for reading. * @param name the name of the file */ - private native void open(String name) throws FileNotFoundException; + private native void open0(String name) throws FileNotFoundException; + + // wrap native call to allow instrumentation + /** + * Opens the specified file for reading. + * @param name the name of the file + */ + private void open(String name) throws FileNotFoundException { + open0(name); + } /** * Reads a byte of data from this input stream. This method blocks diff --git a/src/share/classes/java/io/FileOutputStream.java b/src/share/classes/java/io/FileOutputStream.java index 8377261b448cd86eb80fadce179b4214fa92546c..7d2cb8f115df469d50d72c91e5ffa28976cf7571 100644 --- a/src/share/classes/java/io/FileOutputStream.java +++ b/src/share/classes/java/io/FileOutputStream.java @@ -256,9 +256,20 @@ class FileOutputStream extends OutputStream * @param name name of file to be opened * @param append whether the file is to be opened in append mode */ - private native void open(String name, boolean append) + private native void open0(String name, boolean append) throws FileNotFoundException; + // wrap native call to allow instrumentation + /** + * Opens a file, with the specified name, for overwriting or appending. + * @param name name of file to be opened + * @param append whether the file is to be opened in append mode + */ + private void open(String name, boolean append) + throws FileNotFoundException { + open0(name, append); + } + /** * Writes the specified byte to this file output stream. * diff --git a/src/share/classes/java/io/RandomAccessFile.java b/src/share/classes/java/io/RandomAccessFile.java index 58d8c89cdcc664e711bba57a74e66be17f3ebcfb..ccf979be165c88711715dd7ec84520df262ada18 100644 --- a/src/share/classes/java/io/RandomAccessFile.java +++ b/src/share/classes/java/io/RandomAccessFile.java @@ -296,9 +296,26 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * @param mode the mode flags, a combination of the O_ constants * defined above */ - private native void open(String name, int mode) + private native void open0(String name, int mode) throws FileNotFoundException; + // wrap native call to allow instrumentation + /** + * Opens a file and returns the file descriptor. The file is + * opened in read-write mode if the O_RDWR bit in {@code mode} + * is true, else the file is opened as read-only. + * If the {@code name} refers to a directory, an IOException + * is thrown. + * + * @param name the name of the file + * @param mode the mode flags, a combination of the O_ constants + * defined above + */ + private void open(String name, int mode) + throws FileNotFoundException { + open0(name, mode); + } + // 'Read' primitives /** diff --git a/src/share/classes/java/net/SocketInputStream.java b/src/share/classes/java/net/SocketInputStream.java index 224051ff6085c63014d1fd7bef50cce058e2d61b..41b18bdc7e0c3c9370ed0796d76822d2e48676a8 100644 --- a/src/share/classes/java/net/SocketInputStream.java +++ b/src/share/classes/java/net/SocketInputStream.java @@ -96,6 +96,26 @@ class SocketInputStream extends FileInputStream int timeout) throws IOException; + // wrap native call to allow instrumentation + /** + * Reads into an array of bytes at the specified offset using + * the received socket primitive. + * @param fd the FileDescriptor + * @param b the buffer into which the data is read + * @param off the start offset of the data + * @param len the maximum number of bytes read + * @param timeout the read timeout in ms + * @return the actual number of bytes read, -1 is + * returned when the end of the stream is reached. + * @exception IOException If an I/O error has occurred. + */ + private int socketRead(FileDescriptor fd, + byte b[], int off, int len, + int timeout) + throws IOException { + return socketRead0(fd, b, off, len, timeout); + } + /** * Reads into a byte array data from the socket. * @param b the buffer into which the data is read @@ -147,7 +167,7 @@ class SocketInputStream extends FileInputStream // acquire file descriptor and do the read FileDescriptor fd = impl.acquireFD(); try { - n = socketRead0(fd, b, off, length, timeout); + n = socketRead(fd, b, off, length, timeout); if (n > 0) { return n; } @@ -165,7 +185,7 @@ class SocketInputStream extends FileInputStream impl.setConnectionResetPending(); impl.acquireFD(); try { - n = socketRead0(fd, b, off, length, timeout); + n = socketRead(fd, b, off, length, timeout); if (n > 0) { return n; } diff --git a/src/share/native/java/io/FileInputStream.c b/src/share/native/java/io/FileInputStream.c index 092ddbf6f1f8eb3311dd499cef26ab20018db956..dc1aea5cd64c5a742c6d5fd50b9e2fc5d5a67a3a 100644 --- a/src/share/native/java/io/FileInputStream.c +++ b/src/share/native/java/io/FileInputStream.c @@ -57,7 +57,7 @@ Java_java_io_FileInputStream_initIDs(JNIEnv *env, jclass fdClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileInputStream_open(JNIEnv *env, jobject this, jstring path) { +Java_java_io_FileInputStream_open0(JNIEnv *env, jobject this, jstring path) { fileOpen(env, this, path, fis_fd, O_RDONLY); } diff --git a/src/share/native/java/io/RandomAccessFile.c b/src/share/native/java/io/RandomAccessFile.c index 53b5f1aac1f50bd798808b6b472f63ddd4dacef5..a44d8f39681f296fbeeb842b018496e50b5150f5 100644 --- a/src/share/native/java/io/RandomAccessFile.c +++ b/src/share/native/java/io/RandomAccessFile.c @@ -47,8 +47,8 @@ Java_java_io_RandomAccessFile_initIDs(JNIEnv *env, jclass fdClass) { JNIEXPORT void JNICALL -Java_java_io_RandomAccessFile_open(JNIEnv *env, - jobject this, jstring path, jint mode) +Java_java_io_RandomAccessFile_open0(JNIEnv *env, + jobject this, jstring path, jint mode) { int flags = 0; if (mode & java_io_RandomAccessFile_O_RDONLY) diff --git a/src/solaris/native/java/io/FileOutputStream_md.c b/src/solaris/native/java/io/FileOutputStream_md.c index efd5864cd9c0695ba138256a5018082a0fb5d70f..22d80a22663a37e3d03f1d5b4b7404454419619d 100644 --- a/src/solaris/native/java/io/FileOutputStream_md.c +++ b/src/solaris/native/java/io/FileOutputStream_md.c @@ -53,8 +53,8 @@ Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fdClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, - jstring path, jboolean append) { +Java_java_io_FileOutputStream_open0(JNIEnv *env, jobject this, + jstring path, jboolean append) { fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)); } diff --git a/src/windows/native/java/io/FileOutputStream_md.c b/src/windows/native/java/io/FileOutputStream_md.c index 567ebaa0c8339646160eae4b1ee0f637607ef873..02ea15e89cb090c6be451c38445ddb6ffce43c18 100644 --- a/src/windows/native/java/io/FileOutputStream_md.c +++ b/src/windows/native/java/io/FileOutputStream_md.c @@ -54,8 +54,8 @@ Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fosClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, - jstring path, jboolean append) { +Java_java_io_FileOutputStream_open0(JNIEnv *env, jobject this, + jstring path, jboolean append) { fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)); }