Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find deprecated JVM flags

I'm using the java -XX:+PrintFlagsFinal -version as per the Print all JVM flags question, to compare results between difference JDKs on my upgrade path to JVM 11.

I've noticed though that the result of PrintFlagsFinal will still return deprecated options — e.g. PrintGC is still present, even though running -XX:+PrintGC issues a warning & runs -Xlog:gc instead.

So is there an option similar to PrintFlagsFinal that I can use to find all options that are currently deprecated so I can avoid using them?

(Know that I can manually check the release notes, but wondering if there's an in-built way of finding out from the JVM, similar to jdeprscan for deprecated module dependencies)

like image 301
anotherdave Avatar asked Nov 26 '18 09:11

anotherdave


3 Answers

There are multiple "levels" of deprecation: ALIASED, DEPRECATED, OBSOLETE and EXPIRED flags with the meaning described in arguments.cpp.

Besides above categories, there are also deprecated tracing flags that are replaced with Unified JVM Logging options.

Finally, there are some flags not listed above that simply have "deprecated" in the description.

I'm not aware of a single place that collects all these deprecated flags together, but it's fairly easy to extract them from JVM sources: the mentioned arguments.cpp and globals*.hpp family. I also recommend VM Options Explorer site with well structured table of HotSpot JVM flags by version.

As of JDK 11, the list of deprecated/obsolete/expired and otherwise unsupported flags includes:

AggressiveOpts
AllowNonVirtualCalls
AssumeMP
CheckAssertionStatusDirectives
CheckEndorsedAndExtDirs
CompilerThreadHintNoPreempt
CreateMinidumpOnCrash
DefaultMaxRAMFraction
DeferPollingPageLoopCount
DeferThrSuspendLoopCount
EnableTracing
FastTLABRefill
FreqCountInvocations
IgnoreUnverifiableClassesDuringDump
InitialRAMFraction
InlineNotify
MaxGCMinorPauseMillis
MaxPermSize
MaxRAMFraction
MinRAMFraction
MonitorInUseLists
MustCallLoadClassInternal
NativeMonitorFlags
NativeMonitorSpinLimit
NativeMonitorTimeout
PermSize
PrintCompressedOopsMode
PrintGC
PrintGCDetails
PrintMalloc
PrintMallocFree
PrintSafepointStatistics
PrintSafepointStatisticsCount
PrintSafepointStatisticsTimeout
PrintSharedSpaces
SafepointSpinBeforeYield
SharedMiscCodeSize
SharedMiscDataSize
SharedReadOnlySize
SharedReadWriteSize
ShowSafepointMsgs
TraceBiasedLocking
TraceClassLoading
TraceClassLoadingPreorder
TraceClassPaths
TraceClassResolution
TraceClassUnloading
TraceExceptions
TraceJVMTIObjectTagging
TraceLoaderConstraints
TraceMonitorInflation
TraceRedefineClasses
TraceSafepointCleanupTime
TraceScavenge
UnlinkSymbolsALot
UnsyncloadClass
UseAppCDS
UseConcMarkSweepGC
UseLockedTracing
UseMembar
UseUTCFileTimestamp
VMThreadHintNoPreempt

UPDATE

Thanks to @chriswhocodes, VM Options Explorer now shows deprecated JVM flags.

like image 190
apangin Avatar answered Oct 29 '22 00:10

apangin


I've added deprecation information to the VM Options Explorer at https://chriswhocodes.com/hotspot_option_differences.html Differences between JDK11 and JDK12 VM options

like image 36
ChrisWhoCodes Avatar answered Oct 29 '22 01:10

ChrisWhoCodes


If you can run a Java Flight Recording on the application (e.g. in a development setting) and open it with Java/JDK Mission Control (>= 6.0.0) then JMC will analyze the flags you use to start your JVM and tell you which of them are deprecated.

like image 37
Henrik Dafgård Avatar answered Oct 29 '22 00:10

Henrik Dafgård