Tue, 14 Oct 2014 16:16:12 +0530
8050977: Java8 Javascript Nashorn exception: no current Global instance for nashorn
Reviewed-by: attila, lagergren, hannesw
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /**
25 * JDK-8044798: API for debugging Nashorn
26 *
27 * @test
28 * @run
29 */
31 // Basic API class, method, field existence checks.
33 // The following classes and the associated methods and fields are used as
34 // private debugger interface. Though private/implementation defined, nashorn
35 // code should not be changed to remove these classes, fields and methods.
36 // The test takes signatures of debugger interface and stores in .EXPECTED file.
37 // If any incompatible change is made to nashorn to break any of these, this
38 // test will fail.
40 var Arrays = Java.type("java.util.Arrays");
41 var DebuggerSupport = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport");
43 print(DebuggerSupport.class);
44 print();
45 var methods = DebuggerSupport.class.declaredMethods;
46 Arrays.sort(methods, function(m1, m2) m1.name.compareTo(m2.name));
47 for each (var mth in methods) {
48 switch (mth.name) {
49 case "eval":
50 case "notifyInvoke":
51 case "getSourceInfo":
52 case "valueAsString":
53 case "valueInfos":
54 print(mth);
55 break;
56 case "valueInfo":
57 if (mth.parameterCount == 3) {
58 print(mth);
59 }
60 break;
61 }
62 }
63 print();
65 var DebuggerValueDesc = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.DebuggerValueDesc");
66 print(DebuggerValueDesc.class);
67 print();
68 var fields = DebuggerValueDesc.class.declaredFields;
69 Arrays.sort(fields, function(f1, f2) f1.name.compareTo(f2.name));
70 for each (var fld in fields) {
71 switch (fld.name) {
72 case "key":
73 case "expandable":
74 case "valueAsObject":
75 case "valueAsString":
76 print(fld);
77 }
78 }
79 print();
81 var SourceInfo = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.SourceInfo");
82 print(SourceInfo.class);
83 print();
84 var fields = SourceInfo.class.declaredFields;
85 Arrays.sort(fields, function(f1, f2) f1.name.compareTo(f2.name));
86 for each (var fld in fields) {
87 switch (fld.name) {
88 case "name":
89 case "hash":
90 case "url":
91 case "content":
92 print(fld);
93 }
94 }