aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsundar <none@none>2014-03-27 19:39:18 +0530
committersundar <none@none>2014-03-27 19:39:18 +0530
commit75ef81b44ff36b9daca924d374a13e3803328758 (patch)
tree1e1b1d1f3f83ee9e677d87c4611a8625f5ba27df /src
parent411279c21b8faef8340ec436042f5fe45b0bfd0e (diff)
downloadnashorn-75ef81b44ff36b9daca924d374a13e3803328758.tar.gz
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
Reviewed-by: lagergren, jlaskey
Diffstat (limited to 'src')
-rw-r--r--src/jdk/nashorn/internal/objects/ArrayBufferView.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeArray.java32
-rw-r--r--src/jdk/nashorn/internal/objects/NativeArrayBuffer.java4
-rw-r--r--src/jdk/nashorn/internal/objects/NativeBoolean.java4
-rw-r--r--src/jdk/nashorn/internal/objects/NativeDataView.java6
-rw-r--r--src/jdk/nashorn/internal/objects/NativeDate.java105
-rw-r--r--src/jdk/nashorn/internal/objects/NativeDebug.java10
-rw-r--r--src/jdk/nashorn/internal/objects/NativeError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeEvalError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeFloat32Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeFloat64Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeFunction.java10
-rw-r--r--src/jdk/nashorn/internal/objects/NativeInt16Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeInt32Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeInt8Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeJSAdapter.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeJava.java4
-rw-r--r--src/jdk/nashorn/internal/objects/NativeJavaImporter.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeNumber.java14
-rw-r--r--src/jdk/nashorn/internal/objects/NativeObject.java31
-rw-r--r--src/jdk/nashorn/internal/objects/NativeRangeError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeReferenceError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeRegExp.java26
-rw-r--r--src/jdk/nashorn/internal/objects/NativeString.java64
-rw-r--r--src/jdk/nashorn/internal/objects/NativeSyntaxError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeTypeError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeURIError.java2
-rw-r--r--src/jdk/nashorn/internal/objects/NativeUint16Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeUint32Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeUint8Array.java8
-rw-r--r--src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java8
31 files changed, 201 insertions, 201 deletions
diff --git a/src/jdk/nashorn/internal/objects/ArrayBufferView.java b/src/jdk/nashorn/internal/objects/ArrayBufferView.java
index 7bd1d2f9..c29af851 100644
--- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java
+++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java
@@ -382,7 +382,7 @@ abstract class ArrayBufferView extends ScriptObject {
return (int) (length & Integer.MAX_VALUE);
}
- protected static Object subarrayImpl(final Object self, final Object begin0, final Object end0) {
+ protected static ScriptObject subarrayImpl(final Object self, final Object begin0, final Object end0) {
final ArrayBufferView arrayView = ((ArrayBufferView)self);
final int elementLength = arrayView.elementLength();
final int begin = NativeArrayBuffer.adjustIndex(JSType.toInt32(begin0), elementLength);
diff --git a/src/jdk/nashorn/internal/objects/NativeArray.java b/src/jdk/nashorn/internal/objects/NativeArray.java
index d95caf2c..6f07cb9d 100644
--- a/src/jdk/nashorn/internal/objects/NativeArray.java
+++ b/src/jdk/nashorn/internal/objects/NativeArray.java
@@ -389,7 +389,7 @@ public final class NativeArray extends ScriptObject {
* @return true if argument is an array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object isArray(final Object self, final Object arg) {
+ public static boolean isArray(final Object self, final Object arg) {
return isArray(arg) || (arg instanceof JSObject && ((JSObject)arg).isArray());
}
@@ -488,7 +488,7 @@ public final class NativeArray extends ScriptObject {
* @return locale specific string representation for array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleString(final Object self) {
+ public static String toLocaleString(final Object self) {
final StringBuilder sb = new StringBuilder();
final Iterator<Object> iter = arrayLikeIterator(self, true);
@@ -534,7 +534,7 @@ public final class NativeArray extends ScriptObject {
* @return the new NativeArray
*/
@Constructor(arity = 1)
- public static Object construct(final boolean newObj, final Object self, final Object... args) {
+ public static NativeArray construct(final boolean newObj, final Object self, final Object... args) {
switch (args.length) {
case 0:
return new NativeArray(0);
@@ -587,7 +587,7 @@ public final class NativeArray extends ScriptObject {
* @return the new NativeArray
*/
@SpecializedConstructor
- public static Object construct(final boolean newObj, final Object self) {
+ public static NativeArray construct(final boolean newObj, final Object self) {
return new NativeArray(0);
}
@@ -602,7 +602,7 @@ public final class NativeArray extends ScriptObject {
* @return the new NativeArray
*/
@SpecializedConstructor
- public static Object construct(final boolean newObj, final Object self, final int length) {
+ public static NativeArray construct(final boolean newObj, final Object self, final int length) {
if (length >= 0) {
return new NativeArray(length);
}
@@ -621,7 +621,7 @@ public final class NativeArray extends ScriptObject {
* @return the new NativeArray
*/
@SpecializedConstructor
- public static Object construct(final boolean newObj, final Object self, final long length) {
+ public static NativeArray construct(final boolean newObj, final Object self, final long length) {
if (length >= 0L && length <= JSType.MAX_UINT) {
return new NativeArray(length);
}
@@ -640,7 +640,7 @@ public final class NativeArray extends ScriptObject {
* @return the new NativeArray
*/
@SpecializedConstructor
- public static Object construct(final boolean newObj, final Object self, final double length) {
+ public static NativeArray construct(final boolean newObj, final Object self, final double length) {
final long uint32length = JSType.toUint32(length);
if (uint32length == length) {
@@ -658,7 +658,7 @@ public final class NativeArray extends ScriptObject {
* @return resulting NativeArray
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object concat(final Object self, final Object... args) {
+ public static NativeArray concat(final Object self, final Object... args) {
final ArrayList<Object> list = new ArrayList<>();
concatToList(list, Global.toObject(self));
@@ -705,7 +705,7 @@ public final class NativeArray extends ScriptObject {
* @return string representation after join
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object join(final Object self, final Object separator) {
+ public static String join(final Object self, final Object separator) {
final StringBuilder sb = new StringBuilder();
final Iterator<Object> iter = arrayLikeIterator(self, true);
final String sep = separator == ScriptRuntime.UNDEFINED ? "," : JSType.toString(separator);
@@ -973,7 +973,7 @@ public final class NativeArray extends ScriptObject {
* @return sorted array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object sort(final Object self, final Object comparefn) {
+ public static ScriptObject sort(final Object self, final Object comparefn) {
try {
final ScriptObject sobj = (ScriptObject) self;
final long len = JSType.toUint32(sobj.getLength());
@@ -1177,7 +1177,7 @@ public final class NativeArray extends ScriptObject {
* @return index of element, or -1 if not found
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object indexOf(final Object self, final Object searchElement, final Object fromIndex) {
+ public static long indexOf(final Object self, final Object searchElement, final Object fromIndex) {
try {
final ScriptObject sobj = (ScriptObject)Global.toObject(self);
final long len = JSType.toUint32(sobj.getLength());
@@ -1213,7 +1213,7 @@ public final class NativeArray extends ScriptObject {
* @return index of element, or -1 if not found
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object lastIndexOf(final Object self, final Object... args) {
+ public static long lastIndexOf(final Object self, final Object... args) {
try {
final ScriptObject sobj = (ScriptObject)Global.toObject(self);
final long len = JSType.toUint32(sobj.getLength());
@@ -1248,7 +1248,7 @@ public final class NativeArray extends ScriptObject {
* @return true if callback function return true for every element in the array, false otherwise
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object every(final Object self, final Object callbackfn, final Object thisArg) {
+ public static boolean every(final Object self, final Object callbackfn, final Object thisArg) {
return applyEvery(Global.toObject(self), callbackfn, thisArg);
}
@@ -1272,7 +1272,7 @@ public final class NativeArray extends ScriptObject {
* @return true if callback function returned true for any element in the array, false otherwise
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object some(final Object self, final Object callbackfn, final Object thisArg) {
+ public static boolean some(final Object self, final Object callbackfn, final Object thisArg) {
return new IteratorAction<Boolean>(Global.toObject(self), callbackfn, thisArg, false) {
private final MethodHandle someInvoker = getSOME_CALLBACK_INVOKER();
@@ -1313,7 +1313,7 @@ public final class NativeArray extends ScriptObject {
* @return array with elements transformed by map function
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object map(final Object self, final Object callbackfn, final Object thisArg) {
+ public static NativeArray map(final Object self, final Object callbackfn, final Object thisArg) {
return new IteratorAction<NativeArray>(Global.toObject(self), callbackfn, thisArg, null) {
private final MethodHandle mapInvoker = getMAP_CALLBACK_INVOKER();
@@ -1342,7 +1342,7 @@ public final class NativeArray extends ScriptObject {
* @return filtered array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object filter(final Object self, final Object callbackfn, final Object thisArg) {
+ public static NativeArray filter(final Object self, final Object callbackfn, final Object thisArg) {
return new IteratorAction<NativeArray>(Global.toObject(self), callbackfn, thisArg, new NativeArray()) {
private long to = 0;
private final MethodHandle filterInvoker = getFILTER_CALLBACK_INVOKER();
diff --git a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
index 49a61c96..70c97daf 100644
--- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
+++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
@@ -45,7 +45,7 @@ final class NativeArrayBuffer extends ScriptObject {
private static PropertyMap $nasgenmap$;
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
+ public static NativeArrayBuffer constructor(final boolean newObj, final Object self, final Object... args) {
if (args.length == 0) {
throw new RuntimeException("missing length argument");
}
@@ -81,7 +81,7 @@ final class NativeArrayBuffer extends ScriptObject {
}
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object slice(final Object self, final Object begin0, final Object end0) {
+ public static NativeArrayBuffer slice(final Object self, final Object begin0, final Object end0) {
final NativeArrayBuffer arrayBuffer = (NativeArrayBuffer)self;
int begin = JSType.toInt32(begin0);
int end = end0 != ScriptRuntime.UNDEFINED ? JSType.toInt32(end0) : arrayBuffer.getByteLength();
diff --git a/src/jdk/nashorn/internal/objects/NativeBoolean.java b/src/jdk/nashorn/internal/objects/NativeBoolean.java
index f737a6c8..d645d6dd 100644
--- a/src/jdk/nashorn/internal/objects/NativeBoolean.java
+++ b/src/jdk/nashorn/internal/objects/NativeBoolean.java
@@ -110,7 +110,7 @@ public final class NativeBoolean extends ScriptObject {
* @return string representation of this boolean
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self) {
+ public static String toString(final Object self) {
return getBoolean(self).toString();
}
@@ -121,7 +121,7 @@ public final class NativeBoolean extends ScriptObject {
* @return value of this boolean
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object valueOf(final Object self) {
+ public static boolean valueOf(final Object self) {
return getBoolean(self);
}
diff --git a/src/jdk/nashorn/internal/objects/NativeDataView.java b/src/jdk/nashorn/internal/objects/NativeDataView.java
index 93b5f09f..414ff8ae 100644
--- a/src/jdk/nashorn/internal/objects/NativeDataView.java
+++ b/src/jdk/nashorn/internal/objects/NativeDataView.java
@@ -131,7 +131,7 @@ public class NativeDataView extends ScriptObject {
* @return newly constructed DataView object
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
+ public static NativeDataView constructor(final boolean newObj, final Object self, final Object... args) {
if (args.length == 0 || !(args[0] instanceof NativeArrayBuffer)) {
throw typeError("not.an.arraybuffer.in.dataview");
}
@@ -157,7 +157,7 @@ public class NativeDataView extends ScriptObject {
* @return newly constructed DataView object
*/
@SpecializedConstructor
- public static Object constructor(final boolean newObj, final Object self, final Object arrBuf, final int offset) {
+ public static NativeDataView constructor(final boolean newObj, final Object self, final Object arrBuf, final int offset) {
if (!(arrBuf instanceof NativeArrayBuffer)) {
throw typeError("not.an.arraybuffer.in.dataview");
}
@@ -175,7 +175,7 @@ public class NativeDataView extends ScriptObject {
* @return newly constructed DataView object
*/
@SpecializedConstructor
- public static Object constructor(final boolean newObj, final Object self, final Object arrBuf, final int offset, final int length) {
+ public static NativeDataView constructor(final boolean newObj, final Object self, final Object arrBuf, final int offset, final int length) {
if (!(arrBuf instanceof NativeArrayBuffer)) {
throw typeError("not.an.arraybuffer.in.dataview");
}
diff --git a/src/jdk/nashorn/internal/objects/NativeDate.java b/src/jdk/nashorn/internal/objects/NativeDate.java
index 34e27f17..b3661df7 100644
--- a/src/jdk/nashorn/internal/objects/NativeDate.java
+++ b/src/jdk/nashorn/internal/objects/NativeDate.java
@@ -226,7 +226,7 @@ public final class NativeDate extends ScriptObject {
* @return Date interpreted from the string, or NaN for illegal values
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object parse(final Object self, final Object string) {
+ public static double parse(final Object self, final Object string) {
return parseDateString(JSType.toString(string));
}
@@ -238,7 +238,7 @@ public final class NativeDate extends ScriptObject {
* @return a time clip according to the ECMA specification
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 7, where = Where.CONSTRUCTOR)
- public static Object UTC(final Object self, final Object... args) {
+ public static double UTC(final Object self, final Object... args) {
final NativeDate nd = new NativeDate(0);
final double[] d = convertCtorArgs(args);
final double time = d == null ? Double.NaN : timeClip(makeDate(d));
@@ -253,8 +253,8 @@ public final class NativeDate extends ScriptObject {
* @return a Date that points to the current moment in time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object now(final Object self) {
- return (double)System.currentTimeMillis();
+ public static long now(final Object self) {
+ return System.currentTimeMillis();
}
/**
@@ -264,7 +264,7 @@ public final class NativeDate extends ScriptObject {
* @return string value that represents the Date in the current time zone
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self) {
+ public static String toString(final Object self) {
return toStringImpl(self, FORMAT_DATE_TIME);
}
@@ -275,7 +275,7 @@ public final class NativeDate extends ScriptObject {
* @return string value with the "date" part of the Date in the current time zone
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toDateString(final Object self) {
+ public static String toDateString(final Object self) {
return toStringImpl(self, FORMAT_DATE);
}
@@ -286,7 +286,7 @@ public final class NativeDate extends ScriptObject {
* @return string value with "time" part of Date in the current time zone
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toTimeString(final Object self) {
+ public static String toTimeString(final Object self) {
return toStringImpl(self, FORMAT_TIME);
}
@@ -297,7 +297,7 @@ public final class NativeDate extends ScriptObject {
* @return string value that represents the Data in the current time zone and locale
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleString(final Object self) {
+ public static String toLocaleString(final Object self) {
return toStringImpl(self, FORMAT_LOCAL_DATE_TIME);
}
@@ -308,7 +308,7 @@ public final class NativeDate extends ScriptObject {
* @return string value with the "date" part of the Date in the current time zone and locale
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleDateString(final Object self) {
+ public static String toLocaleDateString(final Object self) {
return toStringImpl(self, FORMAT_LOCAL_DATE);
}
@@ -319,7 +319,7 @@ public final class NativeDate extends ScriptObject {
* @return string value with the "time" part of Date in the current time zone and locale
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleTimeString(final Object self) {
+ public static String toLocaleTimeString(final Object self) {
return toStringImpl(self, FORMAT_LOCAL_TIME);
}
@@ -330,7 +330,7 @@ public final class NativeDate extends ScriptObject {
* @return valueOf - a number which is this time value
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object valueOf(final Object self) {
+ public static double valueOf(final Object self) {
final NativeDate nd = getNativeDate(self);
return (nd != null) ? nd.getTime() : Double.NaN;
}
@@ -342,7 +342,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getTime(final Object self) {
+ public static double getTime(final Object self) {
final NativeDate nd = getNativeDate(self);
return (nd != null) ? nd.getTime() : Double.NaN;
}
@@ -365,7 +365,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC full year
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCFullYear(final Object self) {
+ public static double getUTCFullYear(final Object self) {
return getUTCField(self, YEAR);
}
@@ -376,7 +376,7 @@ public final class NativeDate extends ScriptObject {
* @return year
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getYear(final Object self) {
+ public static double getYear(final Object self) {
final NativeDate nd = getNativeDate(self);
return (nd != null && nd.isValidDate()) ? (yearFromTime(nd.getLocalTime()) - 1900) : Double.NaN;
}
@@ -388,7 +388,7 @@ public final class NativeDate extends ScriptObject {
* @return month
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getMonth(final Object self) {
+ public static double getMonth(final Object self) {
return getField(self, MONTH);
}
@@ -399,7 +399,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC month
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCMonth(final Object self) {
+ public static double getUTCMonth(final Object self) {
return getUTCField(self, MONTH);
}
@@ -410,7 +410,7 @@ public final class NativeDate extends ScriptObject {
* @return date
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getDate(final Object self) {
+ public static double getDate(final Object self) {
return getField(self, DAY);
}
@@ -421,7 +421,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC Date
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCDate(final Object self) {
+ public static double getUTCDate(final Object self) {
return getUTCField(self, DAY);
}
@@ -432,7 +432,7 @@ public final class NativeDate extends ScriptObject {
* @return day
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getDay(final Object self) {
+ public static double getDay(final Object self) {
final NativeDate nd = getNativeDate(self);
return (nd != null && nd.isValidDate()) ? weekDay(nd.getLocalTime()) : Double.NaN;
}
@@ -444,7 +444,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC day
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCDay(final Object self) {
+ public static double getUTCDay(final Object self) {
final NativeDate nd = getNativeDate(self);
return (nd != null && nd.isValidDate()) ? weekDay(nd.getTime()) : Double.NaN;
}
@@ -456,7 +456,7 @@ public final class NativeDate extends ScriptObject {
* @return hours
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getHours(final Object self) {
+ public static double getHours(final Object self) {
return getField(self, HOUR);
}
@@ -467,7 +467,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC hours
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCHours(final Object self) {
+ public static double getUTCHours(final Object self) {
return getUTCField(self, HOUR);
}
@@ -478,7 +478,7 @@ public final class NativeDate extends ScriptObject {
* @return minutes
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getMinutes(final Object self) {
+ public static double getMinutes(final Object self) {
return getField(self, MINUTE);
}
@@ -489,7 +489,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC minutes
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCMinutes(final Object self) {
+ public static double getUTCMinutes(final Object self) {
return getUTCField(self, MINUTE);
}
@@ -500,7 +500,7 @@ public final class NativeDate extends ScriptObject {
* @return seconds
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getSeconds(final Object self) {
+ public static double getSeconds(final Object self) {
return getField(self, SECOND);
}
@@ -511,7 +511,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC seconds
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCSeconds(final Object self) {
+ public static double getUTCSeconds(final Object self) {
return getUTCField(self, SECOND);
}
@@ -522,7 +522,7 @@ public final class NativeDate extends ScriptObject {
* @return milliseconds
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getMilliseconds(final Object self) {
+ public static double getMilliseconds(final Object self) {
return getField(self, MILLISECOND);
}
@@ -533,7 +533,7 @@ public final class NativeDate extends ScriptObject {
* @return UTC milliseconds
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getUTCMilliseconds(final Object self) {
+ public static double getUTCMilliseconds(final Object self) {
return getUTCField(self, MILLISECOND);
}
@@ -544,7 +544,7 @@ public final class NativeDate extends ScriptObject {
* @return time zone offset or NaN if N/A
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object getTimezoneOffset(final Object self) {
+ public static double getTimezoneOffset(final Object self) {
final NativeDate nd = getNativeDate(self);
if (nd != null && nd.isValidDate()) {
final long msec = (long) nd.getTime();
@@ -561,7 +561,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object setTime(final Object self, final Object time) {
+ public static double setTime(final Object self, final Object time) {
final NativeDate nd = getNativeDate(self);
final double num = timeClip(JSType.toNumber(time));
nd.setTime(num);
@@ -576,7 +576,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object setMilliseconds(final Object self, final Object... args) {
+ public static double setMilliseconds(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, MILLISECOND, args, true);
return nd.getTime();
@@ -590,7 +590,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object setUTCMilliseconds(final Object self, final Object... args) {
+ public static double setUTCMilliseconds(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, MILLISECOND, args, false);
return nd.getTime();
@@ -604,7 +604,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
- public static Object setSeconds(final Object self, final Object... args) {
+ public static double setSeconds(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, SECOND, args, true);
return nd.getTime();
@@ -618,7 +618,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
- public static Object setUTCSeconds(final Object self, final Object... args) {
+ public static double setUTCSeconds(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, SECOND, args, false);
return nd.getTime();
@@ -632,7 +632,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 3)
- public static Object setMinutes(final Object self, final Object... args) {
+ public static double setMinutes(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, MINUTE, args, true);
return nd.getTime();
@@ -646,7 +646,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 3)
- public static Object setUTCMinutes(final Object self, final Object... args) {
+ public static double setUTCMinutes(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, MINUTE, args, false);
return nd.getTime();
@@ -660,7 +660,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 4)
- public static Object setHours(final Object self, final Object... args) {
+ public static double setHours(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, HOUR, args, true);
return nd.getTime();
@@ -674,7 +674,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 4)
- public static Object setUTCHours(final Object self, final Object... args) {
+ public static double setUTCHours(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, HOUR, args, false);
return nd.getTime();
@@ -688,7 +688,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object setDate(final Object self, final Object... args) {
+ public static double setDate(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, DAY, args, true);
return nd.getTime();
@@ -702,7 +702,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object setUTCDate(final Object self, final Object... args) {
+ public static double setUTCDate(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, DAY, args, false);
return nd.getTime();
@@ -716,7 +716,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
- public static Object setMonth(final Object self, final Object... args) {
+ public static double setMonth(final Object self, final Object... args) {
final NativeDate nd = getNativeDate(self);
setFields(nd, MONTH, args, true);
return nd.getTime();
@@ -730,7 +730,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
- public static Object setUTCMonth(final Object self, final Object... args) {
+ public static double setUTCMonth(final Object self, final Object... args) {
final NativeDate nd = ensureNativeDate(self);
setFields(nd, MONTH, args, false);
return nd.getTime();
@@ -744,7 +744,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 3)
- public static Object setFullYear(final Object self, final Object... args) {
+ public static double setFullYear(final Object self, final Object... args) {
final NativeDate nd = ensureNativeDate(self);
if (nd.isValidDate()) {
setFields(nd, YEAR, args, true);
@@ -767,7 +767,7 @@ public final class NativeDate extends ScriptObject {
* @return time
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 3)
- public static Object setUTCFullYear(final Object self, final Object... args) {
+ public static double setUTCFullYear(final Object self, final Object... args) {
final NativeDate nd = ensureNativeDate(self);
if (nd.isValidDate()) {
setFields(nd, YEAR, args, false);
@@ -786,7 +786,7 @@ public final class NativeDate extends ScriptObject {
* @return NativeDate
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object setYear(final Object self, final Object year) {
+ public static double setYear(final Object self, final Object year) {
final NativeDate nd = getNativeDate(self);
if (isNaN(nd.getTime())) {
nd.setTime(utc(0, nd.getTimeZone()));
@@ -813,7 +813,7 @@ public final class NativeDate extends ScriptObject {
* @return string representation of date
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toUTCString(final Object self) {
+ public static String toUTCString(final Object self) {
return toGMTStringImpl(self);
}
@@ -826,7 +826,7 @@ public final class NativeDate extends ScriptObject {
* @return string representation of date
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toGMTString(final Object self) {
+ public static String toGMTString(final Object self) {
return toGMTStringImpl(self);
}
@@ -837,7 +837,7 @@ public final class NativeDate extends ScriptObject {
* @return string representation of date
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toISOString(final Object self) {
+ public static String toISOString(final Object self) {
return toISOStringImpl(self);
}
@@ -1282,14 +1282,14 @@ public final class NativeDate extends ScriptObject {
}
}
- private static Object getField(final Object self, final int field) {
+ private static double getField(final Object self, final int field) {
final NativeDate nd = getNativeDate(self);
- return (nd != null && nd.isValidDate()) ? valueFromTime(field, nd.getLocalTime()) : Double.NaN;
+ return (nd != null && nd.isValidDate()) ? (double)valueFromTime(field, nd.getLocalTime()) : Double.NaN;
}
- private static Object getUTCField(final Object self, final int field) {
+ private static double getUTCField(final Object self, final int field) {
final NativeDate nd = getNativeDate(self);
- return (nd != null && nd.isValidDate()) ? valueFromTime(field, nd.getTime()) : Double.NaN;
+ return (nd != null && nd.isValidDate()) ? (double)valueFromTime(field, nd.getTime()) : Double.NaN;
}
private static void setFields(final NativeDate nd, final int fieldId, final Object[] args, final boolean local) {
@@ -1344,5 +1344,4 @@ public final class NativeDate extends ScriptObject {
private TimeZone getTimeZone() {
return timezone;
}
-
}
diff --git a/src/jdk/nashorn/internal/objects/NativeDebug.java b/src/jdk/nashorn/internal/objects/NativeDebug.java
index 59b7b2fe..5d80c37b 100644
--- a/src/jdk/nashorn/internal/objects/NativeDebug.java
+++ b/src/jdk/nashorn/internal/objects/NativeDebug.java
@@ -116,7 +116,7 @@ public final class NativeDebug extends ScriptObject {
* @return true if reference identity
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object identical(final Object self, final Object obj1, final Object obj2) {
+ public static boolean identical(final Object self, final Object obj1, final Object obj2) {
return obj1 == obj2;
}
@@ -144,7 +144,7 @@ public final class NativeDebug extends ScriptObject {
* @return return {@link Object#equals(Object)} for objects.
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object equals(final Object self, final Object obj1, final Object obj2) {
+ public static boolean equals(final Object self, final Object obj1, final Object obj2) {
return Objects.equals(obj1, obj2);
}
@@ -156,7 +156,7 @@ public final class NativeDebug extends ScriptObject {
* @return Java string representation of {@code obj}
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object toJavaString(final Object self, final Object obj) {
+ public static String toJavaString(final Object self, final Object obj) {
return Objects.toString(obj);
}
@@ -168,7 +168,7 @@ public final class NativeDebug extends ScriptObject {
* @return string representation
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object toIdentString(final Object self, final Object obj) {
+ public static String toIdentString(final Object self, final Object obj) {
if (obj == null) {
return "null";
}
@@ -185,7 +185,7 @@ public final class NativeDebug extends ScriptObject {
* @return listener count
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object getListenerCount(final Object self, final Object obj) {
+ public static int getListenerCount(final Object self, final Object obj) {
return (obj instanceof ScriptObject) ? PropertyListeners.getListenerCount((ScriptObject) obj) : 0;
}
diff --git a/src/jdk/nashorn/internal/objects/NativeError.java b/src/jdk/nashorn/internal/objects/NativeError.java
index 3dea2728..1b6b8094 100644
--- a/src/jdk/nashorn/internal/objects/NativeError.java
+++ b/src/jdk/nashorn/internal/objects/NativeError.java
@@ -126,7 +126,7 @@ public final class NativeError extends ScriptObject {
* @return NativeError instance
*/
@Constructor
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeError(msg);
}
diff --git a/src/jdk/nashorn/internal/objects/NativeEvalError.java b/src/jdk/nashorn/internal/objects/NativeEvalError.java
index 2b343ede..586c7cff 100644
--- a/src/jdk/nashorn/internal/objects/NativeEvalError.java
+++ b/src/jdk/nashorn/internal/objects/NativeEvalError.java
@@ -98,7 +98,7 @@ public final class NativeEvalError extends ScriptObject {
* @return new EvalError
*/
@Constructor(name = "EvalError")
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeEvalError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeEvalError(msg);
}
}
diff --git a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java
index b96c81c9..a9dfb7a4 100644
--- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java
@@ -136,8 +136,8 @@ public final class NativeFloat32Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeFloat32Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeFloat32Array)constructorImpl(args, FACTORY);
}
NativeFloat32Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -192,8 +192,8 @@ public final class NativeFloat32Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeFloat32Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeFloat32Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java
index af9251f4..61b58807 100644
--- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java
@@ -146,8 +146,8 @@ public final class NativeFloat64Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeFloat64Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeFloat64Array)constructorImpl(args, FACTORY);
}
NativeFloat64Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -202,8 +202,8 @@ public final class NativeFloat64Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeFloat64Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeFloat64Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeFunction.java b/src/jdk/nashorn/internal/objects/NativeFunction.java
index d092cfb6..3d45cc1f 100644
--- a/src/jdk/nashorn/internal/objects/NativeFunction.java
+++ b/src/jdk/nashorn/internal/objects/NativeFunction.java
@@ -71,7 +71,7 @@ public final class NativeFunction {
* @return string representation of Function
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self) {
+ public static String toString(final Object self) {
if (!(self instanceof ScriptFunction)) {
throw typeError("not.a.function", ScriptRuntime.safeToString(self));
}
@@ -174,7 +174,7 @@ public final class NativeFunction {
* @return function with bound arguments
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object bind(final Object self, final Object... args) {
+ public static ScriptFunction bind(final Object self, final Object... args) {
if (!(self instanceof ScriptFunction)) {
throw typeError("not.a.function", ScriptRuntime.safeToString(self));
}
@@ -199,7 +199,7 @@ public final class NativeFunction {
* @return source for function
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toSource(final Object self) {
+ public static String toSource(final Object self) {
if (!(self instanceof ScriptFunction)) {
throw typeError("not.a.function", ScriptRuntime.safeToString(self));
}
@@ -217,7 +217,7 @@ public final class NativeFunction {
* @return new NativeFunction
*/
@Constructor(arity = 1)
- public static Object function(final boolean newObj, final Object self, final Object... args) {
+ public static ScriptFunction function(final boolean newObj, final Object self, final Object... args) {
final StringBuilder sb = new StringBuilder();
sb.append("(function (");
@@ -253,7 +253,7 @@ public final class NativeFunction {
final Global global = Global.instance();
- return Global.directEval(global, sb.toString(), global, "<function>", global.isStrictContext());
+ return (ScriptFunction)Global.directEval(global, sb.toString(), global, "<function>", global.isStrictContext());
}
private static void checkFunctionParameters(final String params) {
diff --git a/src/jdk/nashorn/internal/objects/NativeInt16Array.java b/src/jdk/nashorn/internal/objects/NativeInt16Array.java
index e24691af..f6aa2054 100644
--- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java
@@ -100,8 +100,8 @@ public final class NativeInt16Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeInt16Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeInt16Array)constructorImpl(args, FACTORY);
}
NativeInt16Array(final NativeArrayBuffer buffer, final int byteOffset, final int byteLength) {
@@ -151,8 +151,8 @@ public final class NativeInt16Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeInt16Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeInt16Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeInt32Array.java b/src/jdk/nashorn/internal/objects/NativeInt32Array.java
index b25f8495..643bd816 100644
--- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java
@@ -103,8 +103,8 @@ public final class NativeInt32Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeInt32Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeInt32Array)constructorImpl(args, FACTORY);
}
NativeInt32Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -154,8 +154,8 @@ public final class NativeInt32Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeInt32Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeInt32Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeInt8Array.java b/src/jdk/nashorn/internal/objects/NativeInt8Array.java
index e5069107..5822c6d5 100644
--- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java
@@ -93,8 +93,8 @@ public final class NativeInt8Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeInt8Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeInt8Array)constructorImpl(args, FACTORY);
}
NativeInt8Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -144,8 +144,8 @@ public final class NativeInt8Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeInt8Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeInt8Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
index b71b4276..84036a32 100644
--- a/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
+++ b/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
@@ -536,7 +536,7 @@ public final class NativeJSAdapter extends ScriptObject {
* @return new NativeJSAdapter
*/
@Constructor
- public static Object construct(final boolean isNew, final Object self, final Object... args) {
+ public static NativeJSAdapter construct(final boolean isNew, final Object self, final Object... args) {
Object proto = UNDEFINED;
Object overrides = UNDEFINED;
Object adaptee;
diff --git a/src/jdk/nashorn/internal/objects/NativeJava.java b/src/jdk/nashorn/internal/objects/NativeJava.java
index b863e24f..7879bab4 100644
--- a/src/jdk/nashorn/internal/objects/NativeJava.java
+++ b/src/jdk/nashorn/internal/objects/NativeJava.java
@@ -75,7 +75,7 @@ public final class NativeJava {
* @see #type(Object, Object)
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object isType(final Object self, final Object type) {
+ public static boolean isType(final Object self, final Object type) {
return type instanceof StaticClass;
}
@@ -338,7 +338,7 @@ public final class NativeJava {
* null.
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object from(final Object self, final Object objArray) {
+ public static NativeArray from(final Object self, final Object objArray) {
if (objArray == null) {
return null;
} else if (objArray instanceof Collection) {
diff --git a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java
index 49be8a7c..40ecbffc 100644
--- a/src/jdk/nashorn/internal/objects/NativeJavaImporter.java
+++ b/src/jdk/nashorn/internal/objects/NativeJavaImporter.java
@@ -86,7 +86,7 @@ public final class NativeJavaImporter extends ScriptObject {
* @return NativeJavaImporter instance
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean isNew, final Object self, final Object... args) {
+ public static NativeJavaImporter constructor(final boolean isNew, final Object self, final Object... args) {
return new NativeJavaImporter(args);
}
diff --git a/src/jdk/nashorn/internal/objects/NativeNumber.java b/src/jdk/nashorn/internal/objects/NativeNumber.java
index 4181d205..a95587ef 100644
--- a/src/jdk/nashorn/internal/objects/NativeNumber.java
+++ b/src/jdk/nashorn/internal/objects/NativeNumber.java
@@ -185,7 +185,7 @@ public final class NativeNumber extends ScriptObject {
* @return number in decimal fixed point notation
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toFixed(final Object self, final Object fractionDigits) {
+ public static String toFixed(final Object self, final Object fractionDigits) {
final int f = JSType.toInteger(fractionDigits);
if (f < 0 || f > 20) {
throw rangeError("invalid.fraction.digits", "toFixed");
@@ -217,7 +217,7 @@ public final class NativeNumber extends ScriptObject {
* @return number in decimal exponential notation
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toExponential(final Object self, final Object fractionDigits) {
+ public static String toExponential(final Object self, final Object fractionDigits) {
final double x = getNumberValue(self);
final boolean trimZeros = fractionDigits == UNDEFINED;
final int f = trimZeros ? 16 : JSType.toInteger(fractionDigits);
@@ -245,7 +245,7 @@ public final class NativeNumber extends ScriptObject {
* @return number in decimal exponentiation notation or decimal fixed notation depending on {@code precision}
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toPrecision(final Object self, final Object precision) {
+ public static String toPrecision(final Object self, final Object precision) {
final double x = getNumberValue(self);
if (precision == UNDEFINED) {
return JSType.toString(x);
@@ -278,7 +278,7 @@ public final class NativeNumber extends ScriptObject {
* @return string representation of this Number in the given radix
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self, final Object radix) {
+ public static String toString(final Object self, final Object radix) {
if (radix != UNDEFINED) {
final int intRadix = JSType.toInteger(radix);
if (intRadix != 10) {
@@ -299,7 +299,7 @@ public final class NativeNumber extends ScriptObject {
* @return localized string for this Number
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleString(final Object self) {
+ public static String toLocaleString(final Object self) {
return JSType.toString(getNumberValue(self));
}
@@ -308,10 +308,10 @@ public final class NativeNumber extends ScriptObject {
* ECMA 15.7.4.4 Number.prototype.valueOf ( )
*
* @param self self reference
- * @return boxed number value for this Number
+ * @return number value for this Number
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object valueOf(final Object self) {
+ public static double valueOf(final Object self) {
return getNumberValue(self);
}
diff --git a/src/jdk/nashorn/internal/objects/NativeObject.java b/src/jdk/nashorn/internal/objects/NativeObject.java
index 26335f63..9cde4faf 100644
--- a/src/jdk/nashorn/internal/objects/NativeObject.java
+++ b/src/jdk/nashorn/internal/objects/NativeObject.java
@@ -111,7 +111,7 @@ public final class NativeObject {
* @return the 'obj' object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object setIndexedPropertiesToExternalArrayData(final Object self, final Object obj, final Object buf) {
+ public static ScriptObject setIndexedPropertiesToExternalArrayData(final Object self, final Object obj, final Object buf) {
Global.checkObject(obj);
final ScriptObject sobj = (ScriptObject)obj;
if (buf instanceof ByteBuffer) {
@@ -203,7 +203,7 @@ public final class NativeObject {
* @return array of property names
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object getOwnPropertyNames(final Object self, final Object obj) {
+ public static ScriptObject getOwnPropertyNames(final Object self, final Object obj) {
if (obj instanceof ScriptObject) {
return new NativeArray(((ScriptObject)obj).getOwnKeys(true));
} else if (obj instanceof ScriptObjectMirror) {
@@ -222,7 +222,7 @@ public final class NativeObject {
* @return object created
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object create(final Object self, final Object proto, final Object props) {
+ public static ScriptObject create(final Object self, final Object proto, final Object props) {
if (proto != null) {
Global.checkObject(proto);
}
@@ -248,10 +248,11 @@ public final class NativeObject {
* @return object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
+ public static ScriptObject defineProperty(final Object self, final Object obj, final Object prop, final Object attr) {
Global.checkObject(obj);
- ((ScriptObject)obj).defineOwnProperty(JSType.toString(prop), attr, true);
- return obj;
+ final ScriptObject sobj = (ScriptObject)obj;
+ sobj.defineOwnProperty(JSType.toString(prop), attr, true);
+ return sobj;
}
/**
@@ -263,7 +264,7 @@ public final class NativeObject {
* @return object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object defineProperties(final Object self, final Object obj, final Object props) {
+ public static ScriptObject defineProperties(final Object self, final Object obj, final Object props) {
Global.checkObject(obj);
final ScriptObject sobj = (ScriptObject)obj;
@@ -342,7 +343,7 @@ public final class NativeObject {
* @return true if sealed, false otherwise
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object isSealed(final Object self, final Object obj) {
+ public static boolean isSealed(final Object self, final Object obj) {
if (obj instanceof ScriptObject) {
return ((ScriptObject)obj).isSealed();
} else if (obj instanceof ScriptObjectMirror) {
@@ -360,7 +361,7 @@ public final class NativeObject {
* @return true if object is frozen, false otherwise
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object isFrozen(final Object self, final Object obj) {
+ public static boolean isFrozen(final Object self, final Object obj) {
if (obj instanceof ScriptObject) {
return ((ScriptObject)obj).isFrozen();
} else if (obj instanceof ScriptObjectMirror) {
@@ -378,7 +379,7 @@ public final class NativeObject {
* @return true if object is extensible, false otherwise
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object isExtensible(final Object self, final Object obj) {
+ public static boolean isExtensible(final Object self, final Object obj) {
if (obj instanceof ScriptObject) {
return ((ScriptObject)obj).isExtensible();
} else if (obj instanceof ScriptObjectMirror) {
@@ -396,7 +397,7 @@ public final class NativeObject {
* @return array of keys in object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
- public static Object keys(final Object self, final Object obj) {
+ public static ScriptObject keys(final Object self, final Object obj) {
if (obj instanceof ScriptObject) {
final ScriptObject sobj = (ScriptObject)obj;
return new NativeArray(sobj.getOwnKeys(false));
@@ -453,7 +454,7 @@ public final class NativeObject {
* @return ToString of object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self) {
+ public static String toString(final Object self) {
return ScriptRuntime.builtinObjectToString(self);
}
@@ -506,7 +507,7 @@ public final class NativeObject {
* @return true if property exists in object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object hasOwnProperty(final Object self, final Object v) {
+ public static boolean hasOwnProperty(final Object self, final Object v) {
// Convert ScriptObjects to primitive with String.class hint
// but no need to convert other primitives to string.
final Object key = JSType.toPrimitive(v, String.class);
@@ -523,7 +524,7 @@ public final class NativeObject {
* @return true if object is prototype of v
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object isPrototypeOf(final Object self, final Object v) {
+ public static boolean isPrototypeOf(final Object self, final Object v) {
if (!(v instanceof ScriptObject)) {
return false;
}
@@ -549,7 +550,7 @@ public final class NativeObject {
* @return true if property is enumerable
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object propertyIsEnumerable(final Object self, final Object v) {
+ public static boolean propertyIsEnumerable(final Object self, final Object v) {
final String str = JSType.toString(v);
final Object obj = Global.toObject(self);
diff --git a/src/jdk/nashorn/internal/objects/NativeRangeError.java b/src/jdk/nashorn/internal/objects/NativeRangeError.java
index 4b2bebcf..ff3ac7b7 100644
--- a/src/jdk/nashorn/internal/objects/NativeRangeError.java
+++ b/src/jdk/nashorn/internal/objects/NativeRangeError.java
@@ -98,7 +98,7 @@ public final class NativeRangeError extends ScriptObject {
* @return new RangeError
*/
@Constructor(name = "RangeError")
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeRangeError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeRangeError(msg);
}
}
diff --git a/src/jdk/nashorn/internal/objects/NativeReferenceError.java b/src/jdk/nashorn/internal/objects/NativeReferenceError.java
index 504f16ec..74190179 100644
--- a/src/jdk/nashorn/internal/objects/NativeReferenceError.java
+++ b/src/jdk/nashorn/internal/objects/NativeReferenceError.java
@@ -98,7 +98,7 @@ public final class NativeReferenceError extends ScriptObject {
* @return new ReferenceError
*/
@Constructor(name = "ReferenceError")
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeReferenceError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeReferenceError(msg);
}
}
diff --git a/src/jdk/nashorn/internal/objects/NativeRegExp.java b/src/jdk/nashorn/internal/objects/NativeRegExp.java
index 04b828bf..89a9a828 100644
--- a/src/jdk/nashorn/internal/objects/NativeRegExp.java
+++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java
@@ -122,7 +122,7 @@ public final class NativeRegExp extends ScriptObject {
* @return new NativeRegExp
*/
@Constructor(arity = 2)
- public static Object constructor(final boolean isNew, final Object self, final Object... args) {
+ public static NativeRegExp constructor(final boolean isNew, final Object self, final Object... args) {
if (args.length > 1) {
return newRegExp(args[0], args[1]);
} else if (args.length > 0) {
@@ -142,7 +142,7 @@ public final class NativeRegExp extends ScriptObject {
* @return new NativeRegExp
*/
@SpecializedConstructor
- public static Object constructor(final boolean isNew, final Object self) {
+ public static NativeRegExp constructor(final boolean isNew, final Object self) {
return new NativeRegExp("", "");
}
@@ -157,7 +157,7 @@ public final class NativeRegExp extends ScriptObject {
* @return new NativeRegExp
*/
@SpecializedConstructor
- public static Object constructor(final boolean isNew, final Object self, final Object pattern) {
+ public static NativeRegExp constructor(final boolean isNew, final Object self, final Object pattern) {
return newRegExp(pattern, UNDEFINED);
}
@@ -173,7 +173,7 @@ public final class NativeRegExp extends ScriptObject {
* @return new NativeRegExp
*/
@SpecializedConstructor
- public static Object constructor(final boolean isNew, final Object self, final Object pattern, final Object flags) {
+ public static NativeRegExp constructor(final boolean isNew, final Object self, final Object pattern, final Object flags) {
return newRegExp(pattern, flags);
}
@@ -283,7 +283,7 @@ public final class NativeRegExp extends ScriptObject {
* @return new NativeRegExp
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object compile(final Object self, final Object pattern, final Object flags) {
+ public static ScriptObject compile(final Object self, final Object pattern, final Object flags) {
final NativeRegExp regExp = checkRegExp(self);
final NativeRegExp compiled = newRegExp(pattern, flags);
// copy over regexp to 'self'
@@ -302,7 +302,7 @@ public final class NativeRegExp extends ScriptObject {
* @return array containing the matches or {@code null} if no match
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object exec(final Object self, final Object string) {
+ public static ScriptObject exec(final Object self, final Object string) {
return checkRegExp(self).exec(JSType.toString(string));
}
@@ -314,7 +314,7 @@ public final class NativeRegExp extends ScriptObject {
* @return true if matches found, false otherwise
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object test(final Object self, final Object string) {
+ public static boolean test(final Object self, final Object string) {
return checkRegExp(self).test(JSType.toString(string));
}
@@ -325,7 +325,7 @@ public final class NativeRegExp extends ScriptObject {
* @return string version of regexp
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self) {
+ public static String toString(final Object self) {
return checkRegExp(self).toString();
}
@@ -618,7 +618,7 @@ public final class NativeRegExp extends ScriptObject {
* @param string String to match.
* @return NativeArray of matches, string or null.
*/
- public Object exec(final String string) {
+ public NativeRegExpExecResult exec(final String string) {
final RegExpResult match = execInner(string);
if (match == null) {
@@ -635,7 +635,7 @@ public final class NativeRegExp extends ScriptObject {
* @param string String to match.
* @return True if a match is found.
*/
- public Object test(final String string) {
+ public boolean test(final String string) {
return execInner(string) != null;
}
@@ -649,7 +649,7 @@ public final class NativeRegExp extends ScriptObject {
* @param replacement Replacement string.
* @return String with substitutions.
*/
- Object replace(final String string, final String replacement, final ScriptFunction function) {
+ String replace(final String string, final String replacement, final ScriptFunction function) {
final RegExpMatcher matcher = regexp.match(string);
if (matcher == null) {
@@ -804,7 +804,7 @@ public final class NativeRegExp extends ScriptObject {
* @param limit Split limit.
* @return Array of substrings.
*/
- Object split(final String string, final long limit) {
+ NativeArray split(final String string, final long limit) {
if (limit == 0L) {
return new NativeArray();
}
@@ -867,7 +867,7 @@ public final class NativeRegExp extends ScriptObject {
* @param string String to match.
* @return Index of match.
*/
- Object search(final String string) {
+ int search(final String string) {
final RegExpResult match = execInner(string);
if (match == null) {
diff --git a/src/jdk/nashorn/internal/objects/NativeString.java b/src/jdk/nashorn/internal/objects/NativeString.java
index c75b2b00..51edf75a 100644
--- a/src/jdk/nashorn/internal/objects/NativeString.java
+++ b/src/jdk/nashorn/internal/objects/NativeString.java
@@ -425,7 +425,7 @@ public final class NativeString extends ScriptObject {
* @return string with arguments translated to charcodes
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1, where = Where.CONSTRUCTOR)
- public static Object fromCharCode(final Object self, final Object... args) {
+ public static String fromCharCode(final Object self, final Object... args) {
final char[] buf = new char[args.length];
int index = 0;
for (final Object arg : args) {
@@ -441,7 +441,7 @@ public final class NativeString extends ScriptObject {
* @return string with one charcode
*/
@SpecializedFunction
- public static Object fromCharCode(final Object self, final Object value) {
+ public static String fromCharCode(final Object self, final Object value) {
try {
return "" + (char)JSType.toUint16(((Number)value).doubleValue());
} catch (final ClassCastException e) {
@@ -456,7 +456,7 @@ public final class NativeString extends ScriptObject {
* @return string with one charcode
*/
@SpecializedFunction
- public static Object fromCharCode(final Object self, final int value) {
+ public static String fromCharCode(final Object self, final int value) {
return "" + (char)(value & 0xffff);
}
@@ -467,7 +467,7 @@ public final class NativeString extends ScriptObject {
* @return string with one charcode
*/
@SpecializedFunction
- public static Object fromCharCode(final Object self, final long value) {
+ public static String fromCharCode(final Object self, final long value) {
return "" + (char)((int)value & 0xffff);
}
@@ -478,7 +478,7 @@ public final class NativeString extends ScriptObject {
* @return string with one charcode
*/
@SpecializedFunction
- public static Object fromCharCode(final Object self, final double value) {
+ public static String fromCharCode(final Object self, final double value) {
return "" + (char)JSType.toUint16(value);
}
@@ -488,7 +488,7 @@ public final class NativeString extends ScriptObject {
* @return self as string
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toString(final Object self) {
+ public static String toString(final Object self) {
return getString(self);
}
@@ -498,7 +498,7 @@ public final class NativeString extends ScriptObject {
* @return self as string
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object valueOf(final Object self) {
+ public static String valueOf(final Object self) {
return getString(self);
}
@@ -509,7 +509,7 @@ public final class NativeString extends ScriptObject {
* @return string representing the char at the given position
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object charAt(final Object self, final Object pos) {
+ public static String charAt(final Object self, final Object pos) {
return charAtImpl(checkObjectToString(self), JSType.toInteger(pos));
}
@@ -546,7 +546,7 @@ public final class NativeString extends ScriptObject {
* @return number representing charcode at position
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object charCodeAt(final Object self, final Object pos) {
+ public static double charCodeAt(final Object self, final Object pos) {
return charCodeAtImpl(checkObjectToString(self), JSType.toInteger(pos));
}
@@ -601,7 +601,7 @@ public final class NativeString extends ScriptObject {
* @return position of first match or -1
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object indexOf(final Object self, final Object search, final Object pos) {
+ public static int indexOf(final Object self, final Object search, final Object pos) {
final String str = checkObjectToString(self);
return str.indexOf(JSType.toString(search), JSType.toInteger(pos));
}
@@ -649,7 +649,7 @@ public final class NativeString extends ScriptObject {
* @return last position of match or -1
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
- public static Object lastIndexOf(final Object self, final Object search, final Object pos) {
+ public static int lastIndexOf(final Object self, final Object search, final Object pos) {
final String str = checkObjectToString(self);
final String searchStr = JSType.toString(search);
@@ -680,7 +680,7 @@ public final class NativeString extends ScriptObject {
* @return result of locale sensitive comparison operation between {@code self} and {@code that}
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object localeCompare(final Object self, final Object that) {
+ public static double localeCompare(final Object self, final Object that) {
final String str = checkObjectToString(self);
final Collator collator = Collator.getInstance(Global.getEnv()._locale);
@@ -698,7 +698,7 @@ public final class NativeString extends ScriptObject {
* @return array of regexp matches
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object match(final Object self, final Object regexp) {
+ public static ScriptObject match(final Object self, final Object regexp) {
final String str = checkObjectToString(self);
@@ -745,7 +745,7 @@ public final class NativeString extends ScriptObject {
* @return string after replacement
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object replace(final Object self, final Object string, final Object replacement) {
+ public static String replace(final Object self, final Object string, final Object replacement) {
final String str = checkObjectToString(self);
@@ -771,7 +771,7 @@ public final class NativeString extends ScriptObject {
* @return offset where match occurred
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object search(final Object self, final Object string) {
+ public static int search(final Object self, final Object string) {
final String str = checkObjectToString(self);
final NativeRegExp nativeRegExp = Global.toRegExp(string == UNDEFINED ? "" : string);
@@ -788,7 +788,7 @@ public final class NativeString extends ScriptObject {
* @return sliced out substring
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object slice(final Object self, final Object start, final Object end) {
+ public static String slice(final Object self, final Object start, final Object end) {
final String str = checkObjectToString(self);
if (end == UNDEFINED) {
@@ -805,7 +805,7 @@ public final class NativeString extends ScriptObject {
* @return sliced out substring
*/
@SpecializedFunction
- public static Object slice(final Object self, final int start) {
+ public static String slice(final Object self, final int start) {
final String str = checkObjectToString(self);
final int from = (start < 0) ? Math.max(str.length() + start, 0) : Math.min(start, str.length());
@@ -820,7 +820,7 @@ public final class NativeString extends ScriptObject {
* @return sliced out substring
*/
@SpecializedFunction
- public static Object slice(final Object self, final double start) {
+ public static String slice(final Object self, final double start) {
return slice(self, (int)start);
}
@@ -833,7 +833,7 @@ public final class NativeString extends ScriptObject {
* @return sliced out substring
*/
@SpecializedFunction
- public static Object slice(final Object self, final int start, final int end) {
+ public static String slice(final Object self, final int start, final int end) {
final String str = checkObjectToString(self);
final int len = str.length();
@@ -853,7 +853,7 @@ public final class NativeString extends ScriptObject {
* @return sliced out substring
*/
@SpecializedFunction
- public static Object slice(final Object self, final double start, final double end) {
+ public static String slice(final Object self, final double start, final double end) {
return slice(self, (int)start, (int)end);
}
@@ -866,7 +866,7 @@ public final class NativeString extends ScriptObject {
* @return array object in which splits have been placed
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object split(final Object self, final Object separator, final Object limit) {
+ public static ScriptObject split(final Object self, final Object separator, final Object limit) {
final String str = checkObjectToString(self);
final long lim = (limit == UNDEFINED) ? JSType.MAX_UINT : JSType.toUint32(limit);
@@ -882,7 +882,7 @@ public final class NativeString extends ScriptObject {
return splitString(str, JSType.toString(separator), lim);
}
- private static Object splitString(String str, String separator, long limit) {
+ private static ScriptObject splitString(String str, String separator, long limit) {
if (separator.isEmpty()) {
final int length = (int) Math.min(str.length(), limit);
final Object[] array = new Object[length];
@@ -923,7 +923,7 @@ public final class NativeString extends ScriptObject {
* @return substring given start and length of section
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object substr(final Object self, final Object start, final Object length) {
+ public static String substr(final Object self, final Object start, final Object length) {
final String str = JSType.toString(self);
final int strLength = str.length();
@@ -946,7 +946,7 @@ public final class NativeString extends ScriptObject {
* @return substring given start and end indexes
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object substring(final Object self, final Object start, final Object end) {
+ public static String substring(final Object self, final Object start, final Object end) {
final String str = checkObjectToString(self);
if (end == UNDEFINED) {
@@ -1026,7 +1026,7 @@ public final class NativeString extends ScriptObject {
* @return string to lower case
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLowerCase(final Object self) {
+ public static String toLowerCase(final Object self) {
return checkObjectToString(self).toLowerCase(Locale.ROOT);
}
@@ -1036,7 +1036,7 @@ public final class NativeString extends ScriptObject {
* @return string to locale sensitive lower case
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleLowerCase(final Object self) {
+ public static String toLocaleLowerCase(final Object self) {
return checkObjectToString(self).toLowerCase(Global.getEnv()._locale);
}
@@ -1046,7 +1046,7 @@ public final class NativeString extends ScriptObject {
* @return string to upper case
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toUpperCase(final Object self) {
+ public static String toUpperCase(final Object self) {
return checkObjectToString(self).toUpperCase(Locale.ROOT);
}
@@ -1056,7 +1056,7 @@ public final class NativeString extends ScriptObject {
* @return string to locale sensitive upper case
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object toLocaleUpperCase(final Object self) {
+ public static String toLocaleUpperCase(final Object self) {
return checkObjectToString(self).toUpperCase(Global.getEnv()._locale);
}
@@ -1066,7 +1066,7 @@ public final class NativeString extends ScriptObject {
* @return string trimmed from whitespace
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object trim(final Object self) {
+ public static String trim(final Object self) {
final String str = checkObjectToString(self);
int start = 0;
@@ -1088,7 +1088,7 @@ public final class NativeString extends ScriptObject {
* @return string trimmed left from whitespace
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object trimLeft(final Object self) {
+ public static String trimLeft(final Object self) {
final String str = checkObjectToString(self);
int start = 0;
@@ -1107,7 +1107,7 @@ public final class NativeString extends ScriptObject {
* @return string trimmed right from whitespace
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- public static Object trimRight(final Object self) {
+ public static String trimRight(final Object self) {
final String str = checkObjectToString(self);
int start = 0;
@@ -1120,7 +1120,7 @@ public final class NativeString extends ScriptObject {
return str.substring(start, end + 1);
}
- private static Object newObj(final Object self, final CharSequence str) {
+ private static ScriptObject newObj(final Object self, final CharSequence str) {
return new NativeString(str);
}
diff --git a/src/jdk/nashorn/internal/objects/NativeSyntaxError.java b/src/jdk/nashorn/internal/objects/NativeSyntaxError.java
index 6515f3cc..db7debb0 100644
--- a/src/jdk/nashorn/internal/objects/NativeSyntaxError.java
+++ b/src/jdk/nashorn/internal/objects/NativeSyntaxError.java
@@ -94,7 +94,7 @@ public final class NativeSyntaxError extends ScriptObject {
* @return new SyntaxError
*/
@Constructor(name = "SyntaxError")
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeSyntaxError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeSyntaxError(msg);
}
}
diff --git a/src/jdk/nashorn/internal/objects/NativeTypeError.java b/src/jdk/nashorn/internal/objects/NativeTypeError.java
index f799b176..6e5a4934 100644
--- a/src/jdk/nashorn/internal/objects/NativeTypeError.java
+++ b/src/jdk/nashorn/internal/objects/NativeTypeError.java
@@ -94,7 +94,7 @@ public final class NativeTypeError extends ScriptObject {
* @return new TypeError
*/
@Constructor(name = "TypeError")
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeTypeError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeTypeError(msg);
}
}
diff --git a/src/jdk/nashorn/internal/objects/NativeURIError.java b/src/jdk/nashorn/internal/objects/NativeURIError.java
index fd59bc8a..cf5fdaa0 100644
--- a/src/jdk/nashorn/internal/objects/NativeURIError.java
+++ b/src/jdk/nashorn/internal/objects/NativeURIError.java
@@ -93,7 +93,7 @@ public final class NativeURIError extends ScriptObject {
* @return new URIError
*/
@Constructor(name = "URIError")
- public static Object constructor(final boolean newObj, final Object self, final Object msg) {
+ public static NativeURIError constructor(final boolean newObj, final Object self, final Object msg) {
return new NativeURIError(msg);
}
}
diff --git a/src/jdk/nashorn/internal/objects/NativeUint16Array.java b/src/jdk/nashorn/internal/objects/NativeUint16Array.java
index ee91aef3..8aa3d628 100644
--- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java
@@ -99,8 +99,8 @@ public final class NativeUint16Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeUint16Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeUint16Array)constructorImpl(args, FACTORY);
}
NativeUint16Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -150,8 +150,8 @@ public final class NativeUint16Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeUint16Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeUint16Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeUint32Array.java b/src/jdk/nashorn/internal/objects/NativeUint32Array.java
index 58909dba..73812246 100644
--- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java
@@ -118,8 +118,8 @@ public final class NativeUint32Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeUint32Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeUint32Array)constructorImpl(args, FACTORY);
}
NativeUint32Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -169,8 +169,8 @@ public final class NativeUint32Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeUint32Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeUint32Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeUint8Array.java b/src/jdk/nashorn/internal/objects/NativeUint8Array.java
index 0db1bee6..1f304563 100644
--- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java
+++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java
@@ -92,8 +92,8 @@ public final class NativeUint8Array extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeUint8Array constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeUint8Array)constructorImpl(args, FACTORY);
}
NativeUint8Array(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -143,8 +143,8 @@ public final class NativeUint8Array extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeUint8Array subarray(final Object self, final Object begin, final Object end) {
+ return (NativeUint8Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override
diff --git a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
index f0db743c..d757ee3a 100644
--- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
+++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
@@ -109,8 +109,8 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
* @return new typed array
*/
@Constructor(arity = 1)
- public static Object constructor(final boolean newObj, final Object self, final Object... args) {
- return constructorImpl(args, FACTORY);
+ public static NativeUint8ClampedArray constructor(final boolean newObj, final Object self, final Object... args) {
+ return (NativeUint8ClampedArray)constructorImpl(args, FACTORY);
}
NativeUint8ClampedArray(final NativeArrayBuffer buffer, final int byteOffset, final int length) {
@@ -160,8 +160,8 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
* @return sub array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
- protected static Object subarray(final Object self, final Object begin, final Object end) {
- return ArrayBufferView.subarrayImpl(self, begin, end);
+ protected static NativeUint8ClampedArray subarray(final Object self, final Object begin, final Object end) {
+ return (NativeUint8ClampedArray)ArrayBufferView.subarrayImpl(self, begin, end);
}
@Override