JDK-7129417 : Compress Strings dropped in Java 7, listed as on by default in docs.
  • Type: Bug
  • Component: docs
  • Sub-Component: hotspot
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: linux
  • CPU: x86
  • Submitted: 2012-01-12
  • Updated: 2013-02-07
  • Resolved: 2013-02-07
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
On this page it lists -XX:+UseCompressedStrings as on by default.

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

 However in Java 6 update 29 its off by default and in Java 7 update 2 it reports

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option UseCompressedStrings; support was removed in 7.0

The program below requires a heap of 2000m on Java 7, 1800m on Java 6 without compressed Strings and 1000m with compressed Strings.  Its also faster with compressed Strings turned on.

REGRESSION.  Last worked in version 7

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try Java 6 and 7 with and without UseCompressedStrings

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Options to improve performance to retained

OR

The documentation to reflect which options are available.  A note as to why its not available would be very interesting.
ACTUAL -
Neither

ERROR MESSAGES/STACK TRACES THAT OCCUR :
OutOfMemoryError if you don't have 2 GB for the heap.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String... args) throws IOException {
        long start = System.nanoTime();
        generateFile("lines.txt", 755 * 1024 * 1024, 189000);

        List<String> lines = loadLines("lines.txt");

        System.out.println("Sorting file");
        Collections.sort(lines);
        System.out.println("... Sorted file");
        // save lines.
        long time = System.nanoTime() - start;
        System.out.printf("Took %.3f second to read, sort and write to a file%n", time / 1e9);
    }

    private static void generateFile(String fileName, int size, int lines) throws FileNotFoundException {
        System.out.println("Creating file to load");
        int lineSize = size / lines;
        StringBuilder sb = new StringBuilder();
        while (sb.length() < lineSize) sb.append('-');
        String padding = sb.toString();

        PrintWriter pw = new PrintWriter(fileName);
        for (int i = 0; i < lines; i++) {
            String text = (i + padding).substring(0, lineSize);
            pw.println(text);
        }
        pw.close();
        System.out.println("... Created file to load");
    }

    private static List<String> loadLines(String fileName) throws IOException {
        System.out.println("Reading file");
        BufferedReader br = new BufferedReader(new FileReader(fileName));
        List<String> ret = new ArrayList<String>();
        String line;
        while ((line = br.readLine()) != null)
            ret.add(line);
        System.out.println("... Read file.");
        return ret;
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use older version of Java until fixed.

SUPPORT :
YES

Comments
Java SE writers do not own technetwork pages. This issue will not be fixed for existing documentation. For JDK 8, all JVM options will be documented from scratch, including the UseCompressedStrings option which will be described in the section with other deprecated options.
07-02-2013

There is nothing to do for JDK 7. Will add this option as deprecated for JDK 8.
04-02-2013

The Java SE team does not own the page http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html The latest java command man page does not have this option described. I am planning to add a section for deprecated options there.
24-01-2013