117

Found an interesting JVM Flag :

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version

It prints hundreds of various options, I never heard about before. It also prints default values, that helps diagnose JVM behaviors better. Another interesting flag is:

-XX:+UnlockExperimentalVMOptions

Does anyone knows of any documentation which explains each one of them ?

Hearen
  • 7,420
  • 4
  • 53
  • 63
Sachin Bhansali
  • 1,372
  • 2
  • 9
  • 12
  • 5
    http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html – user1329572 May 07 '12 at 17:32
  • The reason that commandline isn't listed in the documentation is, because as the name says it's there to diagnose the VM. It can be assumed that the people debugging hotspot probably know them ;) – Voo May 07 '12 at 18:38
  • 1
    this [link](http://www.javaworld.com/article/2073676/hotspot-jvm-options-displayed---xx--printflagsinitial-and--xx--printflagsfinal.html) explains these options in short and pretty well. – sactiw Oct 07 '16 at 17:56

2 Answers2

47

Do not miss also -XX:+JVMCIPrintProperties for Graal JIT options.

Before dive into sources you can skim over following extracts and find suitable option faster:

https://chriswhocodes.com/ (OracleJDK 6/7/8/9/10/11/12, OpenJDK 8/9/10/11, Graal CE/EE, OpenJ9, Zing)

http://jvm-options.tech.xebia.fr/

http://www.pingtimeout.fr/2012/05/jvm-options-complete-reference.html

http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html

Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68
15

The best documentation I've found is the source.

I've used this SO Q&A to create a debug build. With this debug build, you can run java -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+PrintFlagsFinal -XX:+PrintFlagsWithComments -version.

From the directory with the sources, you could execute (assuming you are using Linux, Cygwin or the like):

grep -FR 'UnlockExperimentalVMOptions' hotspot/

Or, the following (which only looks at *.cpp and *.hpp files):

find hotspot/ -name '*.[ch]pp' -exec grep -F 'UnlockExperimentalVMOptions' {} +

Then look at the source files. Probably the best reason why there is no one document that describes all options is that some of these options are better left to those who really understand the JVM and the best way to do that is to become intimately familiar with the source code.

So, in the words (almost) of a great master, use the source!

Community
  • 1
  • 1
Go Dan
  • 15,194
  • 6
  • 41
  • 65
  • 1
    The source is by definition perfect documentation of the program. Also see http://www.codinghorror.com/blog/2012/04/learn-to-read-the-source-luke.html – Pyrolistical May 07 '12 at 18:58
  • @Pyrolistical Thanks for the link; good read and I did not know Jeff Atwood recently blogged about `read the source`. – Go Dan May 07 '12 at 19:02