Search code examples
javajvmjvm-hotspot

Get VMVersionMismatchException when using jmap command


my jdk version is 1.8.0_111 and I'm reading a book on JVM. When I tried the command jmap -F 6469, an exception is thrown as below:

Attaching to process ID 6469, please wait...
Error attaching to process: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM is 25.152-b11
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM is 25.152-b11
    at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:435)
    at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305)
    at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:140)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:185)
    at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
    at sun.jvm.hotspot.tools.PMap.main(PMap.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.tools.jmap.JMap.runTool(JMap.java:201)
    at sun.tools.jmap.JMap.main(JMap.java:130)
Caused by: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM is 25.152-b11
    at sun.jvm.hotspot.runtime.VM.checkVMVersion(VM.java:227)
    at sun.jvm.hotspot.runtime.VM.<init>(VM.java:294)
    at sun.jvm.hotspot.runtime.VM.initialize(VM.java:370)
    at sun.jvm.hotspot.HotSpotAgent.setupVM(HotSpotAgent.java:431)
    ... 11 more

It seems there is something wrong with my jvm version, but I can't find out why. I'm new to JVM, and I'd be grateful if someone could tell me why and how to deal with it.


Solution

  • The target process (6469) runs under different version of JRE (1.8.0_152).

    When running jmap or jstack in forced mode (-F), JDK version of the tool must be exactly the same as JDK of the target process.

    See this answer for details.