Skip to content

Go + JVMTI = ❤ | Hook into JVM using JVMTI interface with logic written in Go

Notifications You must be signed in to change notification settings

jakon89/golang-jmvti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go + JVMTI = ❤

This tool provides binding between JVMTI and Golang. The idea is simple: instead of writing C or C++ code we could utilize higher-level language like Go to interact with JVMTI interface.

How it works

  • Main class simulates long running JVM process that we want to hook into
  • CGO is used to compile Go program to be shared library accepted by JVM.

Unfortunately, CGO does not support function pointers which are used heavily in JVM + JVM TI. To overcome this I use simple proxy which exposes functions that CGO calls in order to communicate with JVMTI protocol.

  • Compiled shared library is attached to the JVM process during startup using -agentpath:agent-go.so=dummy-option parameter. Please refer to Makefile to get better understanding of what is happening.

This POC is intended to show just a few basic things:

  • how to read arguments passed to the agent and how to call JVMTI method from Go. The mumbo-jumbo related to CGO types are left to the reader - good luck.
  • how to build CGO program to be shared library available for JVM

About

Go + JVMTI = ❤ | Hook into JVM using JVMTI interface with logic written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published