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/runtime/FindProperty.java

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

package jdk.nashorn.internal.runtime;

import static jdk.nashorn.internal.lookup.Lookup.MH;
import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.isValid;

import java.lang.invoke.MethodHandle;
import jdk.dynalink.linker.LinkRequest;
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import jdk.nashorn.internal.objects.Global;

/**
 * This class represents the result from a find property search.
 */
public final class FindProperty {
    /** Object where search began. */
    private final ScriptObject self;

    /** Object where search finish. */
    private final ScriptObject prototype;

    /** Found property. */
    private final Property     property;

    /**
     * Constructor
     *
     * @param self      script object where search began
     * @param prototype prototype where property was found, may be {@code self} if not inherited
     * @param property  property that was search result
     */
    public FindProperty(final ScriptObject self, final ScriptObject prototype, final Property property) {
        this.self      = self;
        this.prototype = prototype;
        this.property  = property;
    }

    /**
     * Return a copy of this FindProperty with a different property.
     *
     * @param newProperty the new property
     * @return the new FindProperty instance
     */
    public FindProperty replaceProperty(final Property newProperty) {
        assert this.property.getKey().equals(newProperty.getKey());
        assert this.property.getSlot() == newProperty.getSlot();
        return new FindProperty(self, prototype, newProperty);
    }

    /**
     * Ask for a getter that returns the given type. The type has nothing to do with the
     * internal representation of the property. It may be an Object (boxing primitives) or
     * a primitive (primitive fields with -Dnashorn.fields.dual=true)
     * @see ObjectClassGenerator
     *
     * @param type type of getter, e.g. int.class if we want a function with {@code get()I} signature
     * @param programPoint program point, or INVALID_PROGRAM_POINT if pessimistic
     * @param request link request
     *
     * @return method handle for the getter
     */
    public MethodHandle getGetter(final Class<?> type, final int programPoint, final LinkRequest request) {
        MethodHandle getter;
        if (isValid(programPoint)) {
            getter = property.getOptimisticGetter(type, programPoint);
        } else {
            getter = property.getGetter(type);
        }
        if (property instanceof UserAccessorProperty) {
            getter = MH.insertArguments(getter, 1, UserAccessorProperty.getINVOKE_UA_GETTER(type, programPoint));
            if (isValid(programPoint) && type.isPrimitive()) {
                getter = MH.insertArguments(getter, 1, programPoint);
            }
            property.setType(type);
            return insertAccessorsGetter((UserAccessorProperty) property, request, getter);
        }
        return getter;
    }

    /**
     * Ask for a setter that sets the given type. The type has nothing to do with the
     * internal representation of the property. It may be an Object (boxing primitives) or
     * a primitive (primitive fields with -Dnashorn.fields.dual=true)
     * @see ObjectClassGenerator
     *
     * @param type type of setter, e.g. int.class if we want a function with {@code set(I)V} signature
     * @param strict are we in strict mode
     * @param request link request
     *
     * @return method handle for the getter
     */
    public MethodHandle getSetter(final Class<?> type, final boolean strict, final LinkRequest request) {
        MethodHandle setter = property.getSetter(type, getOwner().getMap());
        if (property instanceof UserAccessorProperty) {
            setter =  MH.insertArguments(setter, 1, UserAccessorProperty.getINVOKE_UA_SETTER(type), strict ? property.getKey() : null);
            property.setType(type);
            return insertAccessorsGetter((UserAccessorProperty) property, request, setter);
        }

        return setter;
    }

    // Fold an accessor getter into the method handle of a user accessor property.
    private MethodHandle insertAccessorsGetter(final UserAccessorProperty uap, final LinkRequest request, final MethodHandle mh) {
        MethodHandle superGetter = uap.getAccessorsGetter();
        if (!isSelf()) {
            superGetter = ScriptObject.addProtoFilter(superGetter, getProtoChainLength());
        }
        if (request != null && !(request.getReceiver() instanceof ScriptObject)) {
            final MethodHandle wrapFilter = Global.getPrimitiveWrapFilter(request.getReceiver());
            superGetter = MH.filterArguments(superGetter, 0, wrapFilter.asType(wrapFilter.type().changeReturnType(superGetter.type().parameterType(0))));
        }
        superGetter = MH.asType(superGetter, superGetter.type().changeParameterType(0, Object.class));

        return MH.foldArguments(mh, superGetter);
    }

    /**
     * Return the {@code ScriptObject} owning of the property:  this means the prototype.
     * @return owner of property
     */
    public ScriptObject getOwner() {
        return prototype;
    }

    /**
     * Return the {@code ScriptObject} where the search started. This is usually the ScriptObject the
     * operation was started on, except for properties found inside a 'with' statement, where it is the
     * top-level 'with' expression object.
     *
     * @return the start object.
     */
    public ScriptObject getSelf() {
        return self;
    }

    /**
     * Return the appropriate receiver for a getter.
     * @return appropriate receiver
     */
    public ScriptObject getGetterReceiver() {
        return property != null && property.isAccessorProperty() ? self : prototype;
    }

    /**
     * Return the appropriate receiver for a setter.
     * @return appropriate receiver
     */
    public ScriptObject getSetterReceiver() {
        return property != null && property.hasSetterFunction(prototype) ? self : prototype;
    }

    /**
     * Return the property that was found
     * @return property
     */
    public Property getProperty() {
        return property;
    }

    /**
     * Check if the property found was inherited from a prototype and it is an ordinary
     * property (one that has no accessor function).
     * @return true if the found property is an inherited ordinary property
     */
    public boolean isInheritedOrdinaryProperty() {
        return !isSelf() && !getProperty().isAccessorProperty();
    }

    /**
     * Check if the property found was NOT inherited, i.e. defined in the script
     * object, rather than in the prototype
     * @return true if not inherited
     */
    public boolean isSelf() {
        return self == prototype;
    }

    /**
     * Check if the property is in the scope
     * @return true if on scope
     */
    public boolean isScope() {
        return prototype.isScope();
    }

    /**
     * Get the property value from self as object.
     * @return the property value
     */
    public int getIntValue() {
        return property.getIntValue(getGetterReceiver(), getOwner());
    }
    /**
     * Get the property value from self as object.
     * @return the property value
     */
    public double getDoubleValue() {
        return property.getDoubleValue(getGetterReceiver(), getOwner());
    }
    /**
     * Get the property value from self as object.
     * @return the property value
     */
    public Object getObjectValue() {
        return property.getObjectValue(getGetterReceiver(), getOwner());
    }

    /**
     * Set the property value in self.
     *
     * @param value the new value
     * @param strict strict flag
     */
    public void setValue(final int value, final boolean strict) {
        property.setValue(getSetterReceiver(), getOwner(), value, strict);
    }

    /**
     * Set the property value in self.
     *
     * @param value the new value
     * @param strict strict flag
     */
    public void setValue(final double value, final boolean strict) {
        property.setValue(getSetterReceiver(), getOwner(), value, strict);
    }

    /**
     * Set the property value in self.
     *
     * @param value the new value
     * @param strict strict flag
     */
    public void setValue(final Object value, final boolean strict) {
        property.setValue(getSetterReceiver(), getOwner(), value, strict);
    }

    /**
     * Get the number of objects in the prototype chain between the {@code self} and the
     * {@code owner} objects.
     * @return the prototype chain length
     */
    int getProtoChainLength() {
        assert self != null;
        int length = 0;
        for (ScriptObject obj = self; obj != prototype; obj = obj.getProto()) {
            assert !(obj instanceof WithObject);
            ++length;
        }
        return length;
    }

    @Override
    public String toString() {
        return "[FindProperty: " + property.getKey() + ']';
    }

}

jdk/nashorn/internal/runtime/FindProperty.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, 108105👍, 0💬