0.1.0 • Published 5 years ago
jdwp v0.1.0
jdwp
Java Debug Wire Protocol
Install
$ npm i jdwp --save
Usage
launch the java project and connect to jvm
const { launcher } = require('jdwp')
const vm = await launcher.launch({
mainClass: 'Test',
vmArgs: [ '-Dfile.encoding=UTF-8', '-Xdebug', '-Xnoagent', '-Djava.compiler=NONE' ],
classPaths: [ __dirname ],
});
vm.on('event', async ({ events }) => {
console.log(events);
});
await vm.ready();
await vm.resume();
run the example demo
$ node example/index.js
Begin debug Test.java
-----------------------
1 public class Test {
2 public int plus(int a, int b) {
3 int c = a + b;
4 return c;
5 }
6
7 public static void main(String[] args) {
8 Test test = new Test();
9 int c = test.plus(1, 2);
10 System.out.println(c);
11 System.out.println("Hello world");
12 }
13 }
14
-----------------------
suspend at breakpoint line:10
get local variable c = 3
set local variable c = 4
4
step => Test main() line:11 Test/Test.java
Hello world
step => Test main() line:12 Test/Test.java
step => java.lang.Thread exit() line:757 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:758 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:759 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:762 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:764 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:765 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:766 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:767 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:768 java/lang/Thread/Thread.java
step => java.lang.Thread exit() line:769 java/lang/Thread/Thread.java
Protocol
https://docs.oracle.com/javase/7/docs/platform/jpda/jdwp/jdwp-protocol.html
- VirtualMachine Command Set (1)
- Version (1)
- ClassesBySignature (2)
- AllClasses (3)
- AllThreads (4)
- TopLevelThreadGroups (5)
- Dispose (6)
- IDSizes (7)
- Suspend (8)
- Resume (9)
- Exit (10)
- CreateString (11)
- Capabilities (12)
- ClassPaths (13)
- DisposeObjects (14)
- HoldEvents (15)
- ReleaseEvents (16)
- CapabilitiesNew (17)
- RedefineClasses (18)
- SetDefaultStratum (19)
- AllClassesWithGeneric (20)
- InstanceCounts (21)
- ReferenceType Command Set (2)
- Signature (1)
- ClassLoader (2)
- Modifiers (3)
- Fields (4)
- Methods (5)
- GetValues (6)
- SourceFile (7)
- NestedTypes (8)
- Status (9)
- Interfaces (10)
- ClassObject (11)
- SourceDebugExtension (12)
- SignatureWithGeneric (13)
- FieldsWithGeneric (14)
- MethodsWithGeneric (15)
- Instances (16)
- ClassFileVersion (17)
- ConstantPool (18)
- ClassType Command Set (3)
- Superclass (1)
- SetValues (2)
- InvokeMethod (3)
- NewInstance (4)
- ArrayType Command Set (4)
- NewInstance (1)
- InterfaceType Command Set (5)
- Method Command Set (6)
- LineTable (1)
- VariableTable (2)
- Bytecodes (3)
- IsObsolete (4)
- VariableTableWithGeneric (5)
- Field Command Set (8)
- ObjectReference Command Set (9)
- ReferenceType (1)
- GetValues (2)
- SetValues (3)
- MonitorInfo (5)
- InvokeMethod (6)
- DisableCollection (7)
- EnableCollection (8)
- IsCollected (9)
- ReferringObjects (10)
- StringReference Command Set (10)
- Value (1)
- ThreadReference Command Set (11)
- Name (1)
- Suspend (2)
- Resume (3)
- Status (4)
- ThreadGroup (5)
- Frames (6)
- FrameCount (7)
- OwnedMonitors (8)
- CurrentContendedMonitor (9)
- Stop (10)
- Interrupt (11)
- SuspendCount (12)
- OwnedMonitorsStackDepthInfo (13)
- ForceEarlyReturn (14)
- ThreadGroupReference Command Set (12)
- Name (1)
- Parent (2)
- Children (3)
- ArrayReference Command Set (13)
- Length (1)
- GetValues (2)
- SetValues (3)
- ClassLoaderReference Command Set (14)
- VisibleClasses (1)
- EventRequest Command Set (15)
- Set (1)
- Clear (2)
- ClearAllBreakpoints (3)
- StackFrame Command Set (16)
- GetValues (1)
- SetValues (2)
- ThisObject (3)
- PopFrames (4)
- ClassObjectReference Command Set (17)
- ReflectedType (1)
- Event Command Set (64)
- Composite (100)