< prev index next >

src/java.base/share/native/libjava/io_util.c

Print this page
rev 53271 : 8216981: Per thread IO statistics in JFR

@@ -48,10 +48,13 @@
     if (nread == 0) { /* EOF */
         return -1;
     } else if (nread == -1) { /* error */
         JNU_ThrowIOExceptionWithLastError(env, "Read error");
     }
+
+    JVM_callFileReadBytes(env, 1);
+
     return ret & 0xFF;
 }
 
 /* The maximum size of a stack-allocated buffer.
  */

@@ -107,10 +110,11 @@
         nread = -1;
     } else {
         nread = IO_Read(fd, buf, len);
         if (nread > 0) {
             (*env)->SetByteArrayRegion(env, bytes, off, nread, (jbyte *)buf);
+            JVM_callFileReadBytes(env, nread);
         } else if (nread == -1) {
             JNU_ThrowIOExceptionWithLastError(env, "Read error");
         } else { /* EOF */
             nread = -1;
         }

@@ -138,10 +142,11 @@
         n = IO_Write(fd, &c, 1);
     }
     if (n == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "Write error");
     }
+    JVM_callFileWriteBytes(env, 1);
 }
 
 void
 writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
            jint off, jint len, jboolean append, jfieldID fid)

@@ -193,10 +198,11 @@
                 break;
             }
             off += n;
             len -= n;
         }
+        JVM_callFileWriteBytes(env, off);
     }
     if (buf != stackBuf) {
         free(buf);
     }
 }
< prev index next >