Java Code Examples for jdk.nashorn.internal.objects.annotations.Getter

The following examples show how to use jdk.nashorn.internal.objects.annotations.Getter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: openjdk-jdk8u   Source File: NativeArray.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (isArray(self)) {
        final long length = ((ScriptObject) self).getArray().length();
        assert length >= 0L;
        // Cast to the narrowest supported numeric type to help optimistic type calculator
        if (length <= Integer.MAX_VALUE) {
            return (int) length;
        }
        return (double) length;
    }

    return 0;
}
 
Example 2
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter of the Uint32Array property.
 *
 * @param self self reference
 * @return the value of the Uint32Array property
 */
@Getter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint32Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint32Array == LAZY_SENTINEL) {
        global.uint32Array = global.getBuiltinUint32Array();
    }
    return global.uint32Array;
}
 
Example 3
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for ECMA 15.1.4.7 Date property
 *
 * @param self self reference
 * @return Date property value
 */
@Getter(name = "Date", attributes = Attribute.NOT_ENUMERABLE)
public static Object getDate(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.date == LAZY_SENTINEL) {
        global.date = global.getBuiltinDate();
    }
    return global.date;
}
 
Example 4
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for ECMA 15.1.4.8 RegExp property
 *
 * @param self self reference
 * @return RegExp property value
 */
@Getter(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE)
public static Object getRegExp(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.regexp == LAZY_SENTINEL) {
        global.regexp = global.getBuiltinRegExp();
    }
    return global.regexp;
}
 
Example 5
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for ECMA 15.1.4.7 Date property
 *
 * @param self self reference
 * @return Date property value
 */
@Getter(name = "Date", attributes = Attribute.NOT_ENUMERABLE)
public static Object getDate(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.date == LAZY_SENTINEL) {
        global.date = global.getBuiltinDate();
    }
    return global.date;
}
 
Example 6
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the RangeError property.
 * @param self self reference
 * @return the value of RangeError property
 */
@Getter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE)
public static Object getRangeError(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.rangeError == LAZY_SENTINEL) {
        global.rangeError = global.getBuiltinRangeError();
    }
    return global.rangeError;
}
 
Example 7
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the DataView property.
 * @param self self reference
 * @return the value of the DataView property
 */
@Getter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE)
public static Object getDataView(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.dataView == LAZY_SENTINEL) {
        global.dataView = global.getBuiltinDataView();
    }
    return global.dataView;
}
 
Example 8
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Nashorn extension: Java access - global.JavaImporter.
 *
 * @param self self reference
 * @return the value of the JavaImporter property
 */
@Getter(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJavaImporter(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.javaImporter == LAZY_SENTINEL) {
        global.javaImporter = global.getBuiltinJavaImporter();
    }
    return global.javaImporter;
}
 
Example 9
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Uin8Array property.
 * @param self self reference
 * @return the value of the Uint8Array property
 */
@Getter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint8Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint8Array == LAZY_SENTINEL) {
        global.uint8Array = global.getBuiltinUint8Array();
    }
    return global.uint8Array;
}
 
Example 10
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Int16Array property.
 * @param self self reference
 * @return the value of the Int16Array property
 */
@Getter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getInt16Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.int16Array == LAZY_SENTINEL) {
        global.int16Array = global.getBuiltinInt16Array();
    }
    return global.int16Array;
}
 
Example 11
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Uint16Array property.
 * @param self self reference
 * @return the value of the Uint16Array property
 */
@Getter(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint16Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint16Array == LAZY_SENTINEL) {
        global.uint16Array = global.getBuiltinUint16Array();
    }
    return global.uint16Array;
}
 
Example 12
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Int32Array property.
 *
 * @param self self reference
 * @return the value of the Int32Array property
 */
@Getter(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getInt32Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.int32Array == LAZY_SENTINEL) {
        global.int32Array = global.getBuiltinInt32Array();
    }
    return global.int32Array;
}
 
Example 13
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter of the Uint32Array property.
 *
 * @param self self reference
 * @return the value of the Uint32Array property
 */
@Getter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint32Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint32Array == LAZY_SENTINEL) {
        global.uint32Array = global.getBuiltinUint32Array();
    }
    return global.uint32Array;
}
 
Example 14
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Float32Array property.
 *
 * @param self self reference
 * @return the value of the Float32Array property
 */
@Getter(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getFloat32Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.float32Array == LAZY_SENTINEL) {
        global.float32Array = global.getBuiltinFloat32Array();
    }
    return global.float32Array;
}
 
Example 15
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Float64Array property.
 *
 * @param self self reference
 * @return the value of the Float64Array property
 */
@Getter(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getFloat64Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.float64Array == LAZY_SENTINEL) {
        global.float64Array = global.getBuiltinFloat64Array();
    }
    return global.float64Array;
}
 
Example 16
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Nashorn extension: global.Java property.
 *
 * @param self self reference
 * @return the value of the Java property
 */
@Getter(name = "Java", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJavaApi(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.javaApi == LAZY_SENTINEL) {
        global.javaApi = global.getBuiltinJavaApi();
    }
    return global.javaApi;
}
 
Example 17
Source Project: TencentKona-8   Source File: NativeArray.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (isArray(self)) {
        final long length = ((ScriptObject) self).getArray().length();
        assert length >= 0L;
        // Cast to the narrowest supported numeric type to help optimistic type calculator
        if (length <= Integer.MAX_VALUE) {
            return (int) length;
        }
        return (double) length;
    }

    return 0;
}
 
Example 18
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Int8Array property.
 * @param self self reference
 * @return the value of the Int8Array property.
 */
@Getter(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getInt8Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.int8Array == LAZY_SENTINEL) {
        global.int8Array = global.getBuiltinInt8Array();
    }
    return global.int8Array;
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the DataView property.
 * @param self self reference
 * @return the value of the DataView property
 */
@Getter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE)
public static Object getDataView(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.dataView == LAZY_SENTINEL) {
        global.dataView = global.getBuiltinDataView();
    }
    return global.dataView;
}
 
Example 20
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for Nashorn extension: global.JSAdapter
 * @param self self reference
 * @return value of the JSAdapter property
 */
@Getter(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJSAdapter(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.jsadapter == LAZY_SENTINEL) {
        global.jsadapter = global.getBuiltinJSAdapter();
    }
    return global.jsadapter;
}
 
Example 21
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Int16Array property.
 * @param self self reference
 * @return the value of the Int16Array property
 */
@Getter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getInt16Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.int16Array == LAZY_SENTINEL) {
        global.int16Array = global.getBuiltinInt16Array();
    }
    return global.int16Array;
}
 
Example 22
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Uin8Array property.
 * @param self self reference
 * @return the value of the Uint8Array property
 */
@Getter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint8Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint8Array == LAZY_SENTINEL) {
        global.uint8Array = global.getBuiltinUint8Array();
    }
    return global.uint8Array;
}
 
Example 23
/**
 * Length getter
 * @param self self reference
 * @return length property value
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (self instanceof ScriptObject) {
        return (double) JSType.toUint32(((ScriptObject)self).getArray().length());
    }

    return 0;
}
 
Example 24
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for ECMA 15.12 - The JSON property
 * @param self self reference
 * @return the value of JSON property
 */
@Getter(name = "JSON", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJSON(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.json == LAZY_SENTINEL) {
        global.json = global.getBuiltinJSON();
    }
    return global.json;
}
 
Example 25
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for Nashorn extension: global.JSAdapter
 * @param self self reference
 * @return value of the JSAdapter property
 */
@Getter(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJSAdapter(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.jsadapter == LAZY_SENTINEL) {
        global.jsadapter = global.getBuiltinJSAdapter();
    }
    return global.jsadapter;
}
 
Example 26
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the EvalError property
 * @param self self reference
 * @return the value of EvalError property
 */
@Getter(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE)
public static Object getEvalError(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.evalError == LAZY_SENTINEL) {
        global.evalError = global.getBuiltinEvalError();
    }
    return global.evalError;
}
 
Example 27
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the RangeError property.
 * @param self self reference
 * @return the value of RangeError property
 */
@Getter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE)
public static Object getRangeError(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.rangeError == LAZY_SENTINEL) {
        global.rangeError = global.getBuiltinRangeError();
    }
    return global.rangeError;
}
 
Example 28
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the URIError property.
 * @param self self reference
 * @return the value of URIError property
 */
@Getter(name = "URIError", attributes = Attribute.NOT_ENUMERABLE)
public static Object getURIError(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uriError == LAZY_SENTINEL) {
        global.uriError = global.getBuiltinURIError();
    }
    return global.uriError;
}
 
Example 29
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the ArrayBuffer property.
 * @param self self reference
 * @return the value of the ArrayBuffer property
 */
@Getter(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE)
public static Object getArrayBuffer(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.arrayBuffer == LAZY_SENTINEL) {
        global.arrayBuffer = global.getBuiltinArrayBuffer();
    }
    return global.arrayBuffer;
}
 
Example 30
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the DataView property.
 * @param self self reference
 * @return the value of the DataView property
 */
@Getter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE)
public static Object getDataView(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.dataView == LAZY_SENTINEL) {
        global.dataView = global.getBuiltinDataView();
    }
    return global.dataView;
}
 
Example 31
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for ECMA 15.12 - The JSON property
 * @param self self reference
 * @return the value of JSON property
 */
@Getter(name = "JSON", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJSON(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.json == LAZY_SENTINEL) {
        global.json = global.getBuiltinJSON();
    }
    return global.json;
}
 
Example 32
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Uin8Array property.
 * @param self self reference
 * @return the value of the Uint8Array property
 */
@Getter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint8Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint8Array == LAZY_SENTINEL) {
        global.uint8Array = global.getBuiltinUint8Array();
    }
    return global.uint8Array;
}
 
Example 33
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Int16Array property.
 * @param self self reference
 * @return the value of the Int16Array property
 */
@Getter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getInt16Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.int16Array == LAZY_SENTINEL) {
        global.int16Array = global.getBuiltinInt16Array();
    }
    return global.int16Array;
}
 
Example 34
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter of the Uint32Array property.
 *
 * @param self self reference
 * @return the value of the Uint32Array property
 */
@Getter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getUint32Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.uint32Array == LAZY_SENTINEL) {
        global.uint32Array = global.getBuiltinUint32Array();
    }
    return global.uint32Array;
}
 
Example 35
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Float32Array property.
 *
 * @param self self reference
 * @return the value of the Float32Array property
 */
@Getter(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE)
public static Object getFloat32Array(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.float32Array == LAZY_SENTINEL) {
        global.float32Array = global.getBuiltinFloat32Array();
    }
    return global.float32Array;
}
 
Example 36
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Nashorn extension: Java access - global.javaImporter.
 *
 * @param self self reference
 * @return the value of the JavaImporter property
 */
@Getter(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJavaImporter(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.javaImporter == LAZY_SENTINEL) {
        global.javaImporter = global.getBuiltinJavaImporter();
    }
    return global.javaImporter;
}
 
Example 37
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter for the Nashorn extension: global.Java property.
 *
 * @param self self reference
 * @return the value of the Java property
 */
@Getter(name = "Java", attributes = Attribute.NOT_ENUMERABLE)
public static Object getJavaApi(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.javaApi == LAZY_SENTINEL) {
        global.javaApi = global.getBuiltinJavaApi();
    }
    return global.javaApi;
}
 
Example 38
Source Project: jdk8u60   Source File: NativeArray.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Length getter
 * @param self self reference
 * @return the length of the object
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (isArray(self)) {
        return JSType.toUint32(((ScriptObject) self).getArray().length());
    }

    return 0;
}
 
Example 39
Source Project: jdk8u60   Source File: NativeRegExp.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Getter for non-standard RegExp.$3 property.
 * @param self self object
 * @return last regexp input
 */
@Getter(where = Where.CONSTRUCTOR, attributes = Attribute.CONSTANT, name = "$3")
public static Object getGroup3(final Object self) {
    final RegExpResult match = Global.instance().getLastRegExpResult();
    return match == null ? "" : match.getGroup(3);
}
 
Example 40
Source Project: openjdk-jdk8u   Source File: NativeRegExp.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Getter for non-standard RegExp.input property.
 * @param self self object
 * @return last regexp input
 */
@Getter(where = Where.CONSTRUCTOR, attributes = Attribute.CONSTANT, name = "input")
public static Object getLastInput(final Object self) {
    final RegExpResult match = Global.instance().getLastRegExpResult();
    return match == null ? "" : match.getInput();
}