session.jvm is a JVMSessionProxy — available on every NSPSession attached to a Java application. It provides direct, runtime-level access to the JVM through JVMTI and JNI: read static and instance fields, invoke methods, and enumerate loaded classes — all without modifying the target application or adding any Java code.
When to Use session.jvm
The high-level state on session.state reflects the semantic model that the NSP JVM probe has already extracted. session.jvm lets you reach below that model to read raw Java fields and call arbitrary methods that are not yet surfaced in the semantic layer.
- Start with
session.get_int(...),session.get_str(...), etc. for values already in the semantic state. - Use
session.jvmwhen you need internal Java fields, collection contents, or method return values not present in the semantic model.
JVM probe attachment via JVMTI takes longer on first connect than CLR or v8 probes — typically 2–15 seconds. If you call
session.jvm methods immediately after client.attach(), you may receive NSPActionError with code jvm_not_attached. Wait for session.confidence >= 0.85 or use client.attach("AppName", fresh=True) to ensure the probe is ready before issuing JVM calls.Prerequisites
read_field(class_name, field_name, *, timeout_ms)
Read the value of a static or instance field from a loaded Java class.
The fully-qualified Java class name, e.g.
"com.ardupilot.GCS". Use dots as separators (not slashes).Field name, case-sensitive, exactly as declared in the Java source.
Maximum time in milliseconds to wait for the JVMTI agent to respond.
read_field():
invoke(class_name, method_name, args, *, timeout_ms)
Invoke a Java method by name and return its result. Arguments are automatically coerced to the JVM types expected by the method’s signature.
Fully-qualified Java class name.
Method name, case-sensitive.
Positional arguments. Each value is coerced to the JVM type expected by the method signature.
Maximum time to wait for the method to return.
Type Coercion Reference
list_classes(*, prefix, timeout_ms)
Enumerate all classes currently loaded in the JVM, optionally filtered to a package prefix.
Return only classes whose fully-qualified name starts with this prefix.
Maximum time to wait for the class enumeration.
