Question

I use to work with Java native agents years ago, and I'm getting back to this. I was wondering....what happened to them?

There were examples in jdk1.6/demo/jvmti directory, but with Java 7, there doesn't seem to be a demo directory. What happened to them?

Anyways, I found the 1.6 demo's (on windows) and I'm trying to compile them on linux and mac using jdk 1.6. There is no sample makefile example for the mac, so that is the one I need the most help with. Is there any way to compile the native agents using jdk 1.6? How about jdk 1.7?

On linux, I somehow got the agents to compile with jdk 1.6, but the ones that depend on the java_crw_demo code doesn't seem to work. I think I may have compiled them wrongly.

The demo's in question are:

  • agent_util
  • gctest
  • heapTracker
  • heapViewer
  • hprof
  • java_crw_demo
  • minst
  • mtrace
  • versionCheck
  • waiters

Anyways, a google search about agents seems to imply that the agents are still being used with jdk 1.7, but there doesn't seem to be the example support that there once was. Is Oracle trying to limit (or sunset) agents?

Thanks.

Was it helpful?

Solution

The JVMTI demos may or may not come bundled with your JDK installation, depending on where you get it from. They are absent (afaict) from OpenJDK installs. But in any case the demos are still available in all cases from the Oracle Download Page. Download the tarball for Mac, expand it to a directory and then browse it.

In relative folder jdk1.7.0_10/demo/jvmti you will find the following demos:

drwxr-xr-x@ 5 tuoyo staff 170 Nov 29 19:30 compiledMethodLoad
drwxr-xr-x@ 5 tuoyo staff 170 Nov 29 19:30 gctest
drwxr-xr-x@ 6 tuoyo staff 204 Nov 29 19:30 heapTracker
drwxr-xr-x@ 5 tuoyo staff 170 Nov 29 19:30 heapViewer
drwxr-xr-x@ 5 tuoyo staff 170 Nov 29 19:30 hprof
drwxr-xr-x@ 6 tuoyo staff 204 Nov 29 19:30 minst
drwxr-xr-x@ 6 tuoyo staff 204 Nov 29 19:30 mtrace
drwxr-xr-x@ 5 tuoyo staff 170 Nov 29 19:30 versionCheck
drwxr-xr-x@ 5 tuoyo staff 170 Nov 29 19:30 waiters

Each individual demo has a source ZIP file with code and a sample makefile. You will more than likely need to tweak the makefile to get the build to work on your target system.

On a side note, you may want to look at the Java Instrumentation API, as it wraps JVMTI and provides a more convenient interface over it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top