Skip to content

Commit

Permalink
8283339: TypeError: undefined is not an Object after JDK-8240299
Browse files Browse the repository at this point in the history
Reviewed-by: attila
  • Loading branch information
cushon authored and szegedi committed Apr 1, 2022
1 parent 1ced089 commit ba9bc19
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static Object getPrototypeOf(final Object self, final Object obj) {
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object setPrototypeOf(final Object self, final Object obj, final Object proto) {
Global.checkObjectCoercible(self);
Global.checkObjectCoercible(obj);

if (obj instanceof ScriptObject) {
((ScriptObject)obj).setPrototypeOf(proto);
Expand Down
36 changes: 36 additions & 0 deletions test/nashorn/script/basic/JDK-8283339.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2022, Google LLC. 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-8283339: Object.setPrototypeOf() should allow static invocation.
*
* @test
* @run
*/

var foo = function(){
var f = Object.setPrototypeOf;
var a = f("test", {});
print(a);
};
foo();
1 change: 1 addition & 0 deletions test/nashorn/script/basic/JDK-8283339.js.EXPECTED
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test

0 comments on commit ba9bc19

Please sign in to comment.