src/java.base/share/classes/java/io/FileInputStream.java

Print this page
rev 10519 : 8054720: Modifications of I/O methods for instrumentation purposes
Summary: Wrap some native methods in Java methods.
Reviewed-by: TBD


 167         if (fdObj == null) {
 168             throw new NullPointerException();
 169         }
 170         if (security != null) {
 171             security.checkRead(fdObj);
 172         }
 173         fd = fdObj;
 174         path = null;
 175 
 176         /*
 177          * FileDescriptor is being shared by streams.
 178          * Register this stream with FileDescriptor tracker.
 179          */
 180         fd.attach(this);
 181     }
 182 
 183     /**
 184      * Opens the specified file for reading.
 185      * @param name the name of the file
 186      */
 187     private native void open(String name) throws FileNotFoundException;









 188 
 189     /**
 190      * Reads a byte of data from this input stream. This method blocks
 191      * if no input is yet available.
 192      *
 193      * @return     the next byte of data, or <code>-1</code> if the end of the
 194      *             file is reached.
 195      * @exception  IOException  if an I/O error occurs.
 196      */
 197     public int read() throws IOException {
 198         return read0();
 199     }
 200 
 201     private native int read0() throws IOException;
 202 
 203     /**
 204      * Reads a subarray as a sequence of bytes.
 205      * @param b the data to be written
 206      * @param off the start offset in the data
 207      * @param len the number of bytes that are written




 167         if (fdObj == null) {
 168             throw new NullPointerException();
 169         }
 170         if (security != null) {
 171             security.checkRead(fdObj);
 172         }
 173         fd = fdObj;
 174         path = null;
 175 
 176         /*
 177          * FileDescriptor is being shared by streams.
 178          * Register this stream with FileDescriptor tracker.
 179          */
 180         fd.attach(this);
 181     }
 182 
 183     /**
 184      * Opens the specified file for reading.
 185      * @param name the name of the file
 186      */
 187     private native void open0(String name) throws FileNotFoundException;
 188 
 189     // wrap native call to allow instrumentation
 190     /**
 191      * Opens the specified file for reading.
 192      * @param name the name of the file
 193      */
 194     private void open(String name) throws FileNotFoundException {
 195         open0(name);
 196     }
 197     
 198     /**
 199      * Reads a byte of data from this input stream. This method blocks
 200      * if no input is yet available.
 201      *
 202      * @return     the next byte of data, or <code>-1</code> if the end of the
 203      *             file is reached.
 204      * @exception  IOException  if an I/O error occurs.
 205      */
 206     public int read() throws IOException {
 207         return read0();
 208     }
 209 
 210     private native int read0() throws IOException;
 211 
 212     /**
 213      * Reads a subarray as a sequence of bytes.
 214      * @param b the data to be written
 215      * @param off the start offset in the data
 216      * @param len the number of bytes that are written