United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7129417 : Compress Strings dropped in Java 7, listed as on by default in docs.

Details
Type:
Bug
Submit Date:
2012-01-12
Status:
Resolved
Updated Date:
2013-02-07
Project Name:
JDK
Resolved Date:
2013-02-07
Component:
docs
OS:
linux
Sub-Component:
hotspot
CPU:
x86
Priority:
P4
Resolution:
Won't Fix
Affected Versions:
8
Fixed Versions:
8

Related Reports

Sub Tasks

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
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.
                                     
2013-01-24
There is nothing to do for JDK 7. Will add this option as deprecated for JDK 8.
                                     
2013-02-04
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.
                                     
2013-02-07



Hardware and Software, Engineered to Work Together