Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_nashorn
提交
7224aa68
D
dragonwell8_nashorn
项目概览
openanolis
/
dragonwell8_nashorn
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_nashorn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7224aa68
编写于
3月 13, 2014
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015958: DataView constructor is not defined
Reviewed-by: attila, hannesw, lagergren
上级
abc57db2
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
1279 addition
and
2 deletion
+1279
-2
src/jdk/nashorn/internal/objects/Global.java
src/jdk/nashorn/internal/objects/Global.java
+11
-0
src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
+13
-0
src/jdk/nashorn/internal/objects/NativeDataView.java
src/jdk/nashorn/internal/objects/NativeDataView.java
+1015
-0
src/jdk/nashorn/internal/runtime/Context.java
src/jdk/nashorn/internal/runtime/Context.java
+2
-2
src/jdk/nashorn/internal/runtime/resources/Messages.properties
...dk/nashorn/internal/runtime/resources/Messages.properties
+4
-0
test/script/basic/dataview_endian.js
test/script/basic/dataview_endian.js
+70
-0
test/script/basic/dataview_getset.js
test/script/basic/dataview_getset.js
+93
-0
test/script/basic/dataview_new.js
test/script/basic/dataview_new.js
+71
-0
未找到文件。
src/jdk/nashorn/internal/objects/Global.java
浏览文件 @
7224aa68
...
...
@@ -226,6 +226,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@Property
(
name
=
"ArrayBuffer"
,
attributes
=
Attribute
.
NOT_ENUMERABLE
)
public
volatile
Object
arrayBuffer
;
/** DataView object */
@Property
(
name
=
"DataView"
,
attributes
=
Attribute
.
NOT_ENUMERABLE
)
public
volatile
Object
dataView
;
/** TypedArray (int8) */
@Property
(
name
=
"Int8Array"
,
attributes
=
Attribute
.
NOT_ENUMERABLE
)
public
volatile
Object
int8Array
;
...
...
@@ -352,6 +356,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private
ScriptObject
builtinJavaImporter
;
private
ScriptObject
builtinJavaApi
;
private
ScriptObject
builtinArrayBuffer
;
private
ScriptObject
builtinDataView
;
private
ScriptObject
builtinInt8Array
;
private
ScriptObject
builtinUint8Array
;
private
ScriptObject
builtinUint8ClampedArray
;
...
...
@@ -866,6 +871,10 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
return
ScriptFunction
.
getPrototype
(
builtinArrayBuffer
);
}
ScriptObject
getDataViewPrototype
()
{
return
ScriptFunction
.
getPrototype
(
builtinDataView
);
}
ScriptObject
getInt8ArrayPrototype
()
{
return
ScriptFunction
.
getPrototype
(
builtinInt8Array
);
}
...
...
@@ -1634,6 +1643,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
private
void
initTypedArray
()
{
this
.
builtinArrayBuffer
=
initConstructor
(
"ArrayBuffer"
);
this
.
builtinDataView
=
initConstructor
(
"DataView"
);
this
.
builtinInt8Array
=
initConstructor
(
"Int8Array"
);
this
.
builtinUint8Array
=
initConstructor
(
"Uint8Array"
);
this
.
builtinUint8ClampedArray
=
initConstructor
(
"Uint8ClampedArray"
);
...
...
@@ -1674,6 +1684,7 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
this
.
typeError
=
this
.
builtinTypeError
;
this
.
uriError
=
this
.
builtinURIError
;
this
.
arrayBuffer
=
this
.
builtinArrayBuffer
;
this
.
dataView
=
this
.
builtinDataView
;
this
.
int8Array
=
this
.
builtinInt8Array
;
this
.
uint8Array
=
this
.
builtinUint8Array
;
this
.
uint8ClampedArray
=
this
.
builtinUint8ClampedArray
;
...
...
src/jdk/nashorn/internal/objects/NativeArrayBuffer.java
浏览文件 @
7224aa68
...
...
@@ -25,6 +25,7 @@
package
jdk.nashorn.internal.objects
;
import
java.nio.ByteBuffer
;
import
java.util.Arrays
;
import
jdk.nashorn.internal.objects.annotations.Attribute
;
import
jdk.nashorn.internal.objects.annotations.Constructor
;
...
...
@@ -128,4 +129,16 @@ final class NativeArrayBuffer extends ScriptObject {
public
int
getByteLength
()
{
return
buffer
.
length
;
}
ByteBuffer
getBuffer
()
{
return
ByteBuffer
.
wrap
(
buffer
);
}
ByteBuffer
getBuffer
(
final
int
offset
)
{
return
ByteBuffer
.
wrap
(
buffer
,
offset
,
buffer
.
length
-
offset
);
}
ByteBuffer
getBuffer
(
final
int
offset
,
final
int
length
)
{
return
ByteBuffer
.
wrap
(
buffer
,
offset
,
length
);
}
}
src/jdk/nashorn/internal/objects/NativeDataView.java
0 → 100644
浏览文件 @
7224aa68
此差异已折叠。
点击以展开。
src/jdk/nashorn/internal/runtime/Context.java
浏览文件 @
7224aa68
...
...
@@ -649,7 +649,7 @@ public final class Context {
* Checks that the given Class can be accessed from no permissions context.
*
* @param clazz Class object
* @throw SecurityException if not accessible
* @throw
s
SecurityException if not accessible
*/
public
static
void
checkPackageAccess
(
final
Class
<?>
clazz
)
{
final
SecurityManager
sm
=
System
.
getSecurityManager
();
...
...
@@ -666,7 +666,7 @@ public final class Context {
* Checks that the given package name can be accessed from no permissions context.
*
* @param pkgName package name
* @throw SecurityException if not accessible
* @throw
s
SecurityException if not accessible
*/
public
static
void
checkPackageAccess
(
final
String
pkgName
)
{
final
SecurityManager
sm
=
System
.
getSecurityManager
();
...
...
src/jdk/nashorn/internal/runtime/resources/Messages.properties
浏览文件 @
7224aa68
...
...
@@ -79,6 +79,7 @@ type.error.not.a.function={0} is not a function
type.error.not.a.constructor
=
{0} is not a constructor function
type.error.not.a.file
=
{0} is not a File
type.error.not.a.bytebuffer
=
{0} is not a java.nio.ByteBuffer
type.error.not.an.arraybuffer.in.dataview
=
First arg to DataView constructor must be an ArrayBuffer
# operations not permitted on undefined
type.error.cant.call.undefined
=
Cannot call undefined
...
...
@@ -137,6 +138,9 @@ type.error.no.method.matches.args=Can not invoke method {0} with the passed argu
type.error.method.not.constructor
=
Java method {0} can't be used as a constructor.
type.error.env.not.object
=
$ENV must be an Object.
type.error.unsupported.java.to.type
=
Unsupported Java.to target type {0}.
range.error.dataview.constructor.offset
=
Wrong offset or length in DataView constructor
range.error.dataview.offset
=
Offset is outside the bounds of the DataView
range.error.inappropriate.array.length
=
inappropriate array length: {0}
range.error.inappropriate.array.buffer.length
=
inappropriate array buffer length: {0}
range.error.invalid.fraction.digits
=
fractionDigits argument to {0} must be in [0, 20]
...
...
test/script/basic/dataview_endian.js
0 → 100644
浏览文件 @
7224aa68
/*
* Copyright (c) 2014, 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-8015958: DataView constructor is not defined
*
* @test
* @run
*/
// set/get endianess checks
var
buffer
=
new
ArrayBuffer
(
4
);
var
dv
=
new
DataView
(
buffer
);
// write (default) big endian, read big/little endian
dv
.
setUint16
(
0
,
0xABCD
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
),
0xABCD
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
,
false
),
0xABCD
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
,
true
),
0xCDAB
);
// write little endian, read big/little endian
dv
.
setUint16
(
0
,
0xABCD
,
true
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
),
0xCDAB
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
,
false
),
0xCDAB
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
,
true
),
0xABCD
);
// write explicit big endian, read big/little endian
dv
.
setUint16
(
0
,
0xABCD
,
false
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
),
0xABCD
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
,
false
),
0xABCD
);
Assert
.
assertEquals
(
dv
.
getUint16
(
0
,
true
),
0xCDAB
);
// write (default) big endian, read big/little endian
dv
.
setUint32
(
0
,
0xABCDEF89
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
),
0xABCDEF89
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
,
false
),
0xABCDEF89
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
,
true
),
0x89EFCDAB
);
// write little endian, read big/little endian
dv
.
setUint32
(
0
,
0xABCDEF89
,
true
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
),
0x89EFCDAB
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
,
false
),
0x89EFCDAB
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
,
true
),
0xABCDEF89
);
// write explicit big endian, read big/little endian
dv
.
setUint32
(
0
,
0xABCDEF89
,
false
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
),
0xABCDEF89
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
,
false
),
0xABCDEF89
);
Assert
.
assertEquals
(
dv
.
getUint32
(
0
,
true
),
0x89EFCDAB
);
test/script/basic/dataview_getset.js
0 → 100644
浏览文件 @
7224aa68
/*
* Copyright (c) 2014, 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-8015958: DataView constructor is not defined
*
* @test
* @run
*/
// checking get/set of values of various types
// Also basic endianess check.
var
Float
=
Java
.
type
(
"
java.lang.Float
"
);
var
Double
=
Java
.
type
(
"
java.lang.Double
"
);
var
DOUBLE_MIN
=
Double
.
MIN_VALUE
;
var
DOUBLE_MIN_NORMAL
=
Double
.
MIN_NORMAL
;
var
FLOAT_MIN
=
Float
.
MIN_VALUE
;
var
FLOAT_MIN_NORMAL
=
Float
.
MIN_NORMAL
;
var
buffer
=
new
ArrayBuffer
(
12
);
var
dv
=
new
DataView
(
buffer
);
dv
.
setInt8
(
1
,
123
);
Assert
.
assertEquals
(
dv
.
getInt8
(
1
),
123
);
dv
.
setInt8
(
1
,
123
,
true
);
Assert
.
assertEquals
(
dv
.
getInt8
(
1
,
true
),
123
);
dv
.
setUint8
(
1
,
255
);
Assert
.
assertEquals
(
dv
.
getUint8
(
1
),
255
);
dv
.
setUint8
(
1
,
255
,
true
);
Assert
.
assertEquals
(
dv
.
getUint8
(
1
,
true
),
255
);
dv
.
setInt16
(
1
,
1234
);
Assert
.
assertEquals
(
dv
.
getInt16
(
1
),
1234
);
dv
.
setInt16
(
1
,
1234
,
true
);
Assert
.
assertEquals
(
dv
.
getInt16
(
1
,
true
),
1234
);
dv
.
setUint16
(
1
,
65535
);
Assert
.
assertEquals
(
dv
.
getUint16
(
1
),
65535
);
dv
.
setUint16
(
1
,
65535
,
true
);
Assert
.
assertEquals
(
dv
.
getUint16
(
1
,
true
),
65535
);
dv
.
setInt32
(
1
,
1234
);
Assert
.
assertEquals
(
dv
.
getInt32
(
1
),
1234
);
dv
.
setInt32
(
1
,
1234
,
true
);
Assert
.
assertEquals
(
dv
.
getInt32
(
1
,
true
),
1234
);
dv
.
setUint32
(
1
,
4294967295
);
Assert
.
assertEquals
(
dv
.
getUint32
(
1
),
4294967295
);
dv
.
setUint32
(
1
,
4294967295
,
true
);
Assert
.
assertEquals
(
dv
.
getUint32
(
1
,
true
),
4294967295
);
dv
.
setFloat64
(
1
,
Math
.
PI
);
Assert
.
assertEquals
(
dv
.
getFloat64
(
1
),
Math
.
PI
,
DOUBLE_MIN
);
dv
.
setFloat64
(
1
,
Math
.
PI
,
true
);
Assert
.
assertEquals
(
dv
.
getFloat64
(
1
,
true
),
Math
.
PI
,
DOUBLE_MIN
);
dv
.
setFloat64
(
1
,
DOUBLE_MIN_NORMAL
);
Assert
.
assertEquals
(
dv
.
getFloat64
(
1
),
DOUBLE_MIN_NORMAL
,
DOUBLE_MIN
);
dv
.
setFloat64
(
1
,
DOUBLE_MIN_NORMAL
,
true
);
Assert
.
assertEquals
(
dv
.
getFloat64
(
1
,
true
),
DOUBLE_MIN_NORMAL
,
DOUBLE_MIN
);
dv
.
setFloat32
(
1
,
1.414
);
Assert
[
"
assertEquals(float, float, float)
"
](
dv
.
getFloat32
(
1
),
1.414
,
FLOAT_MIN
);
dv
.
setFloat32
(
1
,
1.414
,
true
);
Assert
[
"
assertEquals(float, float, float)
"
](
dv
.
getFloat32
(
1
,
true
),
1.414
,
FLOAT_MIN
);
dv
.
setFloat32
(
1
,
FLOAT_MIN_NORMAL
);
Assert
[
"
assertEquals(float, float, float)
"
](
dv
.
getFloat32
(
1
),
FLOAT_MIN_NORMAL
,
FLOAT_MIN
);
dv
.
setFloat32
(
1
,
FLOAT_MIN_NORMAL
,
true
);
Assert
[
"
assertEquals(float, float, float)
"
](
dv
.
getFloat32
(
1
,
true
),
FLOAT_MIN_NORMAL
,
FLOAT_MIN
);
test/script/basic/dataview_new.js
0 → 100644
浏览文件 @
7224aa68
/*
* Copyright (c) 2014, 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-8015958: DataView constructor is not defined
*
* @test
* @run
*/
// basic DataView constructor checks.
// check ArrayBufferView property values of DataView instance
function
check
(
dv
,
buf
,
offset
,
length
)
{
if
(
dv
.
buffer
!==
buf
)
{
fail
(
"
DataView.buffer is wrong
"
);
}
if
(
dv
.
byteOffset
!=
offset
)
{
fail
(
"
DataView.byteOffset =
"
+
dv
.
byteOffset
+
"
, expected
"
+
offset
);
}
if
(
dv
.
byteLength
!=
length
)
{
fail
(
"
DataView.byteLength =
"
+
dv
.
byteLength
+
"
, expected
"
+
length
);
}
}
var
buffer
=
new
ArrayBuffer
(
12
);
check
(
new
DataView
(
buffer
),
buffer
,
0
,
12
);
check
(
new
DataView
(
buffer
,
2
),
buffer
,
2
,
10
);
check
(
new
DataView
(
buffer
,
4
,
8
),
buffer
,
4
,
8
);
// make sure expected error is thrown
function
checkError
(
callback
,
ErrorType
)
{
try
{
callback
();
fail
(
"
Should have thrown
"
+
ErrorType
.
name
);
}
catch
(
e
)
{
if
(
!
(
e
instanceof
ErrorType
))
{
fail
(
"
Expected
"
+
ErrorType
.
name
+
"
got
"
+
e
);
}
}
}
// non ArrayBuffer as first arg
checkError
(
function
()
{
new
DataView
(
344
)
},
TypeError
);
// illegal offset/length values
checkError
(
function
()
{
new
DataView
(
buffer
,
-
1
)
},
RangeError
);
checkError
(
function
()
{
new
DataView
(
buffer
,
15
)
},
RangeError
);
checkError
(
function
()
{
new
DataView
(
buffer
,
1
,
32
)
},
RangeError
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录