Merge
This commit is contained in:
commit
972758ee0f
@ -282,6 +282,11 @@ grant codeBase "file:/${basedir}/test/script/trusted/*" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
grant codeBase "file:/${basedir}/test/script/maptests/*" {
|
||||
permission java.io.FilePermission "${basedir}/test/script/maptests/*","read";
|
||||
permission java.lang.RuntimePermission "nashorn.debugMode";
|
||||
};
|
||||
|
||||
grant codeBase "file:/${basedir}/test/script/basic/*" {
|
||||
permission java.io.FilePermission "${basedir}/test/script/-", "read";
|
||||
permission java.io.FilePermission "$${user.dir}", "read";
|
||||
|
@ -115,6 +115,7 @@ run.classpath=\
|
||||
test.dir=test
|
||||
test.script.dir=test/script
|
||||
test.basic.dir=test/script/basic
|
||||
test.maptests.dir=test/script/maptests
|
||||
test.error.dir=test/script/error
|
||||
test.sandbox.dir=test/script/sandbox
|
||||
test.trusted.dir=test/script/trusted
|
||||
@ -125,7 +126,7 @@ testjfx.dir=${test.script.dir}/jfx
|
||||
testmarkdown.dir=${test.script.dir}/markdown
|
||||
|
||||
test-sys-prop.test.dir=${test.dir}
|
||||
test-sys-prop.test.js.roots=${test.basic.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir}
|
||||
test-sys-prop.test.js.roots=${test.basic.dir} ${test.maptests.dir} ${test.error.dir} ${test.sandbox.dir} ${test.trusted.dir}
|
||||
test-sys-prop.test262.suite.dir=${test262.suite.dir}
|
||||
test-sys-prop.es5conform.testcases.dir=${test.external.dir}/ES5Conform/TestCases
|
||||
test-sys-prop.test.basic.dir=${test.basic.dir}
|
||||
@ -278,7 +279,7 @@ run.test.jvmargs.octane.main=${run.test.jvmargs.common}
|
||||
run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
|
||||
|
||||
# VM options for script tests with @fork option
|
||||
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}
|
||||
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath}
|
||||
|
||||
# path of rhino.jar for benchmarks
|
||||
rhino.jar=
|
||||
|
@ -956,7 +956,7 @@ public final class Context {
|
||||
|
||||
final URL url = source.getURL();
|
||||
final ScriptLoader loader = env._loader_per_compile ? createNewLoader() : scriptLoader;
|
||||
final CodeSource cs = url == null ? null : new CodeSource(url, (CodeSigner[])null);
|
||||
final CodeSource cs = new CodeSource(url, (CodeSigner[])null);
|
||||
final CodeInstaller<ScriptEnvironment> installer = new ContextCodeInstaller(this, loader, cs);
|
||||
|
||||
final Compiler compiler = new Compiler(installer, strict);
|
||||
|
@ -70,9 +70,8 @@ final class ScriptLoader extends NashornLoader {
|
||||
* @return Installed class.
|
||||
*/
|
||||
synchronized Class<?> installClass(final String name, final byte[] data, final CodeSource cs) {
|
||||
if (cs == null) {
|
||||
return defineClass(name, data, 0, data.length, new ProtectionDomain(null, getPermissions(null)));
|
||||
}
|
||||
// null check
|
||||
cs.getClass();
|
||||
return defineClass(name, data, 0, data.length, cs);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 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
|
||||
@ -28,5 +28,5 @@
|
||||
* @run
|
||||
*/
|
||||
|
||||
print(new java.awt.Color(1, 1, 1)) // creates Color[r=1,g=1,b=1]
|
||||
print(new java.awt.Color(1.0, 1.0, 1.0)) // Color[r=255,g=255,b=255]
|
||||
print(Java.type("jdk.nashorn.test.models.IntFloatOverloadSelection").overloadedMethod(1))
|
||||
print(Java.type("jdk.nashorn.test.models.IntFloatOverloadSelection").overloadedMethod(1.0))
|
||||
|
@ -1,2 +1,2 @@
|
||||
java.awt.Color[r=1,g=1,b=1]
|
||||
java.awt.Color[r=255,g=255,b=255]
|
||||
int
|
||||
float
|
||||
|
48
nashorn/test/script/currently-failing/gettersetter.js
Normal file
48
nashorn/test/script/currently-failing/gettersetter.js
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
function Foo() {
|
||||
return {
|
||||
get foo() { return 42; },
|
||||
set foo(x) {}
|
||||
}
|
||||
}
|
||||
|
||||
var obj1 = Foo();
|
||||
var obj2 = Foo();
|
||||
|
||||
assertSameMap(obj1, obj2, "Object literals before change");
|
||||
|
||||
Object.defineProperty(obj2, "foo", { get: function() { return 'hello' } });
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
Object.defineProperty(obj2, "foo", { set: function(x) { print(x) } });
|
||||
assertSameMap(obj1, obj2);
|
58
nashorn/test/script/maptests/builtins.js
Normal file
58
nashorn/test/script/maptests/builtins.js
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
// check that builtin objects share property map
|
||||
|
||||
assertSameMap(new Boolean(true), new Boolean(false));
|
||||
assertSameMap(new Number(3), new Number(Math.PI));
|
||||
assertSameMap(new String('hello'), new String('world'));
|
||||
assertSameMap(new Object(), new Object());
|
||||
assertSameMap(/hello/, /world/);
|
||||
// try w/without regexp flags
|
||||
assertSameMap(/hello/i, /world/g);
|
||||
assertSameMap(new Date(), new Date());
|
||||
assertSameMap(new Date(2000, 1, 1), new Date(1972, 5, 6));
|
||||
assertSameMap(Function(), Function());
|
||||
assertSameMap(Function("x", "return x"), Function("x", "return x*x"));
|
||||
assertSameMap(new Error(), new Error());
|
||||
assertSameMap(new Error('foo'), new Error('bar'));
|
||||
assertSameMap(new EvalError(), new EvalError());
|
||||
assertSameMap(new EvalError('foo'), new EvalError('bar'));
|
||||
assertSameMap(new RangeError(), new RangeError());
|
||||
assertSameMap(new RangeError('foo'), new RangeError('bar'));
|
||||
assertSameMap(new ReferenceError(), new ReferenceError());
|
||||
assertSameMap(new ReferenceError('foo'), new ReferenceError('bar'));
|
||||
assertSameMap(new SyntaxError(), new SyntaxError());
|
||||
assertSameMap(new SyntaxError('foo'), new SyntaxError('bar'));
|
||||
assertSameMap(new TypeError(), new TypeError());
|
||||
assertSameMap(new TypeError('foo'), new TypeError('bar'));
|
||||
assertSameMap(new URIError(), new URIError());
|
||||
assertSameMap(new URIError('foo'), new URIError('bar'));
|
36
nashorn/test/script/maptests/constructor.js
Normal file
36
nashorn/test/script/maptests/constructor.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "point.js");
|
||||
|
||||
// use constructor defined in a different script file
|
||||
// These objects should share the map
|
||||
assertSameMap(new Point(2, 3), new Point(43, 23));
|
||||
assertSameMap(new Point(), new Point());
|
||||
assertSameMap(new Point(), new Point(3, 1));
|
38
nashorn/test/script/maptests/maputil.js
Normal file
38
nashorn/test/script/maptests/maputil.js
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @subtest
|
||||
*/
|
||||
|
||||
function assertSameMap(obj1, obj2, msg) {
|
||||
if (! Debug.identical(Debug.map(obj1), Debug.map(obj2))) {
|
||||
fail(obj1.constructor + " instances don't share map");
|
||||
}
|
||||
}
|
||||
|
||||
function assertNotSameMap(obj1, obj2, msg) {
|
||||
if (Debug.identical(Debug.map(obj1), Debug.map(obj2))) {
|
||||
fail(obj1.constructor + " and " + obj2.constructor + " instances share map");
|
||||
}
|
||||
}
|
40
nashorn/test/script/maptests/object_create.js
Normal file
40
nashorn/test/script/maptests/object_create.js
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
// Objects created by Object.create
|
||||
var obj1 = Object.create(Object.prototype);
|
||||
var obj2 = Object.create(Object.prototype);
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
var proto = { foo: 233 };
|
||||
obj1 = Object.create(proto);
|
||||
obj2 = Object.create(proto);
|
||||
assertSameMap(obj1, obj2);
|
46
nashorn/test/script/maptests/object_literals.js
Normal file
46
nashorn/test/script/maptests/object_literals.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
// Object literals created at the same callsite
|
||||
function makeObject() {
|
||||
return { foo: 34 }
|
||||
}
|
||||
assertSameMap(makeObject(), makeObject());
|
||||
|
||||
function makeObject2() {
|
||||
return { foo: 42, bar: 'hello' }
|
||||
}
|
||||
assertSameMap(makeObject2(), makeObject2());
|
||||
|
||||
// Object literals created at different callsites
|
||||
assertSameMap({}, {});
|
||||
assertSameMap({foo: 4}, {foo: 'hello'});
|
||||
assertSameMap({foo: 34, bar: 'fdgd'}, {foo: 'world', bar: 54});
|
49
nashorn/test/script/maptests/point.js
Normal file
49
nashorn/test/script/maptests/point.js
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @subtest
|
||||
*/
|
||||
|
||||
function Point(x, y) {
|
||||
this.x =x; this.y =y;
|
||||
}
|
||||
|
||||
Point.prototype.toString = function() {
|
||||
return "(" + this.x + "," + this.y + ")";
|
||||
}
|
||||
|
||||
Point.prototype.modulus = function() {
|
||||
return Math.sqrt(this.x*this.x + this.y*this.y);
|
||||
}
|
||||
|
||||
Point.prototype.argument = function() {
|
||||
return Math.atan2(this.y, this.x);
|
||||
}
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
assertSameMap(new Point(2, 3), new Point(43, 23));
|
||||
assertSameMap(new Point(), new Point());
|
||||
assertSameMap(new Point(), new Point(3, 1));
|
46
nashorn/test/script/maptests/property_add.js
Normal file
46
nashorn/test/script/maptests/property_add.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
function Foo() {}
|
||||
|
||||
var obj1 = new Foo();
|
||||
var obj2 = new Foo();
|
||||
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
// property addition at same callsite
|
||||
function addX(obj, val) {
|
||||
obj.x = val;
|
||||
}
|
||||
addX(obj1, 3);
|
||||
addX(obj2, 'hello');
|
||||
|
||||
assertSameMap(obj1, obj2);
|
48
nashorn/test/script/maptests/property_delete.js
Normal file
48
nashorn/test/script/maptests/property_delete.js
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
function Foo() {
|
||||
this.x = 33;
|
||||
}
|
||||
|
||||
var obj1 = new Foo();
|
||||
var obj2 = new Foo();
|
||||
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
// property deletion at same callsite
|
||||
function deleteX(obj) {
|
||||
delete obj.x;
|
||||
}
|
||||
deleteX(obj1);
|
||||
deleteX(obj2);
|
||||
|
||||
assertSameMap(obj1, obj2);
|
56
nashorn/test/script/maptests/proto.js
Normal file
56
nashorn/test/script/maptests/proto.js
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @option -Dnashorn.debug=true
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + "maputil.js");
|
||||
|
||||
// add/delete property to proto (direct/indirect) should
|
||||
// not affect the property map of the objects
|
||||
|
||||
var proto2 = { foo: 334 }
|
||||
var proto = Object.create(proto2);
|
||||
proto.bar = "hello";
|
||||
|
||||
var obj1 = Object.create(proto);
|
||||
var obj2 = Object.create(proto);
|
||||
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
proto.newX = 'world';
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
delete proto.newX;
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
proto2.newX = "foo";
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
delete proto2.newX;
|
||||
assertSameMap(obj1, obj2);
|
||||
|
||||
|
65
nashorn/test/script/sandbox/safeprops.js
Normal file
65
nashorn/test/script/sandbox/safeprops.js
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Try to access System properties safe to read for any code.
|
||||
* No security exception expected.
|
||||
*
|
||||
* @test
|
||||
* @security
|
||||
* @run
|
||||
* @bug 8033924: Default permissions are not given for eval code
|
||||
*/
|
||||
|
||||
var propNames = [
|
||||
"java.version",
|
||||
"java.vendor",
|
||||
"java.vendor.url",
|
||||
"java.class.version",
|
||||
"os.name",
|
||||
"os.version",
|
||||
"os.arch",
|
||||
"file.separator",
|
||||
"path.separator",
|
||||
"line.separator",
|
||||
"java.specification.version",
|
||||
"java.specification.vendor",
|
||||
"java.specification.name",
|
||||
"java.vm.specification.version",
|
||||
"java.vm.specification.vendor",
|
||||
"java.vm.specification.name",
|
||||
"java.vm.version",
|
||||
"java.vm.vendor",
|
||||
"java.vm.name"
|
||||
];
|
||||
|
||||
// no security exception expected
|
||||
for (var p in propNames) {
|
||||
java.lang.System.getProperty(propNames[p]);
|
||||
}
|
||||
|
||||
// no security exception expected
|
||||
for (var p in propNames) {
|
||||
var name = propNames[p];
|
||||
eval('java.lang.System.getProperty(name)');
|
||||
}
|
@ -560,6 +560,47 @@ public class ScriptEngineTest {
|
||||
assertTrue(reached[0]);
|
||||
}
|
||||
|
||||
// properties that can be read by any code
|
||||
private static String[] propNames = {
|
||||
"java.version",
|
||||
"java.vendor",
|
||||
"java.vendor.url",
|
||||
"java.class.version",
|
||||
"os.name",
|
||||
"os.version",
|
||||
"os.arch",
|
||||
"file.separator",
|
||||
"path.separator",
|
||||
"line.separator",
|
||||
"java.specification.version",
|
||||
"java.specification.vendor",
|
||||
"java.specification.name",
|
||||
"java.vm.specification.version",
|
||||
"java.vm.specification.vendor",
|
||||
"java.vm.specification.name",
|
||||
"java.vm.version",
|
||||
"java.vm.vendor",
|
||||
"java.vm.name"
|
||||
};
|
||||
|
||||
// @bug 8033924: Default permissions are not given for eval code
|
||||
@Test
|
||||
public void checkPropertyReadPermissions() throws ScriptException {
|
||||
final ScriptEngineManager m = new ScriptEngineManager();
|
||||
final ScriptEngine e = m.getEngineByName("nashorn");
|
||||
|
||||
for (final String name : propNames) {
|
||||
checkProperty(e, name);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkProperty(final ScriptEngine e, final String name)
|
||||
throws ScriptException {
|
||||
String value = System.getProperty(name);
|
||||
e.put("name", name);
|
||||
assertEquals(value, e.eval("java.lang.System.getProperty(name)"));
|
||||
}
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
// Returns String that would be the result of calling PrintWriter.println
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package jdk.nashorn.test.models;
|
||||
|
||||
public class IntFloatOverloadSelection {
|
||||
|
||||
public static String overloadedMethod(int i) {
|
||||
return "int";
|
||||
}
|
||||
|
||||
public static String overloadedMethod(float f) {
|
||||
return "float";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user