JDK 11 java.base.jmod - Base Module

JDK 11 java.base.jmod is the JMOD file for JDK 11 Base module.

JDK 11 Base module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\java.base.jmod.

JDK 11 Base module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.

JDK 11 Base module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\java.base.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

sun/net/www/MeteredStream.java

/*
 * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package sun.net.www;

import java.net.URL;
import java.util.*;
import java.io.*;
import sun.net.ProgressSource;
import sun.net.www.http.ChunkedInputStream;


public class MeteredStream extends FilterInputStream {

    // Instance variables.
    /* if expected != -1, after we've read >= expected, we're "closed" and return -1
     * from subsequest read() 's
     */
    protected boolean closed = false;
    protected long expected;
    protected long count = 0;
    protected long markedCount = 0;
    protected int markLimit = -1;
    protected ProgressSource pi;

    public MeteredStream(InputStream is, ProgressSource pi, long expected)
    {
        super(is);

        this.pi = pi;
        this.expected = expected;

        if (pi != null) {
            pi.updateProgress(0, expected);
        }
    }

    private final void justRead(long n) throws IOException   {
        if (n == -1) {

            /*
             * don't close automatically when mark is set and is valid;
             * cannot reset() after close()
             */
            if (!isMarked()) {
                close();
            }
            return;
        }

        count += n;

        /**
         * If read beyond the markLimit, invalidate the mark
         */
        if (count - markedCount > markLimit) {
            markLimit = -1;
        }

        if (pi != null)
            pi.updateProgress(count, expected);

        if (isMarked()) {
            return;
        }

        // if expected length is known, we could determine if
        // read overrun.
        if (expected > 0)   {
            if (count >= expected) {
                close();
            }
        }
    }

    /**
     * Returns true if the mark is valid, false otherwise
     */
    private boolean isMarked() {

        if (markLimit < 0) {
            return false;
        }

        // mark is set, but is not valid anymore
        if (count - markedCount > markLimit) {
           return false;
        }

        // mark still holds
        return true;
    }

    public synchronized int read() throws java.io.IOException {
        if (closed) {
            return -1;
        }
        int c = in.read();
        if (c != -1) {
            justRead(1);
        } else {
            justRead(c);
        }
        return c;
    }

    public synchronized int read(byte b[], int off, int len)
                throws java.io.IOException {
        if (closed) {
            return -1;
        }
        int n = in.read(b, off, len);
        justRead(n);
        return n;
    }

    public synchronized long skip(long n) throws IOException {

        // REMIND: what does skip do on EOF????
        if (closed) {
            return 0;
        }

        if (in instanceof ChunkedInputStream) {
            n = in.skip(n);
        }
        else {
            // just skip min(n, num_bytes_left)
            long min = (n > expected - count) ? expected - count: n;
            n = in.skip(min);
        }
        justRead(n);
        return n;
    }

    public void close() throws IOException {
        if (closed) {
            return;
        }
        if (pi != null)
            pi.finishTracking();

        closed = true;
        in.close();
    }

    public synchronized int available() throws IOException {
        return closed ? 0: in.available();
    }

    public synchronized void mark(int readLimit) {
        if (closed) {
            return;
        }
        super.mark(readLimit);

        /*
         * mark the count to restore upon reset
         */
        markedCount = count;
        markLimit = readLimit;
    }

    public synchronized void reset() throws IOException {
        if (closed) {
            return;
        }

        if (!isMarked()) {
            throw new IOException ("Resetting to an invalid mark");
        }

        count = markedCount;
        super.reset();
    }

    public boolean markSupported() {
        if (closed) {
            return false;
        }
        return super.markSupported();
    }

    @SuppressWarnings("deprecation")
    protected void finalize() throws Throwable {
        try {
            close();
            if (pi != null)
                pi.close();
        }
        finally {
            // Call super class
            super.finalize();
        }
    }
}

sun/net/www/MeteredStream.java

 

Or download all of them as a single archive file:

File name: java.base-11.0.1-src.zip
File size: 8740354 bytes
Release date: 2018-11-04
Download 

 

JDK 11 java.compiler.jmod - Compiler Module

JDK 11 Modules List

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-05-29, 207093👍, 0💬