summaryrefslogtreecommitdiff
path: root/external/ikvm/openjdk/java/io/FileInputStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'external/ikvm/openjdk/java/io/FileInputStream.java')
-rw-r--r--external/ikvm/openjdk/java/io/FileInputStream.java45
1 files changed, 38 insertions, 7 deletions
diff --git a/external/ikvm/openjdk/java/io/FileInputStream.java b/external/ikvm/openjdk/java/io/FileInputStream.java
index a0bc2247eb..3547947f07 100644
--- a/external/ikvm/openjdk/java/io/FileInputStream.java
+++ b/external/ikvm/openjdk/java/io/FileInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@ package java.io;
import java.nio.channels.FileChannel;
import sun.nio.ch.FileChannelImpl;
+import sun.misc.IoTrace;
/**
@@ -51,6 +52,9 @@ class FileInputStream extends InputStream
/* File Descriptor - handle to the open file */
private final FileDescriptor fd;
+ /* The path of the referenced file (null if the stream is created with a file descriptor) */
+ private final String path;
+
private FileChannel channel = null;
private final Object closeLock = new Object();
@@ -133,8 +137,14 @@ class FileInputStream extends InputStream
if (name == null) {
throw new NullPointerException();
}
+ /*
+ if (file.isInvalid()) {
+ throw new FileNotFoundException("Invalid file path");
+ }
+ */
fd = new FileDescriptor();
fd.incrementAndGetUseCount();
+ this.path = name;
open(name);
}
@@ -171,6 +181,7 @@ class FileInputStream extends InputStream
security.checkRead(fdObj);
}
fd = fdObj;
+ path = null;
/*
* FileDescriptor is being shared by streams.
@@ -197,9 +208,15 @@ class FileInputStream extends InputStream
* file is reached.
* @exception IOException if an I/O error occurs.
*/
- public int read() throws IOException
- {
- return fd.read();
+ public int read() throws IOException {
+ Object traceContext = IoTrace.fileReadBegin(path);
+ int b = 0;
+ try {
+ b = fd.read();
+ } finally {
+ IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
+ }
+ return b;
}
/**
@@ -226,7 +243,14 @@ class FileInputStream extends InputStream
* @exception IOException if an I/O error occurs.
*/
public int read(byte b[]) throws IOException {
- return readBytes(b, 0, b.length);
+ Object traceContext = IoTrace.fileReadBegin(path);
+ int bytesRead = 0;
+ try {
+ bytesRead = readBytes(b, 0, b.length);
+ } finally {
+ IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
+ }
+ return bytesRead;
}
/**
@@ -248,7 +272,14 @@ class FileInputStream extends InputStream
* @exception IOException if an I/O error occurs.
*/
public int read(byte b[], int off, int len) throws IOException {
- return readBytes(b, off, len);
+ Object traceContext = IoTrace.fileReadBegin(path);
+ int bytesRead = 0;
+ try {
+ bytesRead = readBytes(b, off, len);
+ } finally {
+ IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
+ }
+ return bytesRead;
}
/**
@@ -376,7 +407,7 @@ class FileInputStream extends InputStream
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
- channel = FileChannelImpl.open(fd, true, false, this);
+ channel = FileChannelImpl.open(fd, path, true, false, this);
/*
* Increment fd's use count. Invoking the channel's close()