debuggersupportapi.js revision 970:f82b83cf73ae
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 */ 23 24/** 25 * JDK-8044798: API for debugging Nashorn 26 * 27 * @test 28 * @run 29 */ 30 31// Basic API class, method, field existence checks. 32 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. 39 40var Arrays = Java.type("java.util.Arrays"); 41var DebuggerSupport = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport"); 42 43print(DebuggerSupport.class); 44print(); 45var methods = DebuggerSupport.class.declaredMethods; 46Arrays.sort(methods, function(m1, m2) m1.name.compareTo(m2.name)); 47for 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} 63print(); 64 65var DebuggerValueDesc = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.DebuggerValueDesc"); 66print(DebuggerValueDesc.class); 67print(); 68var fields = DebuggerValueDesc.class.declaredFields; 69Arrays.sort(fields, function(f1, f2) f1.name.compareTo(f2.name)); 70for 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} 79print(); 80 81var SourceInfo = Java.type("jdk.nashorn.internal.runtime.DebuggerSupport.SourceInfo"); 82print(SourceInfo.class); 83print(); 84var fields = SourceInfo.class.declaredFields; 85Arrays.sort(fields, function(f1, f2) f1.name.compareTo(f2.name)); 86for 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} 95