CAUTION: This site hosts draft documentation for the next release. For published content of the latest release, visit www.eclipse.org/openj9/docs

-XX:[+|-]CompactStrings

Start of content that applies only to Java 8 and later This HotSpot option is reimplemented by OpenJ9 and when enabled causes an ISO8859-1 (also known as Latin-1) character representation to be used internally for String objects, while preserving full API compatibility.

This feature provides heap space savings by using an 8-bit character set internally. Most benefit is gained when the majority of the String objects that your application uses can be encoded using the ISO8859-1 character encoding.

If the option is not enabled, the JIT compiler is nevertheless optimized so that although there is no saving in heap space, there is also no performance penalty.

Further details are available at JEP 254: Compact Strings.

Note: With OpenJ9, this option is supported on OpenJDK version 8 and later versions, whereas HotSpot only supports it from Java version 9.

Syntax

Setting Effect Default
-XX:+CompactStrings Enable String compression
-XX:-CompactStrings Disable String compression yes