/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class InheritedChannel {
// the "types" of socket returned by soType0
// oflag values when opening a file
/*
* In order to reduce the possibility of an error at close time we
* descriptors at close time. This makes the close operation a
* simple dup2 operation for each of the standard streams.
*/
private static void detachIOStreams() {
try {
} catch (IOException ioe) {
// this shouldn't happen
throw new InternalError();
}
}
/*
* Override the implCloseSelectableChannel for each channel type - this
* allows us to "detach" the standard streams after closing and ensures
* that the underlying socket really closes.
*/
throws IOException
{
}
super.implCloseSelectableChannel();
}
}
public static class InheritedServerSocketChannelImpl extends
throws IOException
{
}
super.implCloseSelectableChannel();
}
}
public static class InheritedDatagramChannelImpl extends
throws IOException
{
}
super.implCloseSelectableChannel();
}
}
/*
* If there's a SecurityManager then check for the appropriate
* RuntimePermission.
*/
new RuntimePermission("inheritedChannel")
);
}
}
/*
* If standard inherited channel is connected to a socket then return a Channel
* of the appropriate type based standard input.
*/
// dup the file descriptor - we do this so that for two reasons :-
// 1. Avoids any timing issues with FileDescriptor.in being closed
// or redirected while we create the channel.
// 2. Allows streams based on file descriptor 0 to co-exist with
// the channel (closing one doesn't impact the other)
// Examine the file descriptor - if it's not a socket then we don't
// create a channel so we release the file descriptor.
int st;
return null;
}
// Next we create a FileDescriptor for the dup'ed file descriptor
// Have to use reflection and also make assumption on how FD
// is implemented.
Class paramTypes[] = { int.class };
// Now create the channel. If the socket is a streams socket then
// we see if tthere is a peer (ie: connected). If so, then we
// create a SocketChannel, otherwise a ServerSocketChannel.
// If the socket is a datagram socket then create a DatagramChannel
Channel c;
if (st == SOCK_STREAM) {
} else {
assert port > 0;
}
} else {
}
return c;
}
private static boolean haveChannel = false;
/*
* Returns a Channel representing the inherited channel if the
* inherited channel is a stream connected to a network socket.
*/
if (devnull < 0) {
}
// If we don't have the channel try to create it
if (!haveChannel) {
channel = createChannel();
haveChannel = true;
}
// if there is a channel then do the security check before
// returning it.
}
return channel;
}
// -- Native methods --
static {
}
}