rt/emul/compact/src/main/java/java/io/FileInputStream.java
changeset 1337 c794024954b5
parent 1334 588d5bf7a560
     1.1 --- a/rt/emul/compact/src/main/java/java/io/FileInputStream.java	Thu Oct 03 15:40:35 2013 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/io/FileInputStream.java	Thu Oct 03 17:36:44 2013 +0200
     1.3 @@ -25,8 +25,6 @@
     1.4  
     1.5  package java.io;
     1.6  
     1.7 -import java.nio.channels.FileChannel;
     1.8 -import sun.nio.ch.FileChannelImpl;
     1.9  
    1.10  
    1.11  /**
    1.12 @@ -51,7 +49,7 @@
    1.13      /* File Descriptor - handle to the open file */
    1.14      private final FileDescriptor fd;
    1.15  
    1.16 -    private FileChannel channel = null;
    1.17 +//    private FileChannel channel = null;
    1.18  
    1.19      private final Object closeLock = new Object();
    1.20      private volatile boolean closed = false;
    1.21 @@ -125,17 +123,7 @@
    1.22       * @see        java.lang.SecurityManager#checkRead(java.lang.String)
    1.23       */
    1.24      public FileInputStream(File file) throws FileNotFoundException {
    1.25 -        String name = (file != null ? file.getPath() : null);
    1.26 -        SecurityManager security = System.getSecurityManager();
    1.27 -        if (security != null) {
    1.28 -            security.checkRead(name);
    1.29 -        }
    1.30 -        if (name == null) {
    1.31 -            throw new NullPointerException();
    1.32 -        }
    1.33 -        fd = new FileDescriptor();
    1.34 -        fd.incrementAndGetUseCount();
    1.35 -        open(name);
    1.36 +        throw new SecurityException();
    1.37      }
    1.38  
    1.39      /**
    1.40 @@ -163,21 +151,7 @@
    1.41       * @see        SecurityManager#checkRead(java.io.FileDescriptor)
    1.42       */
    1.43      public FileInputStream(FileDescriptor fdObj) {
    1.44 -        SecurityManager security = System.getSecurityManager();
    1.45 -        if (fdObj == null) {
    1.46 -            throw new NullPointerException();
    1.47 -        }
    1.48 -        if (security != null) {
    1.49 -            security.checkRead(fdObj);
    1.50 -        }
    1.51 -        fd = fdObj;
    1.52 -
    1.53 -        /*
    1.54 -         * FileDescriptor is being shared by streams.
    1.55 -         * Ensure that it's GC'ed only when all the streams/channels are done
    1.56 -         * using it.
    1.57 -         */
    1.58 -        fd.incrementAndGetUseCount();
    1.59 +        throw new SecurityException();
    1.60      }
    1.61  
    1.62      /**
    1.63 @@ -303,15 +277,15 @@
    1.64              }
    1.65              closed = true;
    1.66          }
    1.67 -        if (channel != null) {
    1.68 -            /*
    1.69 -             * Decrement the FD use count associated with the channel
    1.70 -             * The use count is incremented whenever a new channel
    1.71 -             * is obtained from this stream.
    1.72 -             */
    1.73 -           fd.decrementAndGetUseCount();
    1.74 -           channel.close();
    1.75 -        }
    1.76 +//        if (channel != null) {
    1.77 +//            /*
    1.78 +//             * Decrement the FD use count associated with the channel
    1.79 +//             * The use count is incremented whenever a new channel
    1.80 +//             * is obtained from this stream.
    1.81 +//             */
    1.82 +//           fd.decrementAndGetUseCount();
    1.83 +//           channel.close();
    1.84 +//        }
    1.85  
    1.86          /*
    1.87           * Decrement the FD use count associated with this stream
    1.88 @@ -358,21 +332,21 @@
    1.89       * @since 1.4
    1.90       * @spec JSR-51
    1.91       */
    1.92 -    public FileChannel getChannel() {
    1.93 -        synchronized (this) {
    1.94 -            if (channel == null) {
    1.95 -                channel = FileChannelImpl.open(fd, true, false, this);
    1.96 -
    1.97 -                /*
    1.98 -                 * Increment fd's use count. Invoking the channel's close()
    1.99 -                 * method will result in decrementing the use count set for
   1.100 -                 * the channel.
   1.101 -                 */
   1.102 -                fd.incrementAndGetUseCount();
   1.103 -            }
   1.104 -            return channel;
   1.105 -        }
   1.106 -    }
   1.107 +//    public FileChannel getChannel() {
   1.108 +//        synchronized (this) {
   1.109 +//            if (channel == null) {
   1.110 +//                channel = FileChannelImpl.open(fd, true, false, this);
   1.111 +//
   1.112 +//                /*
   1.113 +//                 * Increment fd's use count. Invoking the channel's close()
   1.114 +//                 * method will result in decrementing the use count set for
   1.115 +//                 * the channel.
   1.116 +//                 */
   1.117 +//                fd.incrementAndGetUseCount();
   1.118 +//            }
   1.119 +//            return channel;
   1.120 +//        }
   1.121 +//    }
   1.122  
   1.123      private static native void initIDs();
   1.124