rt/emul/compact/src/main/java/java/io/FileOutputStream.java
changeset 1337 c794024954b5
parent 1334 588d5bf7a560
     1.1 --- a/rt/emul/compact/src/main/java/java/io/FileOutputStream.java	Thu Oct 03 15:40:35 2013 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/io/FileOutputStream.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 @@ -65,7 +63,7 @@
    1.13      /**
    1.14       * The associated channel, initalized lazily.
    1.15       */
    1.16 -    private FileChannel channel;
    1.17 +//    private FileChannel channel;
    1.18  
    1.19      private final Object closeLock = new Object();
    1.20      private volatile boolean closed = false;
    1.21 @@ -197,19 +195,7 @@
    1.22      public FileOutputStream(File file, boolean append)
    1.23          throws FileNotFoundException
    1.24      {
    1.25 -        String name = (file != null ? file.getPath() : null);
    1.26 -        SecurityManager security = System.getSecurityManager();
    1.27 -        if (security != null) {
    1.28 -            security.checkWrite(name);
    1.29 -        }
    1.30 -        if (name == null) {
    1.31 -            throw new NullPointerException();
    1.32 -        }
    1.33 -        this.fd = new FileDescriptor();
    1.34 -        this.append = append;
    1.35 -
    1.36 -        fd.incrementAndGetUseCount();
    1.37 -        open(name, append);
    1.38 +        throw new SecurityException();
    1.39      }
    1.40  
    1.41      /**
    1.42 @@ -236,22 +222,7 @@
    1.43       * @see        java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
    1.44       */
    1.45      public FileOutputStream(FileDescriptor fdObj) {
    1.46 -        SecurityManager security = System.getSecurityManager();
    1.47 -        if (fdObj == null) {
    1.48 -            throw new NullPointerException();
    1.49 -        }
    1.50 -        if (security != null) {
    1.51 -            security.checkWrite(fdObj);
    1.52 -        }
    1.53 -        this.fd = fdObj;
    1.54 -        this.append = false;
    1.55 -
    1.56 -        /*
    1.57 -         * FileDescriptor is being shared by streams.
    1.58 -         * Ensure that it's GC'ed only when all the streams/channels are done
    1.59 -         * using it.
    1.60 -         */
    1.61 -        fd.incrementAndGetUseCount();
    1.62 +        throw new SecurityException();
    1.63      }
    1.64  
    1.65      /**
    1.66 @@ -338,16 +309,16 @@
    1.67              }
    1.68              closed = true;
    1.69          }
    1.70 -
    1.71 -        if (channel != null) {
    1.72 -            /*
    1.73 -             * Decrement FD use count associated with the channel
    1.74 -             * The use count is incremented whenever a new channel
    1.75 -             * is obtained from this stream.
    1.76 -             */
    1.77 -            fd.decrementAndGetUseCount();
    1.78 -            channel.close();
    1.79 -        }
    1.80 +//
    1.81 +//        if (channel != null) {
    1.82 +//            /*
    1.83 +//             * Decrement FD use count associated with the channel
    1.84 +//             * The use count is incremented whenever a new channel
    1.85 +//             * is obtained from this stream.
    1.86 +//             */
    1.87 +//            fd.decrementAndGetUseCount();
    1.88 +//            channel.close();
    1.89 +//        }
    1.90  
    1.91          /*
    1.92           * Decrement FD use count associated with this stream
    1.93 @@ -395,21 +366,21 @@
    1.94       * @since 1.4
    1.95       * @spec JSR-51
    1.96       */
    1.97 -    public FileChannel getChannel() {
    1.98 -        synchronized (this) {
    1.99 -            if (channel == null) {
   1.100 -                channel = FileChannelImpl.open(fd, false, true, append, this);
   1.101 -
   1.102 -                /*
   1.103 -                 * Increment fd's use count. Invoking the channel's close()
   1.104 -                 * method will result in decrementing the use count set for
   1.105 -                 * the channel.
   1.106 -                 */
   1.107 -                fd.incrementAndGetUseCount();
   1.108 -            }
   1.109 -            return channel;
   1.110 -        }
   1.111 -    }
   1.112 +//    public FileChannel getChannel() {
   1.113 +//        synchronized (this) {
   1.114 +//            if (channel == null) {
   1.115 +//                channel = FileChannelImpl.open(fd, false, true, append, this);
   1.116 +//
   1.117 +//                /*
   1.118 +//                 * Increment fd's use count. Invoking the channel's close()
   1.119 +//                 * method will result in decrementing the use count set for
   1.120 +//                 * the channel.
   1.121 +//                 */
   1.122 +//                fd.incrementAndGetUseCount();
   1.123 +//            }
   1.124 +//            return channel;
   1.125 +//        }
   1.126 +//    }
   1.127  
   1.128      /**
   1.129       * Cleans up the connection to the file, and ensures that the