All 15 Class Loading & Bytecode Verification questions
More in Class Loading & Bytecode Verification
Advertisement
Back to results for “Security”
Java › Class Loading & Bytecode Verification

What is the purpose of the -Xverify:none (or newer -noverify) JVM flag, and why is disabling bytecode verification generally discouraged?

Intermediate

Answer

This flag disables the JVM's bytecode verification step entirely, historically used to marginally speed up application startup time (since verification does have a measurable but usually small cost) -- disabling it is generally strongly discouraged because it removes a fundamental JVM safety guarantee, potentially allowing malformed or maliciously crafted bytecode (from a compromised dependency, a corrupted build artifact, or intentionally malicious code) to execute unchecked, and the flag has actually been deprecated and had its effect removed entirely in modern JVM versions specifically because the security risk was considered to outweigh any startup performance benefit.
# Historically used (now deprecated/ineffective in modern JVMs):
java -Xverify:none -jar myapp.jar

# Modern JVMs print a warning and IGNORE this flag entirely as of Java 13+:
# "Warning: -Xverify:none is deprecated and will likely be removed in a future release."
Real-world example A team that had been using -Xverify:none in production for years to shave milliseconds off startup time discovers, upon upgrading their JVM version, that the flag now has no effect at all (verification always runs), and researching why leads them to understand they'd been disabling a critical safety mechanism for a negligible performance gain that later JVM optimizations made even less relevant.

Common follow-ups: What legitimate startup-performance alternatives exist instead of disabling verification (like Class Data Sharing/CDS)?;Why did the JDK team decide to deprecate and eventually neutralize this flag entirely rather than just discouraging its use?