/**
     * The "standard" input stream. This stream is already 
     * open and ready to supply input data. Typically this stream 
     * corresponds to keyboard input or another input source specified by 
     * the host environment or user. 
     */
    public final static InputStream in = nullInputStream();源代码如上

解决方案 »

  1.   

    /**
         * The following two methods exist because in, out, and err must be
         * initialized to null.  The compiler, however, cannot be permitted to
         * inline access to them, since they are later set to more sensible values
         * by initializeSystemClass().
         */
        private static InputStream nullInputStream() throws NullPointerException {
    if (currentTimeMillis() > 0)
        return null;
    throw new NullPointerException();
        }    private static PrintStream nullPrintStream() throws NullPointerException {
    if (currentTimeMillis() > 0)
        return null;
    throw new NullPointerException();
        }
      

  2.   

    /**
         * Initialize the system class.  Called after thread initialization.
         */
        private static void initializeSystemClass() {
    props = new Properties();
    initProperties(props);
    sun.misc.Version.init();
    FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
    FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
    FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
    setIn0(new BufferedInputStream(fdIn));
    setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
    setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true)); // Enough of the world is now in place that we can risk
            // initializing the logging configuration.
    try {
        java.util.logging.LogManager.getLogManager().readConfiguration();
    } catch (Exception ex) {
        // System.err.println("Can't read logging configuration:");
        // ex.printStackTrace();
    } // Load the zip library now in order to keep java.util.zip.ZipFile
    // from trying to use itself to load this library later.
    loadLibrary("zip"); // Subsystems that are invoked during initialization can invoke
    // sun.misc.VM.isBooted() in order to avoid doing things that should
    // wait until the application class loader has been set up.
    sun.misc.VM.booted();
        }