aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsundar <none@none>2014-05-26 15:48:25 +0530
committersundar <none@none>2014-05-26 15:48:25 +0530
commit42fbdf6d39a1d894351322a72fcd175d578214fc (patch)
treeea20483ba722c8a4650ef6fc59e05ca3835edb8a /test
parent6a0591d04e739d5e220432b43d1445bf1023dcf4 (diff)
downloadnashorn-42fbdf6d39a1d894351322a72fcd175d578214fc.tar.gz
8043930: TypeError when attemping to create an instance of non-public class could be better
Reviewed-by: attila, lagergren
Diffstat (limited to 'test')
-rw-r--r--test/script/basic/JDK-8043930.js37
-rw-r--r--test/script/basic/JDK-8043930.js.EXPECTED1
2 files changed, 38 insertions, 0 deletions
diff --git a/test/script/basic/JDK-8043930.js b/test/script/basic/JDK-8043930.js
new file mode 100644
index 00000000..a89b3541
--- /dev/null
+++ b/test/script/basic/JDK-8043930.js
@@ -0,0 +1,37 @@
+/*
+ * 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-8043930: TypeError when attemping to create an instance of non-public class could be better
+ *
+ * @test
+ * @run
+ */
+
+var NonPublicClass = Java.type("jdk.nashorn.test.models.NonPublicClass");
+try {
+ var obj = new NonPublicClass();
+ fail("Expected TypeError to be thrown!");
+} catch (e) {
+ print(e);
+}
diff --git a/test/script/basic/JDK-8043930.js.EXPECTED b/test/script/basic/JDK-8043930.js.EXPECTED
new file mode 100644
index 00000000..ee5cf9dc
--- /dev/null
+++ b/test/script/basic/JDK-8043930.js.EXPECTED
@@ -0,0 +1 @@
+TypeError: new cannot be used with non-public java type jdk.nashorn.test.models.NonPublicClass.