Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
874a8be8
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
874a8be8
编写于
7月 05, 2013
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8019947: inherited property invalidation does not work with two globals in same context
Reviewed-by: jlaskey, lagergren, hannesw, attila
上级
b6f91230
变更
55
隐藏空白更改
内联
并排
Showing
55 changed file
with
668 addition
and
324 deletion
+668
-324
nashorn/make/build-nasgen.xml
nashorn/make/build-nasgen.xml
+0
-7
nashorn/make/build.xml
nashorn/make/build.xml
+2
-1
nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java
...orn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java
+1
-1
nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
+5
-9
nashorn/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java
.../nashorn/internal/objects/AccessorPropertyDescriptor.java
+4
-4
nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java
...orn/src/jdk/nashorn/internal/objects/ArrayBufferView.java
+8
-3
nashorn/src/jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java
...jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java
+1
-1
nashorn/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java
.../jdk/nashorn/internal/objects/DataPropertyDescriptor.java
+4
-5
nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java
...k/nashorn/internal/objects/GenericPropertyDescriptor.java
+4
-4
nashorn/src/jdk/nashorn/internal/objects/Global.java
nashorn/src/jdk/nashorn/internal/objects/Global.java
+203
-33
nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java
...orn/src/jdk/nashorn/internal/objects/NativeArguments.java
+14
-10
nashorn/src/jdk/nashorn/internal/objects/NativeArray.java
nashorn/src/jdk/nashorn/internal/objects/NativeArray.java
+9
-1
nashorn/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
...n/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
+10
-2
nashorn/src/jdk/nashorn/internal/objects/NativeBoolean.java
nashorn/src/jdk/nashorn/internal/objects/NativeBoolean.java
+14
-14
nashorn/src/jdk/nashorn/internal/objects/NativeDate.java
nashorn/src/jdk/nashorn/internal/objects/NativeDate.java
+21
-5
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
+3
-2
nashorn/src/jdk/nashorn/internal/objects/NativeError.java
nashorn/src/jdk/nashorn/internal/objects/NativeError.java
+15
-7
nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java
...orn/src/jdk/nashorn/internal/objects/NativeEvalError.java
+14
-3
nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java
.../src/jdk/nashorn/internal/objects/NativeFloat32Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java
.../src/jdk/nashorn/internal/objects/NativeFloat64Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java
nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java
+1
-0
nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java
...rn/src/jdk/nashorn/internal/objects/NativeInt16Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java
...rn/src/jdk/nashorn/internal/objects/NativeInt32Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java
...orn/src/jdk/nashorn/internal/objects/NativeInt8Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
...orn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
+12
-12
nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java
nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java
+3
-2
nashorn/src/jdk/nashorn/internal/objects/NativeJava.java
nashorn/src/jdk/nashorn/internal/objects/NativeJava.java
+2
-0
nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java
.../src/jdk/nashorn/internal/objects/NativeJavaImporter.java
+14
-2
nashorn/src/jdk/nashorn/internal/objects/NativeMath.java
nashorn/src/jdk/nashorn/internal/objects/NativeMath.java
+3
-2
nashorn/src/jdk/nashorn/internal/objects/NativeNumber.java
nashorn/src/jdk/nashorn/internal/objects/NativeNumber.java
+15
-19
nashorn/src/jdk/nashorn/internal/objects/NativeObject.java
nashorn/src/jdk/nashorn/internal/objects/NativeObject.java
+2
-0
nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java
...rn/src/jdk/nashorn/internal/objects/NativeRangeError.java
+14
-2
nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java
...rc/jdk/nashorn/internal/objects/NativeReferenceError.java
+14
-2
nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java
nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java
+22
-11
nashorn/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java
.../jdk/nashorn/internal/objects/NativeRegExpExecResult.java
+6
-2
nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java
...c/jdk/nashorn/internal/objects/NativeStrictArguments.java
+7
-7
nashorn/src/jdk/nashorn/internal/objects/NativeString.java
nashorn/src/jdk/nashorn/internal/objects/NativeString.java
+17
-16
nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java
...n/src/jdk/nashorn/internal/objects/NativeSyntaxError.java
+10
-2
nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java
...orn/src/jdk/nashorn/internal/objects/NativeTypeError.java
+10
-2
nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java
nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java
+10
-2
nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java
...n/src/jdk/nashorn/internal/objects/NativeUint16Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java
...n/src/jdk/nashorn/internal/objects/NativeUint32Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java
...rn/src/jdk/nashorn/internal/objects/NativeUint8Array.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
...jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
+2
-2
nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java
...orn/src/jdk/nashorn/internal/objects/PrototypeObject.java
+13
-9
nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
.../src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
+44
-15
nashorn/src/jdk/nashorn/internal/runtime/Context.java
nashorn/src/jdk/nashorn/internal/runtime/Context.java
+6
-20
nashorn/src/jdk/nashorn/internal/runtime/GlobalFunctions.java
...orn/src/jdk/nashorn/internal/runtime/GlobalFunctions.java
+0
-3
nashorn/src/jdk/nashorn/internal/runtime/GlobalObject.java
nashorn/src/jdk/nashorn/internal/runtime/GlobalObject.java
+1
-8
nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
+9
-0
nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java
...orn/src/jdk/nashorn/internal/runtime/StructureLoader.java
+1
-48
nashorn/src/jdk/nashorn/internal/scripts/JO.java
nashorn/src/jdk/nashorn/internal/scripts/JO.java
+9
-7
nashorn/src/jdk/nashorn/tools/Shell.java
nashorn/src/jdk/nashorn/tools/Shell.java
+2
-1
nashorn/test/script/basic/JDK-8019947.js
nashorn/test/script/basic/JDK-8019947.js
+68
-0
nashorn/test/script/basic/JDK-8019947.js.EXPECTED
nashorn/test/script/basic/JDK-8019947.js.EXPECTED
+3
-0
未找到文件。
nashorn/make/build-nasgen.xml
浏览文件 @
874a8be8
...
...
@@ -42,11 +42,6 @@
<arg
value=
"jdk.nashorn.internal.objects"
/>
<arg
value=
"${basedir}/build/classes"
/>
</java>
<move
todir=
"${basedir}/build/classes/jdk/nashorn/internal/objects"
>
<fileset
dir=
"${basedir}/build/classes/jdk/nashorn/internal/objects"
/>
<mapper
type=
"glob"
from=
"*.class"
to=
"*.clazz"
/>
</move>
</target>
<target
name=
"run-nasgen-eclipse"
>
...
...
@@ -66,7 +61,6 @@
<fileset
dir=
"${basedir}/build/eclipse/.nasgentmp/jdk/nashorn/internal/objects"
>
<include
name=
"*.class"
/>
</fileset>
<mapper
type=
"glob"
from=
"*.class"
to=
"*.clazz"
/>
</move>
<delete
includeemptydirs=
"true"
><fileset
dir=
"${basedir}/build/eclipse/.nasgentmp"
includes=
"**"
/></delete>
...
...
@@ -75,7 +69,6 @@
<fileset
dir=
"${basedir}/build/eclipse/jdk/nashorn/internal/objects"
>
<include
name=
"**/*.class"
/>
</fileset>
<mapper
type=
"glob"
from=
"*.class"
to=
"*.clazz"
/>
</copy>
</target>
...
...
nashorn/make/build.xml
浏览文件 @
874a8be8
...
...
@@ -100,7 +100,8 @@
target=
"${javac.target}"
debug=
"${javac.debug}"
encoding=
"${javac.encoding}"
includeantruntime=
"false"
>
includeantruntime=
"false"
fork=
"true"
>
<compilerarg
value=
"-J-Djava.ext.dirs="
/>
<compilerarg
value=
"-Xlint:unchecked"
/>
<compilerarg
value=
"-Xlint:deprecation"
/>
<compilerarg
value=
"-XDignore.symbol.file"
/>
...
...
nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java
浏览文件 @
874a8be8
...
...
@@ -308,9 +308,9 @@ public final class ScriptObjectMirror extends JSObject implements Bindings {
public
void
putAll
(
final
Map
<?
extends
String
,
?
extends
Object
>
map
)
{
final
ScriptObject
oldGlobal
=
NashornScriptEngine
.
getNashornGlobal
();
final
boolean
globalChanged
=
(
oldGlobal
!=
global
);
final
boolean
strict
=
sobj
.
isStrictContext
();
inGlobal
(
new
Callable
<
Object
>()
{
@Override
public
Object
call
()
{
final
boolean
strict
=
global
.
isStrictContext
();
for
(
final
Map
.
Entry
<?
extends
String
,
?
extends
Object
>
entry
:
map
.
entrySet
())
{
final
Object
value
=
entry
.
getValue
();
final
Object
modValue
=
globalChanged
?
wrap
(
value
,
oldGlobal
)
:
value
;
...
...
nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
浏览文件 @
874a8be8
...
...
@@ -109,6 +109,8 @@ import jdk.nashorn.internal.ir.WithNode;
import
jdk.nashorn.internal.ir.debug.ASTWriter
;
import
jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.objects.Global
;
import
jdk.nashorn.internal.objects.ScriptFunctionImpl
;
import
jdk.nashorn.internal.parser.Lexer.RegexToken
;
import
jdk.nashorn.internal.parser.TokenType
;
import
jdk.nashorn.internal.runtime.Context
;
...
...
@@ -148,11 +150,9 @@ import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
*/
final
class
CodeGenerator
extends
NodeOperatorVisitor
<
CodeGeneratorLexicalContext
>
{
/** Name of the Global object, cannot be referred to as .class, @see CodeGenerator */
private
static
final
String
GLOBAL_OBJECT
=
Compiler
.
OBJECTS_PACKAGE
+
'/'
+
"Global"
;
private
static
final
String
GLOBAL_OBJECT
=
Type
.
getInternalName
(
Global
.
class
);
/** Name of the ScriptFunctionImpl, cannot be referred to as .class @see FunctionObjectCreator */
private
static
final
String
SCRIPTFUNCTION_IMPL_OBJECT
=
Compiler
.
OBJECTS_PACKAGE
+
'/'
+
"ScriptFunctionImpl"
;
private
static
final
String
SCRIPTFUNCTION_IMPL_OBJECT
=
Type
.
getInternalName
(
ScriptFunctionImpl
.
class
);
/** Constant data & installation. The only reason the compiler keeps this is because it is assigned
* by reflection in class installation */
...
...
@@ -3203,11 +3203,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
}.
makeObject
(
method
);
}
/*
* Globals are special. We cannot refer to any Global (or NativeObject) class by .class, as they are different
* for different contexts. As far as I can tell, the only NativeObject that we need to deal with like this
* is from the code pipeline is Global
*/
// calls on Global class.
private
MethodEmitter
globalInstance
()
{
return
method
.
invokestatic
(
GLOBAL_OBJECT
,
"instance"
,
"()L"
+
GLOBAL_OBJECT
+
';'
);
}
...
...
nashorn/src/jdk/nashorn/internal/objects/AccessorPropertyDescriptor.java
浏览文件 @
874a8be8
...
...
@@ -67,12 +67,12 @@ public final class AccessorPropertyDescriptor extends ScriptObject implements Pr
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
AccessorPropertyDescriptor
()
{
this
(
false
,
false
,
UNDEFINED
,
UNDEFINED
)
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
AccessorPropertyDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
,
final
Object
get
,
final
Object
set
)
{
super
(
Global
.
objectPrototype
(),
$nasgenmap
$
);
AccessorPropertyDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
,
final
Object
get
,
final
Object
set
,
final
Global
global
)
{
super
(
global
.
getObjectPrototype
(),
global
.
getAccessorPropertyDescriptorMap
()
);
this
.
configurable
=
configurable
;
this
.
enumerable
=
enumerable
;
this
.
get
=
get
;
...
...
nashorn/src/jdk/nashorn/internal/objects/ArrayBufferView.java
浏览文件 @
874a8be8
...
...
@@ -40,12 +40,17 @@ import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError;
abstract
class
ArrayBufferView
extends
ScriptObject
{
// initialized by nasgen
@SuppressWarnings
(
"unused"
)
private
static
PropertyMap
$nasgenmap
$
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
ArrayBufferView
(
final
NativeArrayBuffer
buffer
,
final
int
byteOffset
,
final
int
elementLength
)
{
checkConstructorArgs
(
buffer
,
byteOffset
,
elementLength
);
this
.
setProto
(
getPrototype
());
final
Global
global
=
Global
.
instance
();
this
.
setMap
(
global
.
getArrayBufferViewMap
());
this
.
setProto
(
getPrototype
(
global
));
this
.
setArray
(
factory
().
createArrayData
(
buffer
,
byteOffset
,
elementLength
));
}
...
...
@@ -283,7 +288,7 @@ abstract class ArrayBufferView extends ScriptObject {
protected
abstract
Factory
factory
();
protected
abstract
ScriptObject
getPrototype
();
protected
abstract
ScriptObject
getPrototype
(
final
Global
global
);
protected
boolean
isFloatArray
()
{
return
false
;
...
...
nashorn/src/jdk/nashorn/internal/objects/BoundScriptFunctionImpl.java
浏览文件 @
874a8be8
...
...
@@ -39,7 +39,7 @@ class BoundScriptFunctionImpl extends ScriptFunctionImpl {
private
final
ScriptFunction
targetFunction
;
BoundScriptFunctionImpl
(
ScriptFunctionData
data
,
ScriptFunction
targetFunction
)
{
super
(
data
);
super
(
data
,
Global
.
instance
()
);
setPrototype
(
ScriptRuntime
.
UNDEFINED
);
this
.
targetFunction
=
targetFunction
;
}
...
...
nashorn/src/jdk/nashorn/internal/objects/DataPropertyDescriptor.java
浏览文件 @
874a8be8
...
...
@@ -25,7 +25,6 @@
package
jdk.nashorn.internal.objects
;
import
static
jdk
.
nashorn
.
internal
.
runtime
.
ScriptRuntime
.
UNDEFINED
;
import
static
jdk
.
nashorn
.
internal
.
runtime
.
ScriptRuntime
.
sameValue
;
import
java.util.Objects
;
...
...
@@ -65,12 +64,12 @@ public final class DataPropertyDescriptor extends ScriptObject implements Proper
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
DataPropertyDescriptor
()
{
this
(
false
,
false
,
false
,
UNDEFINED
)
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
DataPropertyDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
,
final
boolean
writable
,
final
Object
value
)
{
super
(
Global
.
objectPrototype
(),
$nasgenmap
$
);
DataPropertyDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
,
final
boolean
writable
,
final
Object
value
,
final
Global
global
)
{
super
(
global
.
getObjectPrototype
(),
global
.
getDataPropertyDescriptorMap
()
);
this
.
configurable
=
configurable
;
this
.
enumerable
=
enumerable
;
this
.
writable
=
writable
;
...
...
nashorn/src/jdk/nashorn/internal/objects/GenericPropertyDescriptor.java
浏览文件 @
874a8be8
...
...
@@ -55,12 +55,12 @@ public final class GenericPropertyDescriptor extends ScriptObject implements Pro
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
GenericPropertyDescriptor
()
{
this
(
false
,
false
)
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
GenericPropertyDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
)
{
super
(
Global
.
objectPrototype
(),
$nasgenmap
$
);
GenericPropertyDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
,
final
Global
global
)
{
super
(
global
.
getObjectPrototype
(),
global
.
getGenericPropertyDescriptorMap
()
);
this
.
configurable
=
configurable
;
this
.
enumerable
=
enumerable
;
}
...
...
nashorn/src/jdk/nashorn/internal/objects/Global.java
浏览文件 @
874a8be8
...
...
@@ -363,6 +363,35 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private
ScriptObject
builtinFloat32Array
;
private
ScriptObject
builtinFloat64Array
;
private
PropertyMap
accessorPropertyDescriptorMap
;
private
PropertyMap
arrayBufferViewMap
;
private
PropertyMap
dataPropertyDescriptorMap
;
private
PropertyMap
genericPropertyDescriptorMap
;
private
PropertyMap
nativeArgumentsMap
;
private
PropertyMap
nativeArrayMap
;
private
PropertyMap
nativeArrayBufferMap
;
private
PropertyMap
nativeBooleanMap
;
private
PropertyMap
nativeDateMap
;
private
PropertyMap
nativeErrorMap
;
private
PropertyMap
nativeEvalErrorMap
;
private
PropertyMap
nativeJSAdapterMap
;
private
PropertyMap
nativeJavaImporterMap
;
private
PropertyMap
nativeNumberMap
;
private
PropertyMap
nativeRangeErrorMap
;
private
PropertyMap
nativeReferenceErrorMap
;
private
PropertyMap
nativeRegExpMap
;
private
PropertyMap
nativeRegExpExecResultMap
;
private
PropertyMap
nativeStrictArgumentsMap
;
private
PropertyMap
nativeStringMap
;
private
PropertyMap
nativeSyntaxErrorMap
;
private
PropertyMap
nativeTypeErrorMap
;
private
PropertyMap
nativeURIErrorMap
;
private
PropertyMap
prototypeObjectMap
;
private
PropertyMap
objectMap
;
private
PropertyMap
functionMap
;
private
PropertyMap
strictFunctionMap
;
private
PropertyMap
boundFunctionMap
;
// Flag to indicate that a split method issued a return statement
private
int
splitState
=
-
1
;
...
...
@@ -379,8 +408,6 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private
static
final
MethodHandle
LOADWITHNEWGLOBAL
=
findOwnMH
(
"loadWithNewGlobal"
,
Object
.
class
,
Object
.
class
,
Object
[].
class
);
private
static
final
MethodHandle
EXIT
=
findOwnMH
(
"exit"
,
Object
.
class
,
Object
.
class
,
Object
.
class
);
private
final
Context
context
;
// initialized by nasgen
@SuppressWarnings
(
"unused"
)
private
static
PropertyMap
$nasgenmap
$
;
...
...
@@ -391,7 +418,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @param context the context
*/
public
Global
(
final
Context
context
)
{
this
.
context
=
context
;
this
.
setContext
(
context
)
;
this
.
setIsScope
();
/*
* Duplicate global's map and use it. This way the initial Map filled
...
...
@@ -425,7 +452,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return the script environment
*/
static
ScriptEnvironment
getEnv
()
{
return
instance
().
context
.
getEnv
();
return
instance
().
getContext
()
.
getEnv
();
}
/**
...
...
@@ -434,7 +461,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
* @return the context
*/
static
Context
getThisContext
()
{
return
instance
().
context
;
return
instance
().
getContext
()
;
}
// GlobalObject interface implementation
...
...
@@ -457,11 +484,11 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@Override
public
Object
wrapAsObject
(
final
Object
obj
)
{
if
(
obj
instanceof
Boolean
)
{
return
new
NativeBoolean
((
Boolean
)
obj
);
return
new
NativeBoolean
((
Boolean
)
obj
,
this
);
}
else
if
(
obj
instanceof
Number
)
{
return
new
NativeNumber
(((
Number
)
obj
).
doubleValue
());
return
new
NativeNumber
(((
Number
)
obj
).
doubleValue
()
,
this
);
}
else
if
(
obj
instanceof
String
||
obj
instanceof
ConsString
)
{
return
new
NativeString
((
CharSequence
)
obj
);
return
new
NativeString
((
CharSequence
)
obj
,
this
);
}
else
if
(
obj
instanceof
Object
[])
{
// extension
return
new
NativeArray
((
Object
[])
obj
);
}
else
if
(
obj
instanceof
double
[])
{
// extension
...
...
@@ -490,7 +517,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@Override
public
ScriptObject
newObject
()
{
return
new
JO
(
getObjectPrototype
());
return
new
JO
(
getObjectPrototype
()
,
getObjectMap
()
);
}
@Override
...
...
@@ -567,52 +594,52 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@Override
public
ScriptObject
newError
(
final
String
msg
)
{
return
new
NativeError
(
msg
);
return
new
NativeError
(
msg
,
this
);
}
@Override
public
ScriptObject
newEvalError
(
final
String
msg
)
{
return
new
NativeEvalError
(
msg
);
return
new
NativeEvalError
(
msg
,
this
);
}
@Override
public
ScriptObject
newRangeError
(
final
String
msg
)
{
return
new
NativeRangeError
(
msg
);
return
new
NativeRangeError
(
msg
,
this
);
}
@Override
public
ScriptObject
newReferenceError
(
final
String
msg
)
{
return
new
NativeReferenceError
(
msg
);
return
new
NativeReferenceError
(
msg
,
this
);
}
@Override
public
ScriptObject
newSyntaxError
(
final
String
msg
)
{
return
new
NativeSyntaxError
(
msg
);
return
new
NativeSyntaxError
(
msg
,
this
);
}
@Override
public
ScriptObject
newTypeError
(
final
String
msg
)
{
return
new
NativeTypeError
(
msg
);
return
new
NativeTypeError
(
msg
,
this
);
}
@Override
public
ScriptObject
newURIError
(
final
String
msg
)
{
return
new
NativeURIError
(
msg
);
return
new
NativeURIError
(
msg
,
this
);
}
@Override
public
PropertyDescriptor
newGenericDescriptor
(
final
boolean
configurable
,
final
boolean
enumerable
)
{
return
new
GenericPropertyDescriptor
(
configurable
,
enumerable
);
return
new
GenericPropertyDescriptor
(
configurable
,
enumerable
,
this
);
}
@Override
public
PropertyDescriptor
newDataDescriptor
(
final
Object
value
,
final
boolean
configurable
,
final
boolean
enumerable
,
final
boolean
writable
)
{
return
new
DataPropertyDescriptor
(
configurable
,
enumerable
,
writable
,
value
);
return
new
DataPropertyDescriptor
(
configurable
,
enumerable
,
writable
,
value
,
this
);
}
@Override
public
PropertyDescriptor
newAccessorDescriptor
(
final
Object
get
,
final
Object
set
,
final
boolean
configurable
,
final
boolean
enumerable
)
{
final
AccessorPropertyDescriptor
desc
=
new
AccessorPropertyDescriptor
(
configurable
,
enumerable
,
get
==
null
?
UNDEFINED
:
get
,
set
==
null
?
UNDEFINED
:
set
);
final
AccessorPropertyDescriptor
desc
=
new
AccessorPropertyDescriptor
(
configurable
,
enumerable
,
get
==
null
?
UNDEFINED
:
get
,
set
==
null
?
UNDEFINED
:
set
,
this
);
if
(
get
==
null
)
{
desc
.
delete
(
PropertyDescriptor
.
GET
,
false
);
...
...
@@ -701,7 +728,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
final
Global
global
=
Global
.
instance
();
final
ScriptObject
scope
=
(
self
instanceof
ScriptObject
)
?
(
ScriptObject
)
self
:
global
;
return
global
.
context
.
eval
(
scope
,
str
.
toString
(),
callThis
,
location
,
Boolean
.
TRUE
.
equals
(
strict
));
return
global
.
getContext
()
.
eval
(
scope
,
str
.
toString
(),
callThis
,
location
,
Boolean
.
TRUE
.
equals
(
strict
));
}
/**
...
...
@@ -741,7 +768,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
public
static
Object
load
(
final
Object
self
,
final
Object
source
)
throws
IOException
{
final
Global
global
=
Global
.
instance
();
final
ScriptObject
scope
=
(
self
instanceof
ScriptObject
)
?
(
ScriptObject
)
self
:
global
;
return
global
.
context
.
load
(
scope
,
source
);
return
global
.
getContext
()
.
load
(
scope
,
source
);
}
/**
...
...
@@ -761,7 +788,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
final
Object
from
=
hasArgs
?
args
[
0
]
:
UNDEFINED
;
final
Object
[]
arguments
=
hasArgs
?
Arrays
.
copyOfRange
(
args
,
1
,
length
)
:
args
;
return
global
.
context
.
loadWithNewGlobal
(
from
,
arguments
);
return
global
.
getContext
()
.
loadWithNewGlobal
(
from
,
arguments
);
}
/**
...
...
@@ -777,6 +804,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
return
UNDEFINED
;
}
// builtin prototype accessors
ScriptObject
getFunctionPrototype
()
{
return
ScriptFunction
.
getPrototype
(
builtinFunction
);
}
...
...
@@ -885,11 +913,123 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
return
ScriptFunction
.
getPrototype
(
builtinFloat64Array
);
}
// Builtin PropertyMap accessors
PropertyMap
getAccessorPropertyDescriptorMap
()
{
return
accessorPropertyDescriptorMap
;
}
PropertyMap
getArrayBufferViewMap
()
{
return
arrayBufferViewMap
;
}
PropertyMap
getDataPropertyDescriptorMap
()
{
return
dataPropertyDescriptorMap
;
}
PropertyMap
getGenericPropertyDescriptorMap
()
{
return
genericPropertyDescriptorMap
;
}
PropertyMap
getArgumentsMap
()
{
return
nativeArgumentsMap
;
}
PropertyMap
getArrayMap
()
{
return
nativeArrayMap
;
}
PropertyMap
getArrayBufferMap
()
{
return
nativeArrayBufferMap
;
}
PropertyMap
getBooleanMap
()
{
return
nativeBooleanMap
;
}
PropertyMap
getDateMap
()
{
return
nativeDateMap
;
}
PropertyMap
getErrorMap
()
{
return
nativeErrorMap
;
}
PropertyMap
getEvalErrorMap
()
{
return
nativeEvalErrorMap
;
}
PropertyMap
getJSAdapterMap
()
{
return
nativeJSAdapterMap
;
}
PropertyMap
getJavaImporterMap
()
{
return
nativeJavaImporterMap
;
}
PropertyMap
getNumberMap
()
{
return
nativeNumberMap
;
}
PropertyMap
getRangeErrorMap
()
{
return
nativeRangeErrorMap
;
}
PropertyMap
getReferenceErrorMap
()
{
return
nativeReferenceErrorMap
;
}
PropertyMap
getRegExpMap
()
{
return
nativeRegExpMap
;
}
PropertyMap
getRegExpExecResultMap
()
{
return
nativeRegExpExecResultMap
;
}
PropertyMap
getStrictArgumentsMap
()
{
return
nativeStrictArgumentsMap
;
}
PropertyMap
getStringMap
()
{
return
nativeStringMap
;
}
PropertyMap
getSyntaxErrorMap
()
{
return
nativeSyntaxErrorMap
;
}
PropertyMap
getTypeErrorMap
()
{
return
nativeTypeErrorMap
;
}
PropertyMap
getURIErrorMap
()
{
return
nativeURIErrorMap
;
}
PropertyMap
getPrototypeObjectMap
()
{
return
prototypeObjectMap
;
}
PropertyMap
getObjectMap
()
{
return
objectMap
;
}
PropertyMap
getFunctionMap
()
{
return
functionMap
;
}
PropertyMap
getStrictFunctionMap
()
{
return
strictFunctionMap
;
}
PropertyMap
getBoundFunctionMap
()
{
return
boundFunctionMap
;
}
private
ScriptFunction
getBuiltinArray
()
{
return
builtinArray
;
}
/**
* Called from compiled script code to test if builtin has been overridden
*
...
...
@@ -1395,7 +1535,11 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private
void
init
()
{
assert
Context
.
getGlobal
()
==
this
:
"this global is not set as current"
;
final
ScriptEnvironment
env
=
context
.
getEnv
();
final
ScriptEnvironment
env
=
getContext
().
getEnv
();
// duplicate PropertyMaps of Native* classes
copyInitialMaps
();
// initialize Function and Object constructor
initFunctionAndObject
();
...
...
@@ -1441,10 +1585,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
final
ScriptObject
arrayPrototype
=
getArrayPrototype
();
arrayPrototype
.
addOwnProperty
(
"length"
,
Attribute
.
NOT_ENUMERABLE
|
Attribute
.
NOT_CONFIGURABLE
,
0.0
);
this
.
DEFAULT_DATE
=
new
NativeDate
(
Double
.
NaN
);
this
.
DEFAULT_DATE
=
new
NativeDate
(
Double
.
NaN
,
this
);
// initialize default regexp object
this
.
DEFAULT_REGEXP
=
new
NativeRegExp
(
"(?:)"
);
this
.
DEFAULT_REGEXP
=
new
NativeRegExp
(
"(?:)"
,
this
);
// RegExp.prototype should behave like a RegExp object. So copy the
// properties.
...
...
@@ -1560,7 +1704,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
// Nashorn extension: global.$OPTIONS (scripting-mode-only)
final
ScriptObject
options
=
newObject
();
final
ScriptEnvironment
scriptEnv
=
context
.
getEnv
();
final
ScriptEnvironment
scriptEnv
=
getContext
()
.
getEnv
();
copyOptions
(
options
,
scriptEnv
);
addOwnProperty
(
"$OPTIONS"
,
Attribute
.
NOT_ENUMERABLE
,
options
);
...
...
@@ -1713,6 +1857,37 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
}
}
private
void
copyInitialMaps
()
{
this
.
accessorPropertyDescriptorMap
=
AccessorPropertyDescriptor
.
getInitialMap
().
duplicate
();
this
.
arrayBufferViewMap
=
ArrayBufferView
.
getInitialMap
().
duplicate
();
this
.
dataPropertyDescriptorMap
=
DataPropertyDescriptor
.
getInitialMap
().
duplicate
();
this
.
genericPropertyDescriptorMap
=
GenericPropertyDescriptor
.
getInitialMap
().
duplicate
();
this
.
nativeArgumentsMap
=
NativeArguments
.
getInitialMap
().
duplicate
();
this
.
nativeArrayMap
=
NativeArray
.
getInitialMap
().
duplicate
();
this
.
nativeArrayBufferMap
=
NativeArrayBuffer
.
getInitialMap
().
duplicate
();
this
.
nativeBooleanMap
=
NativeBoolean
.
getInitialMap
().
duplicate
();
this
.
nativeDateMap
=
NativeDate
.
getInitialMap
().
duplicate
();
this
.
nativeErrorMap
=
NativeError
.
getInitialMap
().
duplicate
();
this
.
nativeEvalErrorMap
=
NativeEvalError
.
getInitialMap
().
duplicate
();
this
.
nativeJSAdapterMap
=
NativeJSAdapter
.
getInitialMap
().
duplicate
();
this
.
nativeJavaImporterMap
=
NativeJavaImporter
.
getInitialMap
().
duplicate
();
this
.
nativeNumberMap
=
NativeNumber
.
getInitialMap
().
duplicate
();
this
.
nativeRangeErrorMap
=
NativeRangeError
.
getInitialMap
().
duplicate
();
this
.
nativeReferenceErrorMap
=
NativeReferenceError
.
getInitialMap
().
duplicate
();
this
.
nativeRegExpMap
=
NativeRegExp
.
getInitialMap
().
duplicate
();
this
.
nativeRegExpExecResultMap
=
NativeRegExpExecResult
.
getInitialMap
().
duplicate
();
this
.
nativeStrictArgumentsMap
=
NativeStrictArguments
.
getInitialMap
().
duplicate
();
this
.
nativeStringMap
=
NativeString
.
getInitialMap
().
duplicate
();
this
.
nativeSyntaxErrorMap
=
NativeSyntaxError
.
getInitialMap
().
duplicate
();
this
.
nativeTypeErrorMap
=
NativeTypeError
.
getInitialMap
().
duplicate
();
this
.
nativeURIErrorMap
=
NativeURIError
.
getInitialMap
().
duplicate
();
this
.
prototypeObjectMap
=
PrototypeObject
.
getInitialMap
().
duplicate
();
this
.
objectMap
=
JO
.
getInitialMap
().
duplicate
();
this
.
functionMap
=
ScriptFunctionImpl
.
getInitialMap
();
this
.
strictFunctionMap
=
ScriptFunctionImpl
.
getInitialStrictMap
().
duplicate
();
this
.
boundFunctionMap
=
ScriptFunctionImpl
.
getInitialBoundMap
().
duplicate
();
}
// Function and Object constructors are inter-dependent. Also,
// Function.prototype
// functions are not properly initialized. We fix the references here.
...
...
@@ -1793,13 +1968,8 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
}
}
private
static
MethodHandle
findOwnMH
(
final
String
name
,
final
Class
<?>
rtype
,
final
Class
<?>...
types
)
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
Global
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
Global
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
RegExpResult
getLastRegExpResult
()
{
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java
浏览文件 @
874a8be8
...
...
@@ -70,14 +70,18 @@ public final class NativeArguments extends ScriptObject {
map
$
=
map
;
}
static
PropertyMap
getInitialMap
()
{
return
map
$
;
}
private
Object
length
;
private
Object
callee
;
private
ArrayData
namedArgs
;
// This is lazily initialized - only when delete is invoked at all
private
BitSet
deleted
;
NativeArguments
(
final
ScriptObject
proto
,
final
Object
[]
arguments
,
final
Object
callee
,
final
int
numParams
)
{
super
(
proto
,
map
$
);
NativeArguments
(
final
Object
[]
arguments
,
final
Object
callee
,
final
int
numParams
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
setIsArguments
();
setArray
(
ArrayData
.
allocate
(
arguments
));
...
...
@@ -550,8 +554,13 @@ public final class NativeArguments extends ScriptObject {
public
static
ScriptObject
allocate
(
final
Object
[]
arguments
,
final
ScriptFunction
callee
,
final
int
numParams
)
{
// Strict functions won't always have a callee for arguments, and will pass null instead.
final
boolean
isStrict
=
callee
==
null
||
callee
.
isStrict
();
final
ScriptObject
proto
=
Global
.
objectPrototype
();
return
isStrict
?
new
NativeStrictArguments
(
proto
,
arguments
,
numParams
)
:
new
NativeArguments
(
proto
,
arguments
,
callee
,
numParams
);
final
Global
global
=
Global
.
instance
();
final
ScriptObject
proto
=
global
.
getObjectPrototype
();
if
(
isStrict
)
{
return
new
NativeStrictArguments
(
arguments
,
numParams
,
proto
,
global
.
getStrictArgumentsMap
());
}
else
{
return
new
NativeArguments
(
arguments
,
callee
,
numParams
,
proto
,
global
.
getArgumentsMap
());
}
}
/**
...
...
@@ -623,11 +632,6 @@ public final class NativeArguments extends ScriptObject {
}
private
static
MethodHandle
findOwnMH
(
final
String
name
,
final
Class
<?>
rtype
,
final
Class
<?>...
types
)
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeArguments
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeArguments
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeArray.java
浏览文件 @
874a8be8
...
...
@@ -86,6 +86,10 @@ public final class NativeArray extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
/*
* Constructors.
*/
...
...
@@ -130,7 +134,11 @@ public final class NativeArray extends ScriptObject {
}
NativeArray
(
final
ArrayData
arrayData
)
{
super
(
Global
.
instance
().
getArrayPrototype
(),
$nasgenmap
$
);
this
(
arrayData
,
Global
.
instance
());
}
NativeArray
(
final
ArrayData
arrayData
,
final
Global
global
)
{
super
(
global
.
getArrayPrototype
(),
global
.
getArrayMap
());
this
.
setArray
(
arrayData
);
this
.
setIsArray
();
}
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
浏览文件 @
874a8be8
...
...
@@ -43,6 +43,10 @@ final class NativeArrayBuffer extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
@Constructor
(
arity
=
1
)
public
static
Object
constructor
(
final
boolean
newObj
,
final
Object
self
,
final
Object
...
args
)
{
if
(
args
.
length
==
0
)
{
...
...
@@ -52,11 +56,15 @@ final class NativeArrayBuffer extends ScriptObject {
return
new
NativeArrayBuffer
(
JSType
.
toInt32
(
args
[
0
]));
}
protected
NativeArrayBuffer
(
final
byte
[]
byteArray
)
{
super
(
Global
.
instance
().
getArrayBufferPrototype
(),
$nasgenmap
$
);
protected
NativeArrayBuffer
(
final
byte
[]
byteArray
,
final
Global
global
)
{
super
(
global
.
getArrayBufferPrototype
(),
global
.
getArrayBufferMap
()
);
this
.
buffer
=
byteArray
;
}
protected
NativeArrayBuffer
(
final
byte
[]
byteArray
)
{
this
(
byteArray
,
Global
.
instance
());
}
protected
NativeArrayBuffer
(
final
int
byteLength
)
{
this
(
new
byte
[
byteLength
]);
}
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeBoolean.java
浏览文件 @
874a8be8
...
...
@@ -56,15 +56,23 @@ public final class NativeBoolean extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeBoolean
(
final
boolean
value
)
{
this
(
value
,
Global
.
instance
().
getBooleanPrototype
())
;
static
PropertyMap
getInitialMap
(
)
{
return
$nasgenmap
$
;
}
private
NativeBoolean
(
final
boolean
value
,
final
ScriptObject
proto
)
{
super
(
proto
,
$nasgenmap
$
);
private
NativeBoolean
(
final
boolean
value
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
this
.
value
=
value
;
}
NativeBoolean
(
final
boolean
flag
,
final
Global
global
)
{
this
(
flag
,
global
.
getBooleanPrototype
(),
global
.
getBooleanMap
());
}
NativeBoolean
(
final
boolean
flag
)
{
this
(
flag
,
Global
.
instance
());
}
@Override
public
String
safeToString
()
{
return
"[Boolean "
+
toString
()
+
"]"
;
...
...
@@ -131,11 +139,7 @@ public final class NativeBoolean extends ScriptObject {
final
boolean
flag
=
JSType
.
toBoolean
(
value
);
if
(
newObj
)
{
final
ScriptObject
proto
=
(
self
instanceof
ScriptObject
)
?
((
ScriptObject
)
self
).
getProto
()
:
Global
.
instance
().
getBooleanPrototype
();
return
new
NativeBoolean
(
flag
,
proto
);
return
new
NativeBoolean
(
flag
);
}
return
flag
;
...
...
@@ -176,10 +180,6 @@ public final class NativeBoolean extends ScriptObject {
}
private
static
MethodHandle
findWrapFilter
()
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeBoolean
.
class
,
"wrapFilter"
,
MH
.
type
(
NativeBoolean
.
class
,
Object
.
class
));
}
catch
(
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeBoolean
.
class
,
"wrapFilter"
,
MH
.
type
(
NativeBoolean
.
class
,
Object
.
class
));
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeDate.java
浏览文件 @
874a8be8
...
...
@@ -104,18 +104,30 @@ public final class NativeDate extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeDate
()
{
this
(
System
.
currentTimeMillis
())
;
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
NativeDate
(
final
double
time
)
{
super
(
Global
.
instance
().
getDatePrototype
(),
$nasgenmap
$
);
private
NativeDate
(
final
double
time
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
final
ScriptEnvironment
env
=
Global
.
getEnv
();
this
.
time
=
time
;
this
.
timezone
=
env
.
_timezone
;
}
NativeDate
(
final
double
time
,
final
Global
global
)
{
this
(
time
,
global
.
getDatePrototype
(),
global
.
getDateMap
());
}
private
NativeDate
(
final
double
time
)
{
this
(
time
,
Global
.
instance
());
}
private
NativeDate
()
{
this
(
System
.
currentTimeMillis
());
}
@Override
public
String
getClassName
()
{
return
"Date"
;
...
...
@@ -153,6 +165,10 @@ public final class NativeDate extends ScriptObject {
*/
@Constructor
(
arity
=
7
)
public
static
Object
construct
(
final
boolean
isNew
,
final
Object
self
,
final
Object
...
args
)
{
if
(!
isNew
)
{
return
toStringImpl
(
new
NativeDate
(),
FORMAT_DATE_TIME
);
}
NativeDate
result
;
switch
(
args
.
length
)
{
case
0
:
...
...
@@ -182,7 +198,7 @@ public final class NativeDate extends ScriptObject {
break
;
}
return
isNew
?
result
:
toStringImpl
(
new
NativeDate
(),
FORMAT_DATE_TIME
)
;
return
result
;
}
@Override
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
浏览文件 @
874a8be8
...
...
@@ -51,8 +51,9 @@ public final class NativeDebug extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeDebug
()
{
super
(
Global
.
objectPrototype
(),
$nasgenmap
$
);
private
NativeDebug
()
{
// don't create me!
throw
new
UnsupportedOperationException
();
}
@Override
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeError.java
浏览文件 @
874a8be8
...
...
@@ -87,8 +87,12 @@ public final class NativeError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
private
NativeError
(
final
Object
msg
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -96,6 +100,14 @@ public final class NativeError extends ScriptObject {
}
}
NativeError
(
final
Object
msg
,
final
Global
global
)
{
this
(
msg
,
global
.
getErrorPrototype
(),
global
.
getErrorMap
());
}
private
NativeError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
...
...
@@ -354,11 +366,7 @@ public final class NativeError extends ScriptObject {
}
private
static
MethodHandle
findOwnMH
(
final
String
name
,
final
Class
<?>
rtype
,
final
Class
<?>...
types
)
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeError
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeError
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
private
static
String
getScriptStackString
(
final
ScriptObject
sobj
,
final
Throwable
exp
)
{
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeEvalError.java
浏览文件 @
874a8be8
...
...
@@ -58,8 +58,12 @@ public final class NativeEvalError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeEvalError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getEvalErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
private
NativeEvalError
(
final
Object
msg
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -67,12 +71,19 @@ public final class NativeEvalError extends ScriptObject {
}
}
NativeEvalError
(
final
Object
msg
,
final
Global
global
)
{
this
(
msg
,
global
.
getEvalErrorPrototype
(),
global
.
getEvalErrorMap
());
}
private
NativeEvalError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
}
/**
* ECMA 15.11.6.1 EvalError
*
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeFloat32Array.java
浏览文件 @
874a8be8
...
...
@@ -192,7 +192,7 @@ public final class NativeFloat32Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getFloat32ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getFloat32ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeFloat64Array.java
浏览文件 @
874a8be8
...
...
@@ -202,7 +202,7 @@ public final class NativeFloat64Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getFloat64ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getFloat64ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeFunction.java
浏览文件 @
874a8be8
...
...
@@ -61,6 +61,7 @@ public final class NativeFunction {
// do *not* create me!
private
NativeFunction
()
{
throw
new
UnsupportedOperationException
();
}
/**
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeInt16Array.java
浏览文件 @
874a8be8
...
...
@@ -151,7 +151,7 @@ public final class NativeInt16Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getInt16ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getInt16ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeInt32Array.java
浏览文件 @
874a8be8
...
...
@@ -154,7 +154,7 @@ public final class NativeInt32Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getInt32ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getInt32ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeInt8Array.java
浏览文件 @
874a8be8
...
...
@@ -144,7 +144,7 @@ public final class NativeInt8Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getInt8ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getInt8ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeJSAdapter.java
浏览文件 @
874a8be8
...
...
@@ -49,6 +49,7 @@ import jdk.nashorn.internal.runtime.ScriptRuntime;
import
jdk.nashorn.internal.runtime.arrays.ArrayLikeIterator
;
import
jdk.nashorn.internal.lookup.Lookup
;
import
jdk.nashorn.internal.lookup.MethodHandleFactory
;
import
jdk.nashorn.internal.scripts.JO
;
/**
* This class is the implementation of the Nashorn-specific global object named {@code JSAdapter}. It can be
...
...
@@ -146,8 +147,12 @@ public final class NativeJSAdapter extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeJSAdapter
(
final
ScriptObject
proto
,
final
Object
overrides
,
final
ScriptObject
adaptee
)
{
super
(
proto
,
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
NativeJSAdapter
(
final
Object
overrides
,
final
ScriptObject
adaptee
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
this
.
adaptee
=
wrapAdaptee
(
adaptee
);
if
(
overrides
instanceof
ScriptObject
)
{
this
.
overrides
=
true
;
...
...
@@ -159,9 +164,7 @@ public final class NativeJSAdapter extends ScriptObject {
}
private
static
ScriptObject
wrapAdaptee
(
final
ScriptObject
adaptee
)
{
final
ScriptObject
sobj
=
new
jdk
.
nashorn
.
internal
.
scripts
.
JO
();
sobj
.
setProto
(
adaptee
);
return
sobj
;
return
new
JO
(
adaptee
,
Global
.
instance
().
getObjectMap
());
}
@Override
...
...
@@ -570,11 +573,12 @@ public final class NativeJSAdapter extends ScriptObject {
throw
typeError
(
"not.an.object"
,
ScriptRuntime
.
safeToString
(
adaptee
));
}
final
Global
global
=
Global
.
instance
();
if
(
proto
!=
null
&&
!(
proto
instanceof
ScriptObject
))
{
proto
=
Global
.
instance
()
.
getJSAdapterPrototype
();
proto
=
global
.
getJSAdapterPrototype
();
}
return
new
NativeJSAdapter
(
(
ScriptObject
)
proto
,
overrides
,
(
ScriptObject
)
adaptee
);
return
new
NativeJSAdapter
(
overrides
,
(
ScriptObject
)
adaptee
,
(
ScriptObject
)
proto
,
global
.
getJSAdapterMap
()
);
}
@Override
...
...
@@ -736,10 +740,6 @@ public final class NativeJSAdapter extends ScriptObject {
}
private
static
MethodHandle
findOwnMH
(
final
String
name
,
final
Class
<?>
rtype
,
final
Class
<?>...
types
)
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeJSAdapter
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeJSAdapter
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeJSON.java
浏览文件 @
874a8be8
...
...
@@ -62,8 +62,9 @@ public final class NativeJSON extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeJSON
()
{
super
(
Global
.
objectPrototype
(),
$nasgenmap
$
);
private
NativeJSON
()
{
// don't create me!!
throw
new
UnsupportedOperationException
();
}
/**
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeJava.java
浏览文件 @
874a8be8
...
...
@@ -60,6 +60,8 @@ public final class NativeJava {
private
static
PropertyMap
$nasgenmap
$
;
private
NativeJava
()
{
// don't create me
throw
new
UnsupportedOperationException
();
}
/**
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java
浏览文件 @
874a8be8
...
...
@@ -59,11 +59,23 @@ public final class NativeJavaImporter extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeJavaImporter
(
final
Object
[]
args
)
{
super
(
Global
.
instance
().
getJavaImporterPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
private
NativeJavaImporter
(
final
Object
[]
args
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
this
.
args
=
args
;
}
private
NativeJavaImporter
(
final
Object
[]
args
,
final
Global
global
)
{
this
(
args
,
global
.
getJavaImporterPrototype
(),
global
.
getJavaImporterMap
());
}
private
NativeJavaImporter
(
final
Object
[]
args
)
{
this
(
args
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"JavaImporter"
;
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeMath.java
浏览文件 @
874a8be8
...
...
@@ -45,8 +45,9 @@ public final class NativeMath extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeMath
()
{
super
(
Global
.
objectPrototype
(),
$nasgenmap
$
);
private
NativeMath
()
{
// don't create me!
throw
new
UnsupportedOperationException
();
}
/** ECMA 15.8.1.1 - E, always a double constant. Not writable or configurable */
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeNumber.java
浏览文件 @
874a8be8
...
...
@@ -87,17 +87,26 @@ public final class NativeNumber extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeNumber
(
final
double
value
)
{
this
(
value
,
Global
.
instance
().
getNumberPrototype
())
;
static
PropertyMap
getInitialMap
(
)
{
return
$nasgenmap
$
;
}
private
NativeNumber
(
final
double
value
,
final
ScriptObject
proto
)
{
super
(
proto
,
$nasgenmap
$
);
private
NativeNumber
(
final
double
value
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
this
.
value
=
value
;
this
.
isInt
=
isRepresentableAsInt
(
value
);
this
.
isLong
=
isRepresentableAsLong
(
value
);
}
NativeNumber
(
final
double
value
,
final
Global
global
)
{
this
(
value
,
global
.
getNumberPrototype
(),
global
.
getNumberMap
());
}
private
NativeNumber
(
final
double
value
)
{
this
(
value
,
Global
.
instance
());
}
@Override
public
String
safeToString
()
{
return
"[Number "
+
toString
()
+
"]"
;
...
...
@@ -165,16 +174,7 @@ public final class NativeNumber extends ScriptObject {
public
static
Object
constructor
(
final
boolean
newObj
,
final
Object
self
,
final
Object
...
args
)
{
final
double
num
=
(
args
.
length
>
0
)
?
JSType
.
toNumber
(
args
[
0
])
:
0.0
;
if
(
newObj
)
{
final
ScriptObject
proto
=
(
self
instanceof
ScriptObject
)
?
((
ScriptObject
)
self
).
getProto
()
:
Global
.
instance
().
getNumberPrototype
();
return
new
NativeNumber
(
num
,
proto
);
}
return
num
;
return
newObj
?
new
NativeNumber
(
num
)
:
num
;
}
/**
...
...
@@ -380,10 +380,6 @@ public final class NativeNumber extends ScriptObject {
}
private
static
MethodHandle
findWrapFilter
()
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeNumber
.
class
,
"wrapFilter"
,
MH
.
type
(
NativeNumber
.
class
,
Object
.
class
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeNumber
.
class
,
"wrapFilter"
,
MH
.
type
(
NativeNumber
.
class
,
Object
.
class
));
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeObject.java
浏览文件 @
874a8be8
...
...
@@ -58,6 +58,8 @@ public final class NativeObject {
private
static
PropertyMap
$nasgenmap
$
;
private
NativeObject
()
{
// don't create me!
throw
new
UnsupportedOperationException
();
}
private
static
ECMAException
notAnObject
(
final
Object
obj
)
{
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeRangeError.java
浏览文件 @
874a8be8
...
...
@@ -58,8 +58,12 @@ public final class NativeRangeError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeRangeError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getRangeErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
private
NativeRangeError
(
final
Object
msg
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -67,6 +71,14 @@ public final class NativeRangeError extends ScriptObject {
}
}
NativeRangeError
(
final
Object
msg
,
final
Global
global
)
{
this
(
msg
,
global
.
getRangeErrorPrototype
(),
global
.
getRangeErrorMap
());
}
private
NativeRangeError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeReferenceError.java
浏览文件 @
874a8be8
...
...
@@ -58,8 +58,12 @@ public final class NativeReferenceError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeReferenceError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getReferenceErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
private
NativeReferenceError
(
final
Object
msg
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -67,6 +71,14 @@ public final class NativeReferenceError extends ScriptObject {
}
}
NativeReferenceError
(
final
Object
msg
,
final
Global
global
)
{
this
(
msg
,
global
.
getReferenceErrorPrototype
(),
global
.
getReferenceErrorMap
());
}
private
NativeReferenceError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeRegExp.java
浏览文件 @
874a8be8
...
...
@@ -71,7 +71,17 @@ public final class NativeRegExp extends ScriptObject {
@SuppressWarnings
(
"unused"
)
private
static
PropertyMap
$nasgenmap
$
;
NativeRegExp
(
final
String
input
,
final
String
flagString
)
{
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
private
NativeRegExp
(
final
Global
global
)
{
super
(
global
.
getRegExpPrototype
(),
global
.
getRegExpMap
());
this
.
globalObject
=
global
;
}
NativeRegExp
(
final
String
input
,
final
String
flagString
,
final
Global
global
)
{
this
(
global
);
try
{
this
.
regexp
=
RegExpFactory
.
create
(
input
,
flagString
);
}
catch
(
final
ParserException
e
)
{
...
...
@@ -81,17 +91,24 @@ public final class NativeRegExp extends ScriptObject {
}
this
.
setLastIndex
(
0
);
init
();
}
NativeRegExp
(
final
String
input
,
final
String
flagString
)
{
this
(
input
,
flagString
,
Global
.
instance
());
}
NativeRegExp
(
final
String
string
,
final
Global
global
)
{
this
(
string
,
""
,
global
);
}
NativeRegExp
(
final
String
string
)
{
this
(
string
,
""
);
this
(
string
,
Global
.
instance
()
);
}
NativeRegExp
(
final
NativeRegExp
regExp
)
{
this
(
Global
.
instance
());
this
.
lastIndex
=
regExp
.
getLastIndexObject
();
this
.
regexp
=
regExp
.
getRegExp
();
init
();
}
@Override
...
...
@@ -615,7 +632,7 @@ public final class NativeRegExp extends ScriptObject {
return
null
;
}
return
new
NativeRegExpExecResult
(
match
);
return
new
NativeRegExpExecResult
(
match
,
globalObject
);
}
/**
...
...
@@ -886,12 +903,6 @@ public final class NativeRegExp extends ScriptObject {
this
.
lastIndex
=
JSType
.
toObject
(
lastIndex
);
}
private
void
init
()
{
// Keep reference to global object to support "static" properties of RegExp
this
.
globalObject
=
Global
.
instance
();
this
.
setProto
(
globalObject
.
getRegExpPrototype
());
}
private
static
NativeRegExp
checkRegExp
(
final
Object
self
)
{
Global
.
checkObjectCoercible
(
self
);
if
(
self
instanceof
NativeRegExp
)
{
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeRegExpExecResult.java
浏览文件 @
874a8be8
...
...
@@ -53,8 +53,12 @@ public final class NativeRegExpExecResult extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeRegExpExecResult
(
final
RegExpResult
result
)
{
super
(
Global
.
instance
().
getArrayPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
NativeRegExpExecResult
(
final
RegExpResult
result
,
final
Global
global
)
{
super
(
global
.
getArrayPrototype
(),
global
.
getRegExpExecResultMap
());
setIsArray
();
this
.
setArray
(
ArrayData
.
allocate
(
result
.
getGroups
().
clone
()));
this
.
index
=
result
.
getIndex
();
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java
浏览文件 @
874a8be8
...
...
@@ -64,11 +64,15 @@ public final class NativeStrictArguments extends ScriptObject {
map
$
=
map
;
}
static
PropertyMap
getInitialMap
()
{
return
map
$
;
}
private
Object
length
;
private
final
Object
[]
namedArgs
;
NativeStrictArguments
(
final
ScriptObject
proto
,
final
Object
[]
values
,
final
int
numParams
)
{
super
(
proto
,
map
$
);
NativeStrictArguments
(
final
Object
[]
values
,
final
int
numParams
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
setIsArguments
();
final
ScriptFunction
func
=
ScriptFunctionImpl
.
getTypeErrorThrower
();
...
...
@@ -143,10 +147,6 @@ public final class NativeStrictArguments extends ScriptObject {
}
private
static
MethodHandle
findOwnMH
(
final
String
name
,
final
Class
<?>
rtype
,
final
Class
<?>...
types
)
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeStrictArguments
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeStrictArguments
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeString.java
浏览文件 @
874a8be8
...
...
@@ -41,7 +41,7 @@ import java.util.Locale;
import
jdk.internal.dynalink.CallSiteDescriptor
;
import
jdk.internal.dynalink.linker.GuardedInvocation
;
import
jdk.internal.dynalink.linker.LinkRequest
;
import
jdk.nashorn.internal.lookup.MethodHandleFactory
;
import
jdk.nashorn.internal.lookup.MethodHandleFactory
.LookupException
;
import
jdk.nashorn.internal.objects.annotations.Attribute
;
import
jdk.nashorn.internal.objects.annotations.Constructor
;
import
jdk.nashorn.internal.objects.annotations.Function
;
...
...
@@ -74,12 +74,20 @@ public final class NativeString extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeString
(
final
CharSequence
value
)
{
this
(
value
,
Global
.
instance
().
getStringPrototype
())
;
static
PropertyMap
getInitialMap
(
)
{
return
$nasgenmap
$
;
}
private
NativeString
(
final
CharSequence
value
,
final
ScriptObject
proto
)
{
super
(
proto
,
$nasgenmap
$
);
private
NativeString
(
final
CharSequence
value
)
{
this
(
value
,
Global
.
instance
());
}
NativeString
(
final
CharSequence
value
,
final
Global
global
)
{
this
(
value
,
global
.
getStringPrototype
(),
global
.
getStringMap
());
}
private
NativeString
(
final
CharSequence
value
,
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
assert
value
instanceof
String
||
value
instanceof
ConsString
;
this
.
value
=
value
;
}
...
...
@@ -147,9 +155,9 @@ public final class NativeString extends ScriptObject {
if
(
returnType
==
Object
.
class
&&
(
self
instanceof
String
||
self
instanceof
ConsString
))
{
try
{
MethodHandle
mh
=
M
ethodHandles
.
lookup
().
findStatic
(
NativeString
.
class
,
"get"
,
desc
.
getMethodType
());
MethodHandle
mh
=
M
H
.
findStatic
(
MethodHandles
.
lookup
(),
NativeString
.
class
,
"get"
,
desc
.
getMethodType
());
return
new
GuardedInvocation
(
mh
,
NashornGuards
.
getInstanceOf2Guard
(
String
.
class
,
ConsString
.
class
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccess
Exception
e
)
{
}
catch
(
final
Lookup
Exception
e
)
{
// Shouldn't happen. Fall back to super
}
}
...
...
@@ -1065,10 +1073,7 @@ public final class NativeString extends ScriptObject {
}
private
static
Object
newObj
(
final
Object
self
,
final
CharSequence
str
)
{
if
(
self
instanceof
ScriptObject
)
{
return
new
NativeString
(
str
,
((
ScriptObject
)
self
).
getProto
());
}
return
new
NativeString
(
str
,
Global
.
instance
().
getStringPrototype
());
return
new
NativeString
(
str
);
}
/**
...
...
@@ -1202,10 +1207,6 @@ public final class NativeString extends ScriptObject {
}
private
static
MethodHandle
findWrapFilter
()
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
NativeString
.
class
,
"wrapFilter"
,
MH
.
type
(
NativeString
.
class
,
Object
.
class
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
NativeString
.
class
,
"wrapFilter"
,
MH
.
type
(
NativeString
.
class
,
Object
.
class
));
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeSyntaxError.java
浏览文件 @
874a8be8
...
...
@@ -58,8 +58,12 @@ public final class NativeSyntaxError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeSyntaxError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getSyntaxErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
NativeSyntaxError
(
final
Object
msg
,
final
Global
global
)
{
super
(
global
.
getSyntaxErrorPrototype
(),
global
.
getSyntaxErrorMap
());
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -67,6 +71,10 @@ public final class NativeSyntaxError extends ScriptObject {
}
}
private
NativeSyntaxError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeTypeError.java
浏览文件 @
874a8be8
...
...
@@ -58,8 +58,12 @@ public final class NativeTypeError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeTypeError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getTypeErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
NativeTypeError
(
final
Object
msg
,
final
Global
global
)
{
super
(
global
.
getTypeErrorPrototype
(),
global
.
getTypeErrorMap
());
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -67,6 +71,10 @@ public final class NativeTypeError extends ScriptObject {
}
}
private
NativeTypeError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeURIError.java
浏览文件 @
874a8be8
...
...
@@ -57,8 +57,12 @@ public final class NativeURIError extends ScriptObject {
// initialized by nasgen
private
static
PropertyMap
$nasgenmap
$
;
NativeURIError
(
final
Object
msg
)
{
super
(
Global
.
instance
().
getURIErrorPrototype
(),
$nasgenmap
$
);
static
PropertyMap
getInitialMap
()
{
return
$nasgenmap
$
;
}
NativeURIError
(
final
Object
msg
,
final
Global
global
)
{
super
(
global
.
getURIErrorPrototype
(),
global
.
getURIErrorMap
());
if
(
msg
!=
UNDEFINED
)
{
this
.
instMessage
=
JSType
.
toString
(
msg
);
}
else
{
...
...
@@ -66,6 +70,10 @@ public final class NativeURIError extends ScriptObject {
}
}
private
NativeURIError
(
final
Object
msg
)
{
this
(
msg
,
Global
.
instance
());
}
@Override
public
String
getClassName
()
{
return
"Error"
;
...
...
nashorn/src/jdk/nashorn/internal/objects/NativeUint16Array.java
浏览文件 @
874a8be8
...
...
@@ -150,7 +150,7 @@ public final class NativeUint16Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getUint16ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getUint16ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeUint32Array.java
浏览文件 @
874a8be8
...
...
@@ -169,7 +169,7 @@ public final class NativeUint32Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getUint32ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getUint32ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeUint8Array.java
浏览文件 @
874a8be8
...
...
@@ -143,7 +143,7 @@ public final class NativeUint8Array extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getUint8ArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getUint8ArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
浏览文件 @
874a8be8
...
...
@@ -160,7 +160,7 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
}
@Override
protected
ScriptObject
getPrototype
()
{
return
Global
.
instance
()
.
getUint8ClampedArrayPrototype
();
protected
ScriptObject
getPrototype
(
final
Global
global
)
{
return
global
.
getUint8ClampedArrayPrototype
();
}
}
nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java
浏览文件 @
874a8be8
...
...
@@ -57,8 +57,17 @@ public class PrototypeObject extends ScriptObject {
map
$
=
map
;
}
static
PropertyMap
getInitialMap
()
{
return
map
$
;
}
private
PrototypeObject
(
final
Global
global
,
final
PropertyMap
map
)
{
super
(
map
!=
map
$
?
map
.
addAll
(
global
.
getPrototypeObjectMap
())
:
global
.
getPrototypeObjectMap
());
setProto
(
global
.
getObjectPrototype
());
}
PrototypeObject
()
{
this
(
map
$
);
this
(
Global
.
instance
(),
map
$
);
}
/**
...
...
@@ -67,12 +76,11 @@ public class PrototypeObject extends ScriptObject {
* @param map property map
*/
public
PrototypeObject
(
final
PropertyMap
map
)
{
super
(
map
!=
map
$
?
map
.
addAll
(
map
$
)
:
map
$
);
setProto
(
Global
.
objectPrototype
());
this
(
Global
.
instance
(),
map
);
}
PrototypeObject
(
final
ScriptFunction
func
)
{
this
(
map
$
);
this
(
Global
.
instance
(),
map
$
);
this
.
constructor
=
func
;
}
...
...
@@ -107,10 +115,6 @@ public class PrototypeObject extends ScriptObject {
}
private
static
MethodHandle
findOwnMH
(
final
String
name
,
final
Class
<?>
rtype
,
final
Class
<?>...
types
)
{
try
{
return
MethodHandles
.
lookup
().
findStatic
(
PrototypeObject
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
catch
(
final
NoSuchMethodException
|
IllegalAccessException
e
)
{
throw
new
MethodHandleFactory
.
LookupException
(
e
);
}
return
MH
.
findStatic
(
MethodHandles
.
lookup
(),
PrototypeObject
.
class
,
name
,
MH
.
type
(
rtype
,
types
));
}
}
nashorn/src/jdk/nashorn/internal/objects/ScriptFunctionImpl.java
浏览文件 @
874a8be8
...
...
@@ -53,9 +53,26 @@ public class ScriptFunctionImpl extends ScriptFunction {
// property map for non-strict, non-bound functions.
private
static
final
PropertyMap
map
$
;
static
PropertyMap
getInitialMap
()
{
return
map
$
;
}
static
PropertyMap
getInitialStrictMap
()
{
return
strictmodemap
$
;
}
static
PropertyMap
getInitialBoundMap
()
{
return
boundfunctionmap
$
;
}
// Marker object for lazily initialized prototype object
private
static
final
Object
LAZY_PROTOTYPE
=
new
Object
();
private
ScriptFunctionImpl
(
final
String
name
,
final
MethodHandle
invokeHandle
,
final
MethodHandle
[]
specs
,
final
Global
global
)
{
super
(
name
,
invokeHandle
,
global
.
getFunctionMap
(),
null
,
specs
,
false
,
true
,
true
);
init
(
global
);
}
/**
* Constructor called by Nasgen generated code, no membercount, use the default map.
* Creates builtin functions only.
...
...
@@ -65,8 +82,12 @@ public class ScriptFunctionImpl extends ScriptFunction {
* @param specs specialized versions of this method, if available, null otherwise
*/
ScriptFunctionImpl
(
final
String
name
,
final
MethodHandle
invokeHandle
,
final
MethodHandle
[]
specs
)
{
super
(
name
,
invokeHandle
,
map
$
,
null
,
specs
,
false
,
true
,
true
);
init
();
this
(
name
,
invokeHandle
,
specs
,
Global
.
instance
());
}
private
ScriptFunctionImpl
(
final
String
name
,
final
MethodHandle
invokeHandle
,
final
PropertyMap
map
,
final
MethodHandle
[]
specs
,
final
Global
global
)
{
super
(
name
,
invokeHandle
,
map
.
addAll
(
global
.
getFunctionMap
()),
null
,
specs
,
false
,
true
,
true
);
init
(
global
);
}
/**
...
...
@@ -79,8 +100,12 @@ public class ScriptFunctionImpl extends ScriptFunction {
* @param specs specialized versions of this method, if available, null otherwise
*/
ScriptFunctionImpl
(
final
String
name
,
final
MethodHandle
invokeHandle
,
final
PropertyMap
map
,
final
MethodHandle
[]
specs
)
{
super
(
name
,
invokeHandle
,
map
.
addAll
(
map
$
),
null
,
specs
,
false
,
true
,
true
);
init
();
this
(
name
,
invokeHandle
,
map
,
specs
,
Global
.
instance
());
}
private
ScriptFunctionImpl
(
final
String
name
,
final
MethodHandle
methodHandle
,
final
ScriptObject
scope
,
final
MethodHandle
[]
specs
,
final
boolean
isStrict
,
final
boolean
isBuiltin
,
final
boolean
isConstructor
,
final
Global
global
)
{
super
(
name
,
methodHandle
,
getMap
(
global
,
isStrict
),
scope
,
specs
,
isStrict
,
isBuiltin
,
isConstructor
);
init
(
global
);
}
/**
...
...
@@ -95,8 +120,12 @@ public class ScriptFunctionImpl extends ScriptFunction {
* @param isConstructor can the function be used as a constructor (most can; some built-ins are restricted).
*/
ScriptFunctionImpl
(
final
String
name
,
final
MethodHandle
methodHandle
,
final
ScriptObject
scope
,
final
MethodHandle
[]
specs
,
final
boolean
isStrict
,
final
boolean
isBuiltin
,
final
boolean
isConstructor
)
{
super
(
name
,
methodHandle
,
getMap
(
isStrict
),
scope
,
specs
,
isStrict
,
isBuiltin
,
isConstructor
);
init
();
this
(
name
,
methodHandle
,
scope
,
specs
,
isStrict
,
isBuiltin
,
isConstructor
,
Global
.
instance
());
}
private
ScriptFunctionImpl
(
final
RecompilableScriptFunctionData
data
,
final
ScriptObject
scope
,
final
Global
global
)
{
super
(
data
,
getMap
(
global
,
data
.
isStrict
()),
scope
);
init
(
global
);
}
/**
...
...
@@ -106,17 +135,17 @@ public class ScriptFunctionImpl extends ScriptFunction {
* @param scope scope object
*/
public
ScriptFunctionImpl
(
final
RecompilableScriptFunctionData
data
,
final
ScriptObject
scope
)
{
super
(
data
,
getMap
(
data
.
isStrict
()),
scope
);
init
();
this
(
data
,
scope
,
Global
.
instance
());
}
/**
* Only invoked internally from {@link BoundScriptFunctionImpl} constructor.
* @param data the script function data for the bound function.
* @param global the global object
*/
ScriptFunctionImpl
(
final
ScriptFunctionData
data
)
{
super
(
data
,
boundfunctionmap
$
,
null
);
init
();
ScriptFunctionImpl
(
final
ScriptFunctionData
data
,
final
Global
global
)
{
super
(
data
,
global
.
getBoundFunctionMap
()
,
null
);
init
(
global
);
}
static
{
...
...
@@ -159,8 +188,8 @@ public class ScriptFunctionImpl extends ScriptFunction {
}
// Choose the map based on strict mode!
private
static
PropertyMap
getMap
(
final
boolean
strict
)
{
return
strict
?
strictmodemap
$
:
map
$
;
private
static
PropertyMap
getMap
(
final
Global
global
,
final
boolean
strict
)
{
return
strict
?
global
.
getStrictFunctionMap
()
:
global
.
getFunctionMap
()
;
}
private
static
PropertyMap
createBoundFunctionMap
(
final
PropertyMap
strictModeMap
)
{
...
...
@@ -255,8 +284,8 @@ public class ScriptFunctionImpl extends ScriptFunction {
}
// Internals below..
private
void
init
()
{
this
.
setProto
(
Global
.
instance
()
.
getFunctionPrototype
());
private
void
init
(
final
Global
global
)
{
this
.
setProto
(
global
.
getFunctionPrototype
());
this
.
prototype
=
LAZY_PROTOTYPE
;
// We have to fill user accessor functions late as these are stored
...
...
nashorn/src/jdk/nashorn/internal/runtime/Context.java
浏览文件 @
874a8be8
...
...
@@ -36,7 +36,6 @@ import java.io.IOException;
import
java.io.PrintWriter
;
import
java.lang.invoke.MethodHandle
;
import
java.lang.invoke.MethodHandles
;
import
java.lang.reflect.Constructor
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.security.AccessControlContext
;
...
...
@@ -55,6 +54,7 @@ import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import
jdk.nashorn.internal.ir.FunctionNode
;
import
jdk.nashorn.internal.ir.debug.ASTWriter
;
import
jdk.nashorn.internal.ir.debug.PrintVisitor
;
import
jdk.nashorn.internal.objects.Global
;
import
jdk.nashorn.internal.parser.Parser
;
import
jdk.nashorn.internal.runtime.options.Options
;
...
...
@@ -123,8 +123,8 @@ public final class Context {
sm
.
checkPermission
(
new
RuntimePermission
(
"nashorn.setGlobal"
));
}
if
(
global
!=
null
&&
!(
global
instanceof
Global
Object
))
{
throw
new
IllegalArgumentException
(
"global
does not implement GlobalObject
!"
);
if
(
global
!=
null
&&
!(
global
instanceof
Global
))
{
throw
new
IllegalArgumentException
(
"global
is not an instance of Global
!"
);
}
setGlobalTrusted
(
global
);
...
...
@@ -257,8 +257,7 @@ public final class Context {
new
PrivilegedAction
<
ClassLoader
>()
{
@Override
public
ClassLoader
run
()
{
final
StructureLoader
structureLoader
=
new
StructureLoader
(
sharedLoader
,
Context
.
this
);
return
new
ScriptLoader
(
structureLoader
,
Context
.
this
);
return
new
ScriptLoader
(
sharedLoader
,
Context
.
this
);
}
});
this
.
errors
=
errors
;
...
...
@@ -817,25 +816,12 @@ public final class Context {
new
PrivilegedAction
<
ScriptLoader
>()
{
@Override
public
ScriptLoader
run
()
{
// Generated code won't refer to any class generated by context
// script loader and so parent loader can be the structure
// loader -- which is parent of the context script loader.
return
new
ScriptLoader
((
StructureLoader
)
scriptLoader
.
getParent
(),
Context
.
this
);
return
new
ScriptLoader
(
sharedLoader
,
Context
.
this
);
}
});
}
private
ScriptObject
newGlobalTrusted
()
{
try
{
final
Class
<?>
clazz
=
Class
.
forName
(
"jdk.nashorn.internal.objects.Global"
,
true
,
scriptLoader
);
final
Constructor
<?>
cstr
=
clazz
.
getConstructor
(
Context
.
class
);
return
(
ScriptObject
)
cstr
.
newInstance
(
this
);
}
catch
(
final
Exception
e
)
{
printStackTrace
(
e
);
if
(
e
instanceof
RuntimeException
)
{
throw
(
RuntimeException
)
e
;
}
throw
new
RuntimeException
(
e
);
}
return
new
Global
(
this
);
}
}
nashorn/src/jdk/nashorn/internal/runtime/GlobalFunctions.java
浏览文件 @
874a8be8
...
...
@@ -34,9 +34,6 @@ import java.util.Locale;
/**
* Utilities used by Global class.
*
* These are actual implementation methods for functions exposed by global
* scope. The code lives here to share the code across the contexts.
*/
public
final
class
GlobalFunctions
{
...
...
nashorn/src/jdk/nashorn/internal/runtime/GlobalObject.java
浏览文件 @
874a8be8
...
...
@@ -30,14 +30,7 @@ import jdk.internal.dynalink.linker.GuardedInvocation;
import
jdk.internal.dynalink.linker.LinkRequest
;
/**
* Runtime interface to the global scope of the current context.
* NOTE: never access {@code jdk.nashorn.internal.objects.Global} class directly
* from runtime/parser/codegen/ir etc. Always go through this interface.
* <p>
* The reason for this is that all objects in the @{code jdk.nashorn.internal.objects.*} package
* are different per Context and loaded separately by each Context class loader. Attempting
* to directly refer to an object in this package from the rest of the runtime
* will lead to {@code ClassNotFoundException} thrown upon link time
* Runtime interface to the global scope objects.
*/
public
interface
GlobalObject
{
...
...
nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java
浏览文件 @
874a8be8
...
...
@@ -1026,6 +1026,15 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
return
context
;
}
/**
* Set the current context.
* @param ctx context instance to set
*/
protected
final
void
setContext
(
final
Context
ctx
)
{
ctx
.
getClass
();
this
.
context
=
ctx
;
}
/**
* Return the map of an object.
* @return PropertyMap object.
...
...
nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java
浏览文件 @
874a8be8
...
...
@@ -25,30 +25,19 @@
package
jdk.nashorn.internal.runtime
;
import
static
jdk
.
nashorn
.
internal
.
codegen
.
Compiler
.
OBJECTS_PACKAGE
;
import
static
jdk
.
nashorn
.
internal
.
codegen
.
Compiler
.
SCRIPTS_PACKAGE
;
import
static
jdk
.
nashorn
.
internal
.
codegen
.
Compiler
.
binaryName
;
import
static
jdk
.
nashorn
.
internal
.
codegen
.
CompilerConstants
.
JS_OBJECT_PREFIX
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.security.AccessController
;
import
java.security.CodeSigner
;
import
java.security.CodeSource
;
import
java.security.PrivilegedActionException
;
import
java.security.PrivilegedExceptionAction
;
import
java.security.ProtectionDomain
;
import
jdk.nashorn.internal.codegen.ObjectClassGenerator
;
/**
* Responsible for on the fly construction of structure classes as well
* as loading jdk.nashorn.internal.objects.* classes.
* Responsible for on the fly construction of structure classes.
*
*/
final
class
StructureLoader
extends
NashornLoader
{
private
static
final
String
JS_OBJECT_PREFIX_EXTERNAL
=
binaryName
(
SCRIPTS_PACKAGE
)
+
'.'
+
JS_OBJECT_PREFIX
.
symbolName
();
private
static
final
String
OBJECTS_PACKAGE_EXTERNAL
=
binaryName
(
OBJECTS_PACKAGE
);
/**
* Constructor.
...
...
@@ -68,45 +57,9 @@ final class StructureLoader extends NashornLoader {
return
loadedClass
;
}
if
(
name
.
startsWith
(
binaryName
(
OBJECTS_PACKAGE_EXTERNAL
)))
{
try
{
return
AccessController
.
doPrivileged
(
new
PrivilegedExceptionAction
<
Class
<?>>()
{
@Override
public
Class
<?>
run
()
throws
ClassNotFoundException
{
final
String
source
=
name
.
replace
(
'.'
,
'/'
)
+
".clazz"
;
final
URL
url
=
getResource
(
source
);
try
(
final
InputStream
is
=
getResourceAsStream
(
source
))
{
if
(
is
==
null
)
{
throw
new
ClassNotFoundException
(
name
);
}
byte
[]
code
;
try
{
code
=
Source
.
readBytes
(
is
);
}
catch
(
final
IOException
e
)
{
Context
.
printStackTrace
(
e
);
throw
new
ClassNotFoundException
(
name
,
e
);
}
final
Class
<?>
cl
=
defineClass
(
name
,
code
,
0
,
code
.
length
,
new
CodeSource
(
url
,
(
CodeSigner
[])
null
));
if
(
resolve
)
{
resolveClass
(
cl
);
}
return
cl
;
}
catch
(
final
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
});
}
catch
(
final
PrivilegedActionException
e
)
{
throw
new
ClassNotFoundException
(
name
,
e
);
}
}
return
super
.
loadClassTrusted
(
name
,
resolve
);
}
@Override
protected
Class
<?>
findClass
(
final
String
name
)
throws
ClassNotFoundException
{
if
(
name
.
startsWith
(
JS_OBJECT_PREFIX_EXTERNAL
))
{
...
...
nashorn/src/jdk/nashorn/internal/scripts/JO.java
浏览文件 @
874a8be8
...
...
@@ -36,10 +36,11 @@ public class JO extends ScriptObject {
private
static
final
PropertyMap
map
$
=
PropertyMap
.
newMap
(
JO
.
class
);
/**
* Constructor
* Returns the initial property map to be used.
* @return the initial property map.
*/
public
JO
()
{
super
(
map
$
)
;
public
static
PropertyMap
getInitialMap
()
{
return
map
$
;
}
/**
...
...
@@ -52,16 +53,17 @@ public class JO extends ScriptObject {
}
/**
* Constructor given an initial prototype
using the default property map
* Constructor given an initial prototype
and an initial property map.
*
* @param proto the prototype object
* @param map the property map
*/
public
JO
(
final
ScriptObject
proto
)
{
super
(
proto
,
map
$
);
public
JO
(
final
ScriptObject
proto
,
final
PropertyMap
map
)
{
super
(
proto
,
map
);
}
/**
*
Used by FunctionObjectCreator.
A method handle of this method is passed to the ScriptFunction constructor.
* A method handle of this method is passed to the ScriptFunction constructor.
*
* @param map the property map to use for allocatorMap
*
...
...
nashorn/src/jdk/nashorn/tools/Shell.java
浏览文件 @
874a8be8
...
...
@@ -47,6 +47,7 @@ import jdk.nashorn.internal.ir.debug.PrintVisitor;
import
jdk.nashorn.internal.parser.Parser
;
import
jdk.nashorn.internal.runtime.Context
;
import
jdk.nashorn.internal.runtime.ErrorManager
;
import
jdk.nashorn.internal.runtime.JSType
;
import
jdk.nashorn.internal.runtime.Property
;
import
jdk.nashorn.internal.runtime.ScriptEnvironment
;
import
jdk.nashorn.internal.runtime.ScriptFunction
;
...
...
@@ -446,7 +447,7 @@ public class Shell {
}
if
(
res
!=
null
&&
res
!=
ScriptRuntime
.
UNDEFINED
)
{
err
.
println
(
ScriptRuntime
.
safeT
oString
(
res
));
err
.
println
(
JSType
.
t
oString
(
res
));
}
}
}
finally
{
...
...
nashorn/test/script/basic/JDK-8019947.js
0 → 100644
浏览文件 @
874a8be8
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* JDK-8019947: inherited property invalidation does not work with two globals in same context
*
* @test
* @option -scripting
* @run
*/
function
func
(
arr
)
{
try
{
print
(
arr
.
toString
());
}
catch
(
e
)
{
print
(
e
.
stack
);
}
}
var
arr
=
[
"
hello
"
,
"
world
"
]
func
(
arr
);
var
global
=
loadWithNewGlobal
({
name
:
"
t
"
,
script
:
<<
EOF
function
func
(
arr
)
{
try
{
print
(
arr
.
toString
());
}
catch
(
e
)
{
print
(
e
.
stack
);
}
}
var
arr
=
[
1
,
2
,
3
];
func
(
arr
);
delete
Array
.
prototype
.
toString
;
// Object.prototype.toString should be visible
// after Array.prototype.toString is deleted.
func
(
arr
);
this
;
EOF
});
nashorn/test/script/basic/JDK-8019947.js.EXPECTED
0 → 100644
浏览文件 @
874a8be8
hello,world
1,2,3
[object Array]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录