JDK 11 jdk.scripting.nashorn.jmod - Scripting Nashorn Module

JDK 11 jdk.scripting.nashorn.jmod is the JMOD file for JDK 11 Scripting Nashorn module.

JDK 11 Scripting Nashorn module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\jdk.scripting.nashorn.jmod.

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

JDK 11 Scripting Nashorn module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.scripting.nashorn.

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

✍: FYIcenter

jdk/nashorn/internal/parser/Token.java

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

package jdk.nashorn.internal.parser;

import static jdk.nashorn.internal.parser.TokenKind.LITERAL;

import jdk.nashorn.internal.runtime.Source;

/**
 * A token is a 64 bit long value that represents a basic parse/lex unit.
 * This class provides static methods to manipulate lexer tokens.
 */
public class Token {

    /**
     * We use 28 bits for the position and 28 bits for the length of the token.
     * This limits the maximal length of code we can handle to 2 ^ 28 - 1 bytes.
     */
    public final static int LENGTH_MASK = 0xfffffff;

    // The first 8 bits are used for the token type, followed by length and position
    private final static int LENGTH_SHIFT = 8;
    private final static int POSITION_SHIFT  = 36;

    private Token() {
    }

    /**
     * Create a compact form of token information.
     * @param type     Type of token.
     * @param position Start position of the token in the source.
     * @param length   Length of the token.
     * @return Token descriptor.
     */
    public static long toDesc(final TokenType type, final int position, final int length) {
        assert position <= LENGTH_MASK && length <= LENGTH_MASK;
        return (long)position << POSITION_SHIFT |
               (long)length   << LENGTH_SHIFT  |
               type.ordinal();
    }

    /**
     * Extract token position from a token descriptor.
     * @param token Token descriptor.
     * @return Start position of the token in the source.
     */
    public static int descPosition(final long token) {
        return (int)(token >>> POSITION_SHIFT);
    }

    /**
     * Normally returns the token itself, except in case of string tokens
     * which report their position past their opening delimiter and thus
     * need to have position and length adjusted.
     *
     * @param token Token descriptor.
     * @return same or adjusted token.
     */
    public static long withDelimiter(final long token) {
        final TokenType tokenType = Token.descType(token);
        switch(tokenType) {
            case STRING:
            case ESCSTRING:
            case EXECSTRING:
            case TEMPLATE:
            case TEMPLATE_TAIL: {
                final int start = Token.descPosition(token) - 1;
                final int len = Token.descLength(token) + 2;
                return toDesc(tokenType, start, len);
            }
            case TEMPLATE_HEAD:
            case TEMPLATE_MIDDLE: {
                final int start = Token.descPosition(token) - 1;
                final int len = Token.descLength(token) + 3;
                return toDesc(tokenType, start, len);
            }
            default: {
                return token;
            }
        }
    }

    /**
     * Extract token length from a token descriptor.
     * @param token Token descriptor.
     * @return Length of the token.
     */
    public static int descLength(final long token) {
        return (int)((token >>> LENGTH_SHIFT) & LENGTH_MASK);
    }

    /**
     * Extract token type from a token descriptor.
     * @param token Token descriptor.
     * @return Type of token.
     */
    public static TokenType descType(final long token) {
        return TokenType.getValues()[(int)token & 0xff];
    }

    /**
     * Change the token to use a new type.
     *
     * @param token   The original token.
     * @param newType The new token type.
     * @return The recast token.
     */
    public static long recast(final long token, final TokenType newType) {
        return token & ~0xFFL | newType.ordinal();
    }

    /**
     * Return a string representation of a token.
     * @param source  Token source.
     * @param token   Token descriptor.
     * @param verbose True to include details.
     * @return String representation.
     */
    public static String toString(final Source source, final long token, final boolean verbose) {
        final TokenType type = Token.descType(token);
        String result;

        if (source != null && type.getKind() == LITERAL) {
            result = source.getString(token);
        } else {
            result = type.getNameOrType();
        }

        if (verbose) {
            final int position = Token.descPosition(token);
            final int length = Token.descLength(token);
            result += " (" + position + ", " + length + ")";
        }

        return result;
    }

    /**
     * String conversion of token
     *
     * @param source the source
     * @param token  the token
     *
     * @return token as string
     */
    public static String toString(final Source source, final long token) {
        return Token.toString(source, token, false);
    }

    /**
     * String conversion of token - version without source given
     *
     * @param token  the token
     *
     * @return token as string
     */
    public static String toString(final long token) {
        return Token.toString(null, token, false);
    }

    /**
     * Static hash code computation function token
     *
     * @param token a token
     *
     * @return hash code for token
     */
    public static int hashCode(final long token) {
        return (int)(token ^ token >>> 32);
    }

}

jdk/nashorn/internal/parser/Token.java

 

Or download all of them as a single archive file:

File name: jdk.scripting.nashorn-11.0.1-src.zip
File size: 1390965 bytes
Release date: 2018-11-04
Download 

 

JDK 11 jdk.scripting.nashorn.shell.jmod - Scripting Nashorn Shell Module

JDK 11 jdk.rmic.jmod - RMI Compiler Tool

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-04-25, 108174👍, 0💬