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/codegen/FunctionSignature.java

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

package jdk.nashorn.internal.codegen;

import static jdk.nashorn.internal.lookup.Lookup.MH;

import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.Expression;
import jdk.nashorn.internal.ir.FunctionNode;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;

/**
 * Class that generates function signatures for dynamic calls
 */
public final class FunctionSignature {

    /** parameter types that ASM can understand */
    private final Type[] paramTypes;

    /** return type that ASM can understand */
    private final Type returnType;

    /** valid Java descriptor string for function */
    private final String descriptor;

    /** {@link MethodType} for function */
    private final MethodType methodType;

    /**
     * Constructor
     *
     * Create a FunctionSignature given arguments as AST Nodes
     *
     * @param hasSelf   does the function have a self slot?
     * @param hasCallee does the function need a callee variable
     * @param retType   what is the return type
     * @param args      argument list of AST Nodes
     */
    public FunctionSignature(final boolean hasSelf, final boolean hasCallee, final Type retType, final List<? extends Expression> args) {
        this(hasSelf, hasCallee, retType, FunctionSignature.typeArray(args));
    }

    /**
     * Constructor
     *
     * Create a FunctionSignature given arguments as AST Nodes
     *
     * @param hasSelf does the function have a self slot?
     * @param hasCallee does the function need a callee variable
     * @param retType what is the return type
     * @param nArgs   number of arguments
     */
    public FunctionSignature(final boolean hasSelf, final boolean hasCallee, final Type retType, final int nArgs) {
        this(hasSelf, hasCallee, retType, FunctionSignature.objectArgs(nArgs));
    }

    /**
     * Constructor
     *
     * Create a FunctionSignature given argument types only
     *
     * @param hasSelf   does the function have a self slot?
     * @param hasCallee does the function have a callee slot?
     * @param retType   what is the return type
     * @param argTypes  argument list of AST Nodes
     */
    private FunctionSignature(final boolean hasSelf, final boolean hasCallee, final Type retType, final Type... argTypes) {
        final boolean isVarArg;

        int count = 1;

        if (argTypes == null) {
            isVarArg = true;
        } else {
            isVarArg = argTypes.length > LinkerCallSite.ARGLIMIT;
            count    = isVarArg ? 1 : argTypes.length;
        }

        if (hasCallee) {
            count++;
        }
        if (hasSelf) {
            count++;
        }

        paramTypes = new Type[count];

        int next = 0;
        if (hasCallee) {
            paramTypes[next++] = Type.typeFor(ScriptFunction.class);
        }

        if (hasSelf) {
            paramTypes[next++] = Type.OBJECT;
        }

        if (isVarArg) {
            paramTypes[next] = Type.OBJECT_ARRAY;
        } else if (argTypes != null) {
            for (int j = 0; next < count;) {
                final Type type = argTypes[j++];
                // TODO: for now, turn java/lang/String into java/lang/Object as we aren't as specific.
                paramTypes[next++] = type.isObject() ? Type.OBJECT : type;
            }
        } else {
            assert false : "isVarArgs cannot be false when argTypes are null";
        }

        this.returnType = retType;
        this.descriptor = Type.getMethodDescriptor(returnType, paramTypes);

        final List<Class<?>> paramTypeList = new ArrayList<>();
        for (final Type paramType : paramTypes) {
            paramTypeList.add(paramType.getTypeClass());
        }

        this.methodType = MH.type(returnType.getTypeClass(), paramTypeList.toArray(new Class<?>[0]));
    }

    /**
     * Create a function signature given a function node, using as much
     * type information for parameters and return types that is available
     *
     * @param functionNode the function node
     */
    public FunctionSignature(final FunctionNode functionNode) {
        this(
            true,
            functionNode.needsCallee(),
            functionNode.getReturnType(),
            (functionNode.isVarArg() && !functionNode.isProgram()) ?
                null :
                functionNode.getParameters());
    }

    /**
     * Internal function that converts an array of nodes to their Types
     *
     * @param args node arg list
     *
     * @return the array of types
     */
    private static Type[] typeArray(final List<? extends Expression> args) {
        if (args == null) {
            return null;
        }

        final Type[] typeArray = new Type[args.size()];

        int pos = 0;
        for (final Expression arg : args) {
            typeArray[pos++] = arg.getType();
        }

        return typeArray;
    }

    @Override
    public String toString() {
        return descriptor;
    }

    /**
     * @return the number of param types
     */
    public int size() {
        return paramTypes.length;
    }

    /**
     * Get the param types for this function signature
     * @return cloned vector of param types
     */
    public Type[] getParamTypes() {
        return paramTypes.clone();
    }

    /**
     * Return the {@link MethodType} for this function signature
     * @return the method type
     */
    public MethodType getMethodType() {
        return methodType;
    }

    /**
     * Return the return type for this function signature
     * @return the return type
     */
    public Type getReturnType() {
        return returnType;
    }

    private static Type[] objectArgs(final int nArgs) {
        final Type[] array = new Type[nArgs];
        for (int i = 0; i < nArgs; i++) {
            array[i] = Type.OBJECT;
        }
        return array;
    }

}

jdk/nashorn/internal/codegen/FunctionSignature.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, 107947👍, 0💬