< prev index next >

test/java/lang/String/CompactString/VMOptionsTest.java

Print this page




  22  */
  23 
  24 import java.io.*;
  25 import java.lang.reflect.Field;
  26 
  27 import org.testng.annotations.BeforeClass;
  28 import org.testng.annotations.DataProvider;
  29 import org.testng.annotations.Test;
  30 
  31 import static org.testng.Assert.*;
  32 
  33 /*
  34  * @test
  35  * @bug 8077559
  36  * @summary Tests Compact String. This one is testing
  37  *          if Compact String enable/disable VM Options is indeed working in String class,
  38  *          it's verified by testing if the VM option affect coder and
  39  *          COMPACT_STRINGS field in String class.
  40  * @run testng/othervm -XX:+CompactStrings -DCompactStringEnabled=true VMOptionsTest
  41  * @run testng/othervm -XX:-CompactStrings -DCompactStringEnabled=false VMOptionsTest
  42  * @run testng/othervm -DCompactStringEnabled=true VMOptionsTest
  43  */
  44 
  45 public class VMOptionsTest {
  46     boolean compactStringEnabled;
  47     // corresponding "COMPACT_STRINGS" field in String class.
  48     Field COMPACT_STRINGS;
  49     // corresponding "coder" field in String class.
  50     Field coder;
  51 
  52     // corresponding coder type in String class.
  53     final byte LATIN1 = 0;
  54     final byte UTF16  = 1;
  55 
  56     @BeforeClass
  57     public void setUp() throws Exception {
  58         compactStringEnabled = Boolean.valueOf(System.getProperty("CompactStringEnabled", null));
  59         COMPACT_STRINGS = String.class.getDeclaredField("COMPACT_STRINGS");
  60         COMPACT_STRINGS.setAccessible(true);
  61         coder = String.class.getDeclaredField("coder");
  62         coder.setAccessible(true);




  22  */
  23 
  24 import java.io.*;
  25 import java.lang.reflect.Field;
  26 
  27 import org.testng.annotations.BeforeClass;
  28 import org.testng.annotations.DataProvider;
  29 import org.testng.annotations.Test;
  30 
  31 import static org.testng.Assert.*;
  32 
  33 /*
  34  * @test
  35  * @bug 8077559
  36  * @summary Tests Compact String. This one is testing
  37  *          if Compact String enable/disable VM Options is indeed working in String class,
  38  *          it's verified by testing if the VM option affect coder and
  39  *          COMPACT_STRINGS field in String class.
  40  * @run testng/othervm -XX:+CompactStrings -DCompactStringEnabled=true VMOptionsTest
  41  * @run testng/othervm -XX:-CompactStrings -DCompactStringEnabled=false VMOptionsTest

  42  */
  43 
  44 public class VMOptionsTest {
  45     boolean compactStringEnabled;
  46     // corresponding "COMPACT_STRINGS" field in String class.
  47     Field COMPACT_STRINGS;
  48     // corresponding "coder" field in String class.
  49     Field coder;
  50 
  51     // corresponding coder type in String class.
  52     final byte LATIN1 = 0;
  53     final byte UTF16  = 1;
  54 
  55     @BeforeClass
  56     public void setUp() throws Exception {
  57         compactStringEnabled = Boolean.valueOf(System.getProperty("CompactStringEnabled", null));
  58         COMPACT_STRINGS = String.class.getDeclaredField("COMPACT_STRINGS");
  59         COMPACT_STRINGS.setAccessible(true);
  60         coder = String.class.getDeclaredField("coder");
  61         coder.setAccessible(true);


< prev index next >