JavaScript interface to Hotspot Serviceability Agent
-
-
-Serviceability Agent (SA) provides Java API and tools to diagnose HotSpot Virtual Machine and
-Java apps running on it. SA is a snapshot debugger -- can be used to observe state of a frozen java process or java core dump.
-
-
-
Existing SA APIs
-
-There are two application programmer interfaces (APIs) for SA:
-
-
1. Private java API
-
-
-This tries to mimic hotspot VM's internal C++ classes and methods. Because VM data structures
-are a moving target, this API can never be 'stable'! Besides, to use SA's private API knowledge of
-HotSpot code base is essential.
-
-
2. SA-JDI -- Java Debugger Interface read-only subset API
-
-
-This is read-only subset of JDI (Java Debugger Interface)
-This is a standardized interface to get java level state of a java process or java core dump. While this
-interface is useful, this misses parts of java level state from target process or core such as
-
-
heap walking interface -- only objects traceable to static variables (of classes) and local
-variables of stack frames can be accessed.
-
re-constructing .class from debuggee are missing.
-
re-constructing object mirrors for Java objects of the debuggee.
-
-
-
-
-
-
SA Scripting interface
-
-
-Traditionally, platform debuggers such as dbx, gdb and Solaris mdb (Module Debugger), provide a scripting
-language interface. Scripting language interface provides easy-to-use, dynamically typed
-interface to access data structures from debuggee. dbx and mdb even allow user to write
-C/C++ modules to extend the scripting language commands.
-
-
-
-SA provides SOQL - Simple Object Query Language -- a SQL-like query language to access
-Java heap as an object database. SA's main GUI (HSDB) also exposes scripting interface of underlying debugger such as dbx, windbg.
-But to use this interface, user has to learn scripting interface of multiple debugger back-ends such as dbx, windbg.
-And these scripting interfaces are 'raw' in the sense that no java state is exposed -- only C/C++ state of VM is exposed.
-Higher level SA services are not available through scripting interface.
-
-
-
-jsdb -- JavaScript Debugger attempts to provide JavaScript interface to SA.
-jsdb provides
-
-
-
-jsdb is a command line JavaScript shell based on
-Mozilla's Rhino JavaScript Engine.
-This command line utility attaches to Java process or core file or remote debug server and waits for user input.
-This shell supports the following global functions and objects in addition to the standard JavaScript functions and
-objects:
-
-
jdsb globals
-
-
-
-
Function/Variable
-
Description
-
-
-
-address(jobject)
-
-
-function that returns the address of the Java object as a string
-
-
-
-classof(jobject)
-
-
-function that returns the JavaScript object that represents class object of the Java object
-
-
-
-dumpClass(jclass,[dir])
-
-
-function that writes .class for the given Java Class. Optionally (second arg) accepts the directory where the
-.class has to be written.
-
-
-
-help()
-
-
-function that prints help message for global functions and objects
-
-
-
-
-identityHash(jobject)
-
-
-function that returns the identity hashCode of the Java object
-
-
-
-
-mirror(jobject)
-
-
-function that returns a local mirror of the Java object.
-
-
-
-
-load([file1, file2,...])
-
-
-function that loads zero or more JavaScript file(s). With no arguments, reads for
-JavaScript code.
-
-
-
-
-object(string)
-
-
-function that converts a string address into Java object
-
-
-
-
-owner(jobject)
-
-
-function that returns the owner thread of this monitor or null
-
-
-
-
-sizeof(jobject)
-
-
-function that returns the size of Java object in bytes
-
-
-
-
-staticof(jclass, field)
-
-
-function that returns the value of given field of the given Java class
-
-
-
-
-print(expr1, expr2,...)
-
-
-function that prints zero or more JavaScript expressions after converting those as strings
-
-
-
-
-println(expr1, expr2..)
-
-
-function that same as print, but prints a newline at the end
-
-
-
-
-read([prompt])
-
-
-function that reads a single line from standard input
-
-
-
-
-quit()
-
-
-function that quits the interactive load call as well as the shell
-
-
-
-
-jvm
-
-
-variable -- a JavaScript object that represents the target jvm that is being debugged
-
-
-
-
-
jvm object
-
-
-jvm object supports the following read-only properties.
-
-
-
-
-
-Property name
-
-
-Description
-
-
-
-
-threads
-
-
-array of Java threads from the debuggee
-
-
-
-
-heap
-
-
-object representing the heap of the debuggee
-
-
-
-
-type
-
-
-string value that is either "Server" or "Client" or "Core" -- the flavour of debuggee VM
-
-
-
-
-bootClassPath
-
-
-string value of bootclasspath of the debuggee
-
-
-
-
-cpu
-
-
-string value of cpu on which the debuggee runs/ran
-
-
-
-
-sysProps
-
-
-name-value pairs (JavaScript associative array) of Java System properties of the debuggee
-
-
-
-
-addressSize
-
-
-int value -- 32 for 32 bit debuggee, 64 for 64 bit debuggee
-
-
-
-
-os
-
-
-string value of OS on which the debuggee runs/ran
-
-
-
-
-buildInfo
-
-
-internal build info string from debuggee
-
-
-
-
-flags
-
-
-name-value pairs (JavaScript associative array) of JVM command line flags of the debuggee
-
-
-
-
-classPath
-
-
-string value of classpath of the debuggee
-
-
-
-
-userDir
-
-
-string value of user.dir System property of the debuggee
-
-
-
-
-
heap object
-
-
-heap object represents Java heap of the debuggee VM
-
-
-
-
-Function or property name
-
-
-Description
-
-
-
-
-capacity
-
-
-byte size of capacity of the heap
-
-
-
-
-used
-
-
-byte size of used portion (of live objects) of the heap
-
-This function accepts a callback function 'func' and optionally class name and boolean arguments.
-This function calls the callback for each Java object in the debuggee's heap. The optional class
-argument may be used to receive objects of given class only. The third arguments specifies whether
-to include objects of subtype of given class [or interface] or not. The default value of class is "java.lang.Object"
-and and that of the third argument is true. i.e., by default all objects are included.
-
-This function accepts a callback function 'func'. This function iterates through the classes of the debuggee and calls the
-callback for each class. The second parameter tells whether to pass initiating loader to the iterator callback or not.
-
-
-
-
-
Accessing Java objects and arrays in script
-
-
-From a given Java object, we can access all fields of the Java object by usual '.' operator. i.e., if you got a Java object
-called 'o' of type java.lang.Thread from debuggee, you can access 'stackSize' field by o.stackSize syntax. Similarly, length of Java array
-objects can be accessed by length property. And array indexing follows usual syntax. i.e., n'th element of array 'a' is
-accessed by a[n].
-
-
-
jvm.threads array
-
-
-This is a JavaScript array of Java threads of the debuggee. As usual, 'length' property tells the number of threads and individual
-threads may be accessed by index operator -- i.e, jvm.threads[0] returns the first thread.
-
-
-
thread object
-
-
-
-In addition to the fields of java.lang.Thread (or subclass) fields, thread objects have two additional properties.
-
-
-
frames -- array of stack frame objects
-
monitors -- array of monitor objects owned by the thread
-
-
-
-
-
stack frame object
-
-
-
-
-Property name
-
-
-Description
-
-
-
-thisObject
-
-
-Object representing 'this' of the current frame [will be null for static methods]
-
-
-
-
-locals
-
-
-name-value pairs of local variables [JavaScript associative array]
-
-
-
-
-line
-
-
-Java source line number at which the frame is executing
-
-
-
-
-bci
-
-
-byte code index of the bytecode that the frame is executing
-
-
-
-
-thread
-
-
-thread to which this frame belongs
-
-
-
-
-method
-
-
-Java method that the frame is executing
-
-
-
-
-
method object
-
-
-method object represents a Java method of debuggee
-
-
-
-
-
-Property name
-
-
-Description
-
-
-
-
-isStatic
-
-
-boolean - true for static methods and false for non-static methods
-
-
-
-
-
-isSynchronized
-
-
-boolean - true for synchronized methods and false for non-synchronized methods
-
-
-
-
-
-isNative
-
-
-boolean - true for native methods and false for non-native methods
-
-
-
-
-
-isProtected
-
-
-boolean - true for protected methods and false for non-protected methods
-
-
-
-
-
-isPrivate
-
-
-boolean - true for private methods and false for non-private methods
-
-
-
-
-
-isSynthetic
-
-
-boolean - true for Javac generated synthetic methods and false for non-synthetic methods
-
-
-
-
-
-isPackagePrivate
-
-
-boolean - true for package-private methods and false for non-package-private methods
-
-
-
-
-
-isPublic
-
-
-boolean - true for public methods and false for non-public methods
-
-
-
-
-
-holder
-
-
-an object that represents Class that contains this method
-
-
-
-
-
-signature
-
-
-string -- signature of this method
-
-
-
-
-
-isObsolete
-
-
-boolean - true for obsolete (hotswapped) methods and false for non-obsolete methods
-
-
-
-
-
-isStrict
-
-
-boolean - true for strictfp methods and false for non-strictfp methods
-
-
-
-
-
-isFinal
-
-
-boolean - true for final methods and false for non-final methods
-
-
-
-
-
-name
-
-
-string - name of this method
-
-
-
-
-
class object
-
-
-A class object represents loaded Java class in debuggee VM. This represents java.lang.Class instance in the debuggee.
-This is type of return value of classof global function. Also, method.holder property and field.holder are
-of this type.
-
-
-
-
-
-Property name
-
-
-Description
-
-
-
-
-
-name
-
-
-name of this class
-
-
-
-
-
-superClass
-
-
-class object representing super class of this class
-
-
-
-
-
-isArrayClass
-
-
-boolean -- is the current class an array class?
-
-
-
-
-
-isStatic
-
-
-boolean -- is the current class static or not
-
-
-
-
-
-isInterface
-
-
-boolean -- is the current class an interface
-
-
-
-
-
-isAbstract
-
-
-boolean -- is the current class abstract or not
-
-
-
-
-
-isProtected
-
-
-boolean -- is the current class protected or not
-
-
-
-
-
-isPrivate
-
-
-boolean -- is the current class private or not
-
-
-
-
-
-isPackagePrivate
-
-
-boolean -- is the current class package private or not
-
-
-
-
-
-isSynthetic
-
-
-boolean -- is the current class synthetic or not
-
-
-
-
-
-classLoader
-
-
-object that represents ClassLoader object that loaded the current class
-
-
-
-
-
-
-fields
-
-
-array of static and instance fields of the current class
-
-
-
-
-
-protectionDomain
-
-
-protection domain to which current class belongs
-
-
-
-
-
-isPublic
-
-
-boolean -- is the current class public or not
-
-
-
-
-
-signers
-
-
-array of signers for current class
-
-
-
-
-
-sourceFile
-
-
-string -- name of the source file for current class
-
-
-
-
-
-interfaces
-
-
-array -- interfaces implemented by current class
-
-
-
-
-
-isStrict
-
-
-boolean -- is the current class strictfp or not
-
-
-
-
-
-methods
-
-
-array of methods (static and instance) of the current class
-
-
-
-
-
-
-isFinal
-
-
-boolean -- is the current class final or not
-
-
-
-
-
-statics
-
-
-name-value pairs (JavaScript associate array) of static fields of the current class
-
-
-
-
-
field object
-
-field represents a static or instance field of some class in debuggee
-
-
-
-
-
-Property name
-
-
-Description
-
-
-
-
-
-isStatic
-
-
-boolean -- is this field a static field?
-
-
-
-
-
-holder
-
-
-class that owns this field
-
-
-
-
-
-signature
-
-
-string signature of this field
-
-
-
-
-
-isProtected
-
-
-boolean - is this field a protected field or not?
-
-
-
-
-
-isPrivate
-
-
-boolean - is this field a private field or not?
-
-
-
-
-
-isSynthetic
-
-
-boolean - is this javac generated synthetic field or not?
-
-
-
-
-
-isPackagePrivate
-
-
-boolean - is this field a package private field or not?
-
-
-
-
-
-isTransient
-
-
-boolean - is this field a transient field or not?
-
-
-
-
-
-isFinal
-
-
-boolean - is this field final or not?
-
-
-
-
-
-name
-
-
-string - name of this field
-
-
-
-
-
-isPublic
-
-
-boolean - is this field public or not?
-
-
-
-
-
Initialization Script
-
-jsdb engine looks for initialization script file named jsdb.js in user's home directory. If found, it loads just after attaching to debuggee but before printing prompt for user's input. User can assume that s/he can access debuggee VM
-state during initialization script.
-
-
-
Sample scripts
-
-Semantics and knowledge of application classes (for eg. AppServer's classes) would be needed to create app specific
-scripts. The following script samples are app-independent and provide a flavour of kind of scripts that can be written.
-
-
Script to print system properties of JVM
-
-
-
-jvm.sysProps.toString()
-
-
-
-
Script to print JVM command line flags
-
-
-jvm.flags.toString()
-
-
-
-
-
Script to print class-wise histogram of objects
-
-
-
-
-// associate array to hold histogram
-var histo;
-function func(obj) {
- var classname = classof(obj).name;
- if (histo[classname] == undefined) {
- // first time we are visiting this class type
- histo[classname] = 1;
- } else {
- histo[classname]++;
- }
-}
-
-// iterate through java heap calling 'func' for each object
-jvm.heap.forEachObject(func);
-
-// print the histogram
-for (i in histo) {
- println('number of instances of ', i, ' = ', histo[i]);
-}
-
-
-
-
-
Script to print stack trace of all Java threads
-
-
-
-
-function printStackTrace(t) {
- println(t.name);
- println('');
- for (i in t.frames) {
- println(t.frames[i]);
- }
- println('');
-}
-
-// walk through the list of threads and call printStackTrace
-// for each thread
-for (o in jvm.threads) {
- printStackTrace(jvm.threads[o]);
-}
-
-
-
-
-
-
-
Script to re-construct .class files for all non-bootstrap classes
-
-
-
-
-function dump(cl) {
- if (!cl.isArrayClass && cl.classLoader != null) {
- // not an array class and a non-bootstrap class
- // create .class files in e:\tmp dir
- dumpClass(cl, "e:\\tmp);
- } else {
- println("skipping bootstrap class ", cl.name);
- }
-}
-
-// walk thru heap and call callback for each java.lang.Class instance
-jvm.heap.forEachObject(dump, "java.lang.Class");
-
-
-
-
Script to print paths of all java.io.File's currently accessed
-
-
-
-
-function printFile(f) {
- // construct a mirror java.io.File here and
- // print absolute path here
- println(mirror(f).getAbsolutePath());
-}
-
-jvm.heap.forEachObject(printFile, "java.io.File");
-
-
-
-
-
Script to print static fields of java.lang.Thread class
-
-
-
-var threadClass = classof("java.lang.Thread");
-for (i in threadClass.statics) {
- println(i, '=', threadClass.statics[i]);
-}
-
-
-
-This object provides short names for SA package names. For eg. instead of writing
-Packages.sun.jvm.hotspot.memory, we can write sapkg.memory.
-
-
-
sa object
-
-This object contains all SA singleton objects such as VM, Universe, SymbolTable,
-SystemDictionary, ObjectHeap, CollectedHeap, Debugger, CDebugger (if available),
-Interpreter, TypeDataBase and Threads. For eg. to access SymbolTable of Java debuggee,
-we can use sa.symbolTable. User can execute the following code to get fields of this object.
-
-
-
-for (i in sa) {
- println(i);
-}
-
-
-
-
Heap Iterators
-
-
forEachOop(callback)
-
calls a callback function for each Oop in Java heap
calls a callback function for each Oop of a give Klass type
-Optinally, third argument can specify whether to include subtype Oops
-or not.
-
-
-
-
System Dictionary Access
-
-
forEachKlass(callback)
-
calls a callback function for each Klass in Java heap
-
forEachKlassAndLoader(callback)
-
-calls callback with Klass and initiating loader (Oop) for System dictionary
-entry.
-
-
findInstanceKlass(name)
-
-finds the first instance klass with given name from System dictionary
-
-
-
-
Thread, Frame Iterators
-
-
forEachJavaThread(callback)
-
calls callback for each Java Thread
-
forEachFrame(javaThread, callback)
-
calls callback for each Frame of a given JavaThread
-
forEachVFrame(javaThread, callback)
-
calls callback for each JavaVFrame of a given JavaThread
-
forEachThread(callback)
-
calls callback for each (native) ThreadProxy (obtained by CDebugger.getThreadList)
-
-
forEachCFrame(threadProxy, callback)
-
-calls callback for each CFrame of a given ThreadProxy object
-
-
-
-
Code blobs, Interpreter codelets
-
-
forEachCodeBlob(callback)
-
-calls callback with each code blob in code cache
-
-
findCodeBlob(address)
-
-finds the code blob, if any, that contains the given address.
-Returns null, on failure.
-
-
findNMethod(address)
-
-finds the NMethod that contains given address.
-
-
pcDescAt(addr)
-
-returns PCDesc at given address or null.
-
-
forEachInterpCodelet(callbacl)
-
-calls callback with each Interpreter codelet
-
-
-
-
VM structs, constants
-
-
forEachType(callback)
-
-calls callback for each Type in VM's type database
-
-
forEachVMIntConst(callback)
-
-calls callback for each named integer constant. passes name
-as argument.
-
-
forEachVMLongConst(callback)
-
-calls callback for each named long constant. passes name
-as argument.
-
-
findVMType(name)
-
-finds a VM type by name. returns null if no known Type of given name
-exists in type database.
-
-
findVMIntConst(name)
-
-finds an integer constant in type data base by name.
-
-
findVMLongConst(name)
-
-finds an long constant in type data base by name.
-
-
vmTypeof(addr)
-
-returns VM type of object at 'addr' if any. Else, returns null.
-
-
isOfVMType(addr, type)
-
-returns whether object at 'addr' is of VM type 'type' or not.
-
-
printVMType(type, addr)
-
-prints 'addr' as VM object of type 'type'
-
-
printXXX(addr)
-
-For each VM type, these functions are defined. For eg. there is printUniverse,
-printSystemDictionary etc. are available. Without 'addr' being passed static fields are printed. With 'addr' param being passed, instance fields are printed.
-
-
-
-
Low level debugger facilities
-
-
num2addr(number)
-
-converts a (long) number to SA Address instance
-
-
str2addr(string)
-
-converts a given hex string to SA Address instance
-
-
any2addr(any)
-
-Takes a number or a string or an Address and returns
-an Address instance. For other types, returns 'undefined'
-
-
addr2str(addr)
-
-converts a given Address instance to a hex string
-
-
addr2num(addr)
-
-converts a given Address instance to a (long) number
-
-
sym2addr(library, symbol)
-
-returns Address of a given symbol in a given library (shared object or DLL)
-Example: sym2addr('jvm.dll', 'JNI_CreateJavaVM')
-
addr2sym(addr)
-
-Returns nearest symbol to a given address (if any). If no such symbol is found,
-returns the given address as a string.
-
-
readBytesAt(addr, num)
-
-returns 'num' bytes at 'addr' as a Java byte[]
-
-
readWordsAt(addr, num)
-
-returns 'num' words at 'addr' as a Java long[]
-
-
readCStrAt(addr)
-
-returns 'C' String at given address
-
-
readCStrLen(addr)
-
-returns the length of the 'C' String at given address
-
-
readRegs(threadProxy)
-
-returns register set (of Thread Context) of a given thread specified
-by threadProxy. return value is an associate array having name-value pairs
-of registers.
-
-
regs(threadProxy)
-
-prints register set of a given thread.
-
-
mem(addr, [num])
-
-prints 'num' words (address size) at 'addr'. Prints nearest symbol for address, if found.
-
-
dis(addr, [num])
-
prints native code disassembly of 'num' bytes at given address 'addr'.
-Default value of 'num' is 4. This automatically detects whether the given address
-inside a nmethod. If so, it prints safepoint info, entry points , method signature etc.
-of the nmethod.
-
-
jdis(method [or addr])
-
-prints Java bytecode disassembly for given method Oop or address of a method Oop.
-
-
nmethoddis(nmethod)
-
-prints disassembly of given nmethod object. Note that you don't have to call this directly
-instead use 'dis'.
-
-
where
-
-prints Java stack trace for all Java threads
-
-
-
-
Miscellaneous
-
-
addr2oop(addr)
-
-converts a given address to a Oop object
-
-
oop2addr(oop)
-
-returns address of a given Oop object
-
-
isOfVMType(addr, type)
-
-returns whether the given 'addr' points to a (C++) VM object of specified
-type. type may be specified by SA Type object or string name of the type.
-
-
newVMObject(addr)
-
-returns instance of SA object for a given address (similar to SA VirtualConstructor
-interface).
-
-
vmobj2addr(vmobject)
-
-returns Address represented by a given SA VMObject
-
-
addr2vmobj(addr)
-
same as newVMObject(addr)
-
whatis(addr)
-
-returns string description of given address (using SA FindPointer and guess type API).
-
isOop(addr)
-
-returns whether a given address is a valid Oop address or not
-
-
-
-
Moving b/w jsdb low level and high level interfaces
-
-
-Java objects of debuggee are represented by different script wrappers in high level
-interface. In the low-level interface these are instances of SA Oop class or its'
-subclass. To move b/w low-level and high-level interfaces the following functions may
-be used
-
-
-
oop2obj(oop)
-
-converts a given Oop object to a high-level wrapper object
-
-
obj2oop(obj)
-
-converts a jsdb high level wrapper to underlying Oop instance
-
-
-
-
JavaScript tips
-
-
-
to know properties, functions of any object, use the script
-
-
-for(i in object) { println(i); }
-
-
-
to view the source code of any function, just type the name of
-function in jsdb prompt
-
to view global functions, properties, run
-
-
-for(i in this) { println(i); }
-
-
-
-
-
-
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java
index b9d09609549..4fe7a7f10a7 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java
@@ -104,9 +104,6 @@ import sun.jvm.hotspot.utilities.ReversePtrs;
import sun.jvm.hotspot.utilities.ReversePtrsAnalysis;
import sun.jvm.hotspot.utilities.RobustOopDeterminator;
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
-import sun.jvm.hotspot.utilities.soql.JSJavaFactory;
-import sun.jvm.hotspot.utilities.soql.JSJavaFactoryImpl;
-import sun.jvm.hotspot.utilities.soql.JSJavaScriptEngine;
public class CommandProcessor {
@@ -1846,7 +1843,6 @@ public class CommandProcessor {
private DebuggerInterface debugger;
private HotSpotAgent agent;
- private JSJavaScriptEngine jsengine;
private BufferedReader in;
private PrintStream out;
private PrintStream err;
@@ -1858,65 +1854,7 @@ public class CommandProcessor {
// called after debuggee attach
private void postAttach() {
- /*
- * JavaScript engine no longer works. For now disable it. Eventually we will remove it.
- // create JavaScript engine and start it
- try {
- jsengine = new JSJavaScriptEngine() {
- private ObjectReader reader = new ObjectReader();
- private JSJavaFactory factory = new JSJavaFactoryImpl();
- public ObjectReader getObjectReader() {
- return reader;
- }
- public JSJavaFactory getJSJavaFactory() {
- return factory;
- }
- protected void quit() {
- debugger.detach();
- quit = true;
- }
- protected BufferedReader getInputReader() {
- return in;
- }
- protected PrintStream getOutputStream() {
- return out;
- }
- protected PrintStream getErrorStream() {
- return err;
- }
- };
- try {
- jsengine.defineFunction(this,
- this.getClass().getMethod("registerCommand",
- new Class[] {
- String.class, String.class, String.class
- }));
- } catch (NoSuchMethodException exp) {
- // should not happen, see below...!!
- exp.printStackTrace();
- }
- jsengine.start();
- }
- catch (Exception ex) {
- System.out.println("Warning! JS Engine can't start, some commands will not be available.");
- if (verboseExceptions) {
- ex.printStackTrace(out);
- }
- }
- */
- }
-
- public void registerCommand(String cmd, String usage, final String func) {
- commands.put(cmd, new Command(cmd, usage, false) {
- public void doit(Tokens t) {
- final int len = t.countTokens();
- Object[] args = new Object[len];
- for (int i = 0; i < len; i++) {
- args[i] = t.nextToken();
- }
- jsengine.call(func, args);
- }
- });
+ // nothing for now..
}
public void setOutput(PrintStream o) {
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
index 694b5b210bd..9531511de0a 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java
@@ -276,15 +276,6 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
item.setMnemonic(KeyEvent.VK_D);
toolsMenu.add(item);
- item = createMenuItem("Find Object by Query",
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- showFindByQueryPanel();
- }
- });
- item.setMnemonic(KeyEvent.VK_Q);
- toolsMenu.add(item);
-
item = createMenuItem("Find Pointer",
new ActionListener() {
@@ -1531,10 +1522,6 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
showPanel("Command Line", new CommandProcessorPanel(new CommandProcessor(di, null, null, null)));
}
- private void showFindByQueryPanel() {
- showPanel("Find Object by Query", new FindByQueryPanel());
- }
-
private void showFindPanel() {
showPanel("Find Pointer", new FindPanel());
}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java
deleted file mode 100644
index bd7e4c4ce45..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- *
- */
-
-package sun.jvm.hotspot.tools.soql;
-
-import sun.jvm.hotspot.debugger.JVMDebugger;
-import sun.jvm.hotspot.tools.*;
-import sun.jvm.hotspot.utilities.*;
-import sun.jvm.hotspot.utilities.soql.*;
-
-/** This is command line JavaScript debugger console */
-public class JSDB extends Tool {
-
- public JSDB() {
- super();
- }
-
- public JSDB(JVMDebugger d) {
- super(d);
- }
-
- public static void main(String[] args) {
- JSDB jsdb = new JSDB();
- jsdb.execute(args);
- }
-
- public void run() {
- JSJavaScriptEngine engine = new JSJavaScriptEngine() {
- private ObjectReader objReader = new ObjectReader();
- private JSJavaFactory factory = new JSJavaFactoryImpl();
-
- public ObjectReader getObjectReader() {
- return objReader;
- }
-
- public JSJavaFactory getJSJavaFactory() {
- return factory;
- }
- };
- engine.startConsole();
- }
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java
deleted file mode 100644
index eceabd39a98..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- *
- */
-
-package sun.jvm.hotspot.tools.soql;
-
-import java.io.*;
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.tools.*;
-import sun.jvm.hotspot.utilities.*;
-import sun.jvm.hotspot.utilities.soql.*;
-
-/**
- This is command line SOQL (Simple Object Query Language) interpreter.
-*/
-
-public class SOQL extends Tool {
- public static void main(String[] args) {
- SOQL soql = new SOQL();
- soql.execute(args);
- }
-
- public SOQL() {
- super();
- }
-
- public SOQL(JVMDebugger d) {
- super(d);
- }
-
- protected SOQLEngine soqlEngine;
- protected BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- protected PrintStream out = System.out;
- static protected String prompt = "soql> ";
- static protected String secondPrompt = "> ";
-
- public void run() {
- soqlEngine = SOQLEngine.getEngine();
- while (true) {
- try {
- out.print(prompt);
- String line = in.readLine();
- if (line == null) {
- return;
- }
- StringTokenizer st = new StringTokenizer(line);
- if (st.hasMoreTokens()) {
- String cmd = st.nextToken();
- if (cmd.equals("select")) {
- handleSelect(line);
- } else if (cmd.equals("classes")) {
- handleClasses(line);
- } else if (cmd.equals("class")) {
- handleClass(line);
- } else if (cmd.equals("object")) {
- handleObject(line);
- } else if (cmd.equals("quit")) {
- out.println("Bye!");
- return;
- } else if (cmd.equals("")) {
- // do nothing ...
- } else {
- handleUnknown(line);
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
- }
- }
-
- protected void handleSelect(String query) {
- StringBuffer buf = new StringBuffer(query);
- String tmp = null;
- while (true) {
- out.print(secondPrompt);
- try {
- tmp = in.readLine();
- } catch (IOException ioe) {
- break;
- }
- if (tmp.equals("") || tmp.equals("go"))
- break;
- buf.append('\n');
- buf.append(tmp);
- }
- query = buf.toString();
-
- try {
- soqlEngine.executeQuery(query,
- new ObjectVisitor() {
- public void visit(Object o) {
- if (o != null && o instanceof JSJavaObject) {
- String oopAddr = ((JSJavaObject)o).getOop().getHandle().toString();
- out.println(oopAddr);
- } else {
- out.println((o == null)? "null" : o.toString());
- }
- }
- });
- } catch (SOQLException se) {
- se.printStackTrace();
- }
- }
-
- protected void handleClasses(String line) {
- // just list all InstanceKlasses
- InstanceKlass[] klasses = SystemDictionaryHelper.getAllInstanceKlasses();
- for (int i = 0; i < klasses.length; i++) {
- out.print(klasses[i].getName().asString().replace('/', '.'));
- out.print(" @");
- out.println(klasses[i].getAddress());
- }
- }
-
- protected void handleClass(String line) {
- StringTokenizer st = new StringTokenizer(line);
- st.nextToken(); // ignore "class"
- if (st.hasMoreTokens()) {
- String className = st.nextToken();
- InstanceKlass klass = SystemDictionaryHelper.findInstanceKlass(className);
- if (klass == null) {
- out.println("class " + className + " not found");
- } else {
- // klass.iterate(new OopPrinter(out), true);
-
- // base class
- InstanceKlass base = (InstanceKlass) klass.getSuper();
- if (base != null) {
- out.println("super");
- out.print("\t");
- out.println(base.getName().asString().replace('/', '.'));
- }
-
- // list immediate fields only
- U2Array fields = klass.getFields();
- int numFields = (int) fields.length();
- ConstantPool cp = klass.getConstants();
- out.println("fields");
- if (numFields != 0) {
- for (int f = 0; f < numFields; f++){
- Symbol f_name = klass.getFieldName(f);
- Symbol f_sig = klass.getFieldSignature(f);
- StringBuffer sigBuf = new StringBuffer();
- new SignatureConverter(f_sig, sigBuf).dispatchField();
- out.print('\t');
- out.print(sigBuf.toString().replace('/', '.'));
- out.print(' ');
- out.println(f_name.asString());
- }
- } else {
- out.println("\tno fields in this class");
- }
- }
- } else {
- out.println("usage: class ");
- }
- }
-
- protected Oop getOopAtAddress(Address addr) {
- OopHandle oopHandle = addr.addOffsetToAsOopHandle(0);
- return VM.getVM().getObjectHeap().newOop(oopHandle);
- }
-
- protected void handleObject(String line) {
- StringTokenizer st = new StringTokenizer(line);
- st.nextToken(); // ignore "object"
- if (st.hasMoreTokens()) {
- String addrStr = st.nextToken();
- Address addr = null;
- Debugger dbg = VM.getVM().getDebugger();
- try {
- addr = dbg.parseAddress(addrStr);
- } catch (Exception e) {
- out.println("invalid address : " + e.getMessage());
- return;
- }
-
- Oop oop = null;
- try {
- oop = getOopAtAddress(addr);
- } catch (Exception e) {
- out.println("invalid object : " + e.getMessage());
- }
-
- if (oop != null) {
- oop.iterate(new OopPrinter(out), true);
- } else {
- out.println("null object!");
- }
- } else {
- out.println("usage: object ");
- }
- }
-
- protected void handleUnknown(String line) {
- out.println("Unknown command!");
- }
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindByQueryPanel.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindByQueryPanel.java
deleted file mode 100644
index 13c77ee3afd..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/FindByQueryPanel.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- *
- */
-
-package sun.jvm.hotspot.ui;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-import javax.swing.*;
-import javax.swing.event.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.ui.tree.*;
-import sun.jvm.hotspot.utilities.soql.*;
-
-public class FindByQueryPanel extends SAPanel {
- private JTextArea queryEditor;
- private JEditorPane objectsEditor;
- private SOQLEngine queryEngine;
-
- public FindByQueryPanel() {
- queryEngine = SOQLEngine.getEngine();
- HyperlinkListener hyperListener = new HyperlinkListener() {
- public void hyperlinkUpdate(HyperlinkEvent e) {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- VM vm = VM.getVM();
- OopHandle handle = vm.getDebugger().parseAddress(e.getDescription()).addOffsetToAsOopHandle(0);
- showInspector(vm.getObjectHeap().newOop(handle));
- }
- }
- };
-
- objectsEditor = new JEditorPane();
- objectsEditor.setContentType("text/html");
- objectsEditor.setEditable(false);
- objectsEditor.addHyperlinkListener(hyperListener);
-
- queryEditor = new JTextArea();
- JButton queryButton = new JButton("Execute");
- queryButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- final StringBuffer buf = new StringBuffer();
- buf.append("");
- try {
- queryEngine.executeQuery(queryEditor.getText(),
- new ObjectVisitor() {
- public void visit(Object o) {
- if (o != null && o instanceof JSJavaObject) {
- String oopAddr = ((JSJavaObject)o).getOop().getHandle().toString();
- buf.append("");
- buf.append(oopAddr);
- buf.append("");
- } else {
- buf.append((o == null)? "null" : o.toString());
- }
- buf.append(" ");
- }
- });
-
- } catch (Exception e) {
- e.printStackTrace();
- buf.append("");
- buf.append(e.getMessage());
- buf.append("");
- }
- buf.append("");
- objectsEditor.setText(buf.toString());
- }
- });
-
- JPanel topPanel = new JPanel();
- topPanel.setLayout(new BorderLayout());
- topPanel.add(new JLabel("SOQL Query :"), BorderLayout.WEST);
- topPanel.add(new JScrollPane(queryEditor), BorderLayout.CENTER);
- topPanel.add(queryButton, BorderLayout.EAST);
-
- JPanel bottomPanel = new JPanel();
- bottomPanel.setLayout(new BorderLayout());
- bottomPanel.add(new JScrollPane(objectsEditor), BorderLayout.CENTER);
-
- JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
- splitPane.setDividerLocation(0.3);
-
- setLayout(new BorderLayout());
- add(splitPane, BorderLayout.CENTER);
- }
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/Callable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/Callable.java
deleted file mode 100644
index 5a6931e0db8..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/Callable.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2007, 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.
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import javax.script.ScriptException;
-
-/**
- * This interface is used to represent "function" valued
- * properties in ScriptObjects.
- */
-public interface Callable {
- /**
- * Call the underlying function passing the given
- * arguments and return the result.
- */
- public Object call(Object[] args) throws ScriptException;
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/DefaultScriptObject.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/DefaultScriptObject.java
deleted file mode 100644
index d4215d621bc..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/DefaultScriptObject.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2007, 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.
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import java.util.*;
-
-/**
- * Dummy implementation for ScriptObject interface. This class
- * supports empty set of named and indexed properties. Returns
- * false always for "has" calls. And ignores "delete" and "put"
- * calls.
- */
-public class DefaultScriptObject implements ScriptObject {
- public Object[] getIds() {
- return EMPTY_ARRAY;
- }
-
- public Object get(String name) {
- return UNDEFINED;
- }
-
- public Object get(int index) {
- return UNDEFINED;
- }
-
- public void put(String name, Object value) {
- }
-
- public void put(int index, Object value) {
- }
-
- public boolean has(String name) {
- return false;
- }
-
- public boolean has(int index) {
- return false;
- }
-
- public boolean delete(String name) {
- return false;
- }
-
- public boolean delete(int index) {
- return false;
- }
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/InvocableCallable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/InvocableCallable.java
deleted file mode 100644
index a47212f57cd..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/InvocableCallable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2007, 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.
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import javax.script.Invocable;
-import javax.script.ScriptException;
-
-/**
- * This Callable implementation invokes a script
- * function of given name when called. If the target
- * object is non-null, script "method" is invoked, else
- * a "global" script function is invoked.
- */
-public class InvocableCallable implements Callable {
- private Object target;
- private String name;
- private Invocable invocable;
-
- public InvocableCallable(Object target, String name,
- Invocable invocable) {
- this.target = target;
- this.name = name;
- this.invocable = invocable;
- }
-
- public Object call(Object[] args) throws ScriptException {
- try {
- if (target == null) {
- return invocable.invokeFunction(name, args);
- } else {
- return invocable.invokeMethod(target, name, args);
- }
- } catch (NoSuchMethodException nme) {
- throw new ScriptException(nme);
- }
- }
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaArray.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaArray.java
deleted file mode 100644
index fb077bb34e0..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaArray.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2003, 2020, 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.
- *
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import sun.jvm.hotspot.oops.*;
-
-/**
- This is JavaScript wrapper for Java Array.
-*/
-
-public abstract class JSJavaArray extends JSJavaObject {
- public JSJavaArray(Array array, JSJavaFactory fac) {
- super(array, fac);
- type = (JSJavaArrayKlass) fac.newJSJavaKlass(array.getKlass());
- }
-
- public final Array getArray() {
- return (Array) getOop();
- }
-
- public final JSJavaClass getJSJavaClass() {
- return type.getJSJavaClass();
- }
-
- public Object get(String name) {
- if (name.equals("length")) {
- return (int) getArray().getLength();
- } else {
- return super.get(name);
- }
- }
-
- public Object get(int index) {
- return (isInRange(index)) ? type.getFieldValue(index, getArray())
- : super.get(index);
- }
-
- public Object[] getIds() {
- Object[] superFields = super.getIds();
- final int len = (int) getArray().getLength();
- Object[] res = new Object[superFields.length + len];
- for (int i = 0; i < len; i++) {
- res[i] = i;
- }
- System.arraycopy(superFields, 0, res, len, superFields.length);
- return res;
- }
-
- public boolean has(String name) {
- if (name.equals("length")) {
- return true;
- } else {
- return super.has(name);
- }
- }
-
- public boolean has(int index) {
- if (isInRange(index)) {
- return true;
- } else {
- return super.has(index);
- }
- }
-
- public void put(String name, Object value) {
- if (! name.equals("length")) {
- super.put(name, value);
- }
- }
-
- public void put(int index, Object value) {
- if (! isInRange(index)) {
- super.put(index, value);
- }
- }
-
- //-- Internals only below this point
- private boolean isInRange(int index) {
- return index >= 0 && index < getArray().getLength();
- }
-
- private JSJavaArrayKlass type;
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaArrayKlass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaArrayKlass.java
deleted file mode 100644
index 62aa7a3c6f7..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaArrayKlass.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2003, 2020, 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.
- *
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import java.util.*;
-import sun.jvm.hotspot.oops.*;
-
-/**
- This is JavaScript wrapper for Java ArrayKlass.
-*/
-
-public abstract class JSJavaArrayKlass extends JSJavaKlass {
- public JSJavaArrayKlass(ArrayKlass kls, JSJavaFactory fac) {
- super(kls, fac);
- }
-
- public final ArrayKlass getArrayKlass() {
- return (ArrayKlass) getKlass();
- }
-
- public Object getMetaClassFieldValue(String name) {
- if (name.equals("dimension")) {
- return getArrayKlass().getDimension();
- } else {
- return super.getMetaClassFieldValue(name);
- }
- }
-
- public boolean hasMetaClassField(String name) {
- if (name.equals("dimension")) {
- return true;
- } else {
- return super.hasMetaClassField(name);
- }
- }
-
- public boolean isArray() {
- return true;
- }
-
- public String[] getMetaClassFieldNames() {
- String[] superFields = super.getMetaClassFieldNames();
- String[] res = new String[superFields.length + 1];
- System.arraycopy(superFields, 0, res, 0, superFields.length);
- res[superFields.length] = "dimension";
- return res;
- }
-
- public abstract Object getFieldValue(int index, Array array);
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaClass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaClass.java
deleted file mode 100644
index abe3c2e97e5..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaClass.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- *
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import java.util.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.utilities.*;
-
-public class JSJavaClass extends JSJavaInstance {
- public JSJavaClass(Instance instance, JSJavaKlass jk, JSJavaFactory fac) {
- super(instance, fac);
- this.jklass = jk;
- }
-
- public JSJavaKlass getJSJavaKlass() {
- return jklass;
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("Class (address=");
- buf.append(getOop().getHandle());
- buf.append(", name=");
- buf.append(jklass.getName());
- buf.append(')');
- return buf.toString();
- }
-
- protected Object getFieldValue(String name) {
- return jklass.getMetaClassFieldValue(name);
- }
-
- protected String[] getFieldNames() {
- return jklass.getMetaClassFieldNames();
- }
-
- protected boolean hasField(String name) {
- return jklass.hasMetaClassField(name);
- }
-
- private JSJavaKlass jklass;
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactory.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactory.java
deleted file mode 100644
index 2b08648e6be..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2003, 2012, 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.
- *
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import java.util.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.runtime.*;
-
-public interface JSJavaFactory {
- public JSJavaObject newJSJavaObject(Oop oop);
- public JSJavaKlass newJSJavaKlass(Klass klass);
- public JSJavaField newJSJavaField(Field f);
- public JSJavaThread newJSJavaThread(JavaThread jt);
- public JSJavaFrame newJSJavaFrame(JavaVFrame vf);
- public JSJavaMethod newJSJavaMethod(Method m);
- public JSList newJSList(List l);
- public JSMap newJSMap(Map m);
- public JSJavaHeap newJSJavaHeap();
- public JSJavaVM newJSJavaVM();
- // checks for one of the above special cases
- public Object newJSJavaWrapper(Object o);
-}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java
deleted file mode 100644
index 8615ab4e1c6..00000000000
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFactoryImpl.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 2004, 2020, 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.
- *
- */
-
-package sun.jvm.hotspot.utilities.soql;
-
-import java.lang.ref.*;
-import java.util.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.utilities.*;
-
-public class JSJavaFactoryImpl implements JSJavaFactory {
- public JSJavaObject newJSJavaObject(Oop oop) {
- if (oop == null) return null;
- SoftReference sref = (SoftReference) om.get(oop);
- JSJavaObject res = (sref != null)? (JSJavaObject) sref.get() : null;
- if (res == null) {
- if (oop instanceof TypeArray) {
- res = new JSJavaTypeArray((TypeArray)oop, this);
- } else if (oop instanceof ObjArray) {
- res = new JSJavaObjArray((ObjArray)oop, this);
- } else if (oop instanceof Instance) {
- res = newJavaInstance((Instance) oop);
- }
- }
- if (res != null) {
- om.put(oop, new SoftReference<>(res));
- }
- return res;
- }
-
- public JSJavaKlass newJSJavaKlass(Klass klass) {
- JSJavaKlass res = null;
- if (klass instanceof InstanceKlass) {
- res = new JSJavaInstanceKlass((InstanceKlass) klass, this);
- } else if (klass instanceof ObjArrayKlass) {
- res = new JSJavaObjArrayKlass((ObjArrayKlass) klass, this);
- } else if (klass instanceof TypeArrayKlass) {
- res = new JSJavaTypeArrayKlass((TypeArrayKlass) klass, this);
- }
- if (res != null) {
- om.put(klass, new SoftReference<>(res));
- }
- return res;
- }
-
- public JSJavaMethod newJSJavaMethod(Method method) {
- JSJavaMethod res = new JSJavaMethod(method, this);
- if (res != null) {
- om.put(method, new SoftReference<>(res));
- }
- return res;
- }
-
- public JSJavaField newJSJavaField(Field field) {
- if (field == null) return null;
- return new JSJavaField(field, this);
- }
-
- public JSJavaThread newJSJavaThread(JavaThread jthread) {
- if (jthread == null) return null;
- return new JSJavaThread(jthread, this);
- }
-
- public JSJavaFrame newJSJavaFrame(JavaVFrame jvf) {
- if (jvf == null) return null;
- return new JSJavaFrame(jvf, this);
- }
-
- public JSList newJSList(List list) {
- if (list == null) return null;
- return new JSList(list, this);
- }
-
- public JSMap newJSMap(Map map) {
- if (map == null) return null;
- return new JSMap(map, this);
- }
-
- public Object newJSJavaWrapper(Object item) {
- if (item == null) return null;
- if (item instanceof Oop) {
- return newJSJavaObject((Oop) item);
- } else if (item instanceof Field) {
- return newJSJavaField((Field) item);
- } else if (item instanceof JavaThread) {
- return newJSJavaThread((JavaThread) item);
- } else if (item instanceof JavaVFrame) {
- return newJSJavaFrame((JavaVFrame) item);
- } else if (item instanceof List) {
- return newJSList((List) item);
- } else if (item instanceof Map) {
- return newJSMap((Map) item);
- } else {
- // not-a-special-type, just return the input item
- return item;
- }
- }
-
- public JSJavaHeap newJSJavaHeap() {
- return new JSJavaHeap(this);
- }
-
- public JSJavaVM newJSJavaVM() {
- return new JSJavaVM(this);
- }
-
- // -- Internals only below this point
- private String javaLangString() {
- if (javaLangString == null) {
- javaLangString = "java/lang/String";
- }
- return javaLangString;
- }
-
- private String javaLangThread() {
- if (javaLangThread == null) {
- javaLangThread = "java/lang/Thread";
- }
- return javaLangThread;
- }
-
- private String javaLangClass() {
- if (javaLangClass == null) {
- javaLangClass = "java/lang/Class";
- }
- return javaLangClass;
- }
-
- private JSJavaObject newJavaInstance(Instance instance) {
- // look for well-known classes
- Symbol className = instance.getKlass().getName();
- if (Assert.ASSERTS_ENABLED) {
- Assert.that(className != null, "Null class name");
- }
- JSJavaObject res = null;
- if (className.equals(javaLangString())) {
- res = new JSJavaString(instance, this);
- } else if (className.equals(javaLangThread())) {
- res = new JSJavaThread(instance, this);
- } else if (className.equals(javaLangClass())) {
- Klass reflectedType = java_lang_Class.asKlass(instance);
- if (reflectedType != null) {
- JSJavaKlass jk = newJSJavaKlass(reflectedType);
- // we don't support mirrors of VM internal Klasses
- if (jk == null) return null;
- res = new JSJavaClass(instance, jk, this);
- } else {
- // for primitive Classes, the reflected type is null
- return null;
- }
- } else {
- // not a well-known class. But the base class may be
- // one of the known classes.
- Klass kls = instance.getKlass().getSuper();
- while (kls != null) {
- className = kls.getName();
- // java.lang.Class and java.lang.String are final classes
- if (className.equals(javaLangThread())) {
- res = new JSJavaThread(instance, this);
- break;
- }
- kls = kls.getSuper();
- }
- }
- if (res == null) {
- res = new JSJavaInstance(instance, this);
- }
- return res;
- }
-
- private Map