Search code examples
javajvmdeprecatedjvm-arguments

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)


Solution

  • 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.