JVMTI, JMX and the attach API are all supported.
The list of diagnostic commands varies with each version of the JVM, but you can easily query the JVM with "$JAVA_HOME/bin/jcmd <pid> help". This will give you a list of all the commands supported for that JVM. "$JAVA_HOME/bin/jcmd <pid> help <command>" will give you details about that particular command.
You code snippet does not look like JVMTI, but Serviceability Agent code. In your case JVM 1 will execute the code. It will first attach to JVM 2 as if it were a debugger (completely suspending execution in JVM 2 until it detaches).
The JMC code is not currently freely available.
Ok. I have misunderstood. JVMTI deals with JNI agents(http://www.oracle.com/technetwork/articles/javase/jvmti-136367.html )and serviceability API is Java. Right ? Can the attach API do everything that JVMTI does ? If this has all been explained in an article I will read that first. There are a few such technologies and I found it confusing.
Yes, JVMTI is a native API (C or C++) whereas the Serviceability Agent is in Java. JVMTI is a supported and specified API. The Serviceability agent API is not supported and may change at any time.
JVMTI is a very versatile API which can be used of writing debuggers and profilers. The attach API is very specific and only does a few things, one of which is to load a JVMTI agent. In short: they do different things.