4

Is it possible to get full command line with all arguments which was used to launch current Java process and to get that during OnLoad phase in JVMTI?

2 Answers2

1

I have consulted the JVMTI reference and I think that it is not natively provided, I guess your best shot is to use Byte Code Instrumentation (BCI).

Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
  • 1
    OnLoad happens before any classes are loaded, so it's to early to instrument something. – Vladimir Šor May 07 '12 at 11:19
  • You are right, I am afraid that I don't see a possibility. What problem are you trying to solve? Maybe there is a work around, I think about passing the same program arguments to the agent. – Konrad Reiche May 07 '12 at 11:51
0

Its not possible to get the pull path but on Oracle JVMs you could use

char * res;
jvmti->GetSystemProperty("sun.java.command", &res);

to get the main class and arguments.

You can use java.class.path too, so with both you can discover quite a lot about how the command started.

Neil Wightman
  • 1,103
  • 2
  • 9
  • 29