< prev index next >

test/gc/arguments/TestObjectTenuringFlags.java

Print this page




  31  * @build TestObjectTenuringFlags FlagsValue
  32  * @run main/othervm TestObjectTenuringFlags
  33  */
  34 
  35 import com.oracle.java.testlibrary.*;
  36 
  37 import java.util.*;
  38 
  39 public class TestObjectTenuringFlags {
  40   public static void main(String args[]) throws Exception {
  41     // default case
  42     runTenuringFlagsConsistencyTest(
  43         new String[]{},
  44         false /* shouldFail */,
  45         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 15));
  46 
  47     // valid cases
  48     runTenuringFlagsConsistencyTest(
  49         new String[]{"-XX:+NeverTenure"},
  50         false /* shouldFail */,
  51         new ExpectedTenuringFlags(false /* alwaysTenure */, true /* neverTenure */, 7, 16));
  52 
  53     runTenuringFlagsConsistencyTest(
  54         new String[]{"-XX:+AlwaysTenure"},
  55         false /* shouldFail */,
  56         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
  57 
  58     runTenuringFlagsConsistencyTest(
  59         new String[]{"-XX:MaxTenuringThreshold=0"},
  60         false /* shouldFail */,
  61         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
  62 
  63     runTenuringFlagsConsistencyTest(
  64         new String[]{"-XX:MaxTenuringThreshold=5"},
  65         false /* shouldFail */,
  66         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 5, 5));
  67 
  68     runTenuringFlagsConsistencyTest(
  69         new String[]{"-XX:MaxTenuringThreshold=10"},
  70         false /* shouldFail */,
  71         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 10));
  72 
  73     runTenuringFlagsConsistencyTest(
  74         new String[]{"-XX:MaxTenuringThreshold=15"},
  75         false /* shouldFail */,
  76         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 15));
  77 
  78     runTenuringFlagsConsistencyTest(
  79         new String[]{"-XX:MaxTenuringThreshold=16"},
  80         false /* shouldFail */,
  81         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 16));
  82 
  83     runTenuringFlagsConsistencyTest(
  84         new String[]{"-XX:InitialTenuringThreshold=0"},
  85         false /* shouldFail */,
  86         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 0, 15));
  87 
  88     runTenuringFlagsConsistencyTest(
  89         new String[]{"-XX:InitialTenuringThreshold=5"},
  90         false /* shouldFail */,
  91         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 5, 15));
  92 
  93     runTenuringFlagsConsistencyTest(
  94         new String[]{"-XX:InitialTenuringThreshold=10"},
  95         false /* shouldFail */,
  96         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 10, 15));
  97 
  98     runTenuringFlagsConsistencyTest(
  99         new String[]{"-XX:InitialTenuringThreshold=15"},
 100         false /* shouldFail */,
 101         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 15, 15));
 102 
 103     // "Last option wins" cases
 104     runTenuringFlagsConsistencyTest(
 105         new String[]{"-XX:+AlwaysTenure", "-XX:+NeverTenure"},
 106         false /* shouldFail */,
 107         new ExpectedTenuringFlags(false /* alwaysTenure */, true /* neverTenure */, 7, 16));
 108 
 109     runTenuringFlagsConsistencyTest(
 110         new String[]{"-XX:+NeverTenure", "-XX:+AlwaysTenure"},
 111         false /* shouldFail */,
 112         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
 113 
 114     runTenuringFlagsConsistencyTest(
 115         new String[]{"-XX:MaxTenuringThreshold=16", "-XX:+AlwaysTenure"},
 116         false /* shouldFail */,
 117         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
 118 
 119     runTenuringFlagsConsistencyTest(
 120         new String[]{"-XX:+AlwaysTenure", "-XX:MaxTenuringThreshold=16"},
 121         false /* shouldFail */,
 122         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 16));
 123 
 124     runTenuringFlagsConsistencyTest(
 125         new String[]{"-XX:MaxTenuringThreshold=0", "-XX:+NeverTenure"},
 126         false /* shouldFail */,
 127         new ExpectedTenuringFlags(false /* alwaysTenure */, true /* neverTenure */, 7, 16));
 128 
 129     runTenuringFlagsConsistencyTest(
 130         new String[]{"-XX:+NeverTenure", "-XX:MaxTenuringThreshold=0"},
 131         false /* shouldFail */,
 132         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
 133 
 134     // Illegal cases
 135     runTenuringFlagsConsistencyTest(
 136         new String[]{"-XX:MaxTenuringThreshold=17"},
 137         true /* shouldFail */,
 138         new ExpectedTenuringFlags());
 139 
 140     runTenuringFlagsConsistencyTest(
 141         new String[]{"-XX:InitialTenuringThreshold=16"},
 142         true /* shouldFail */,
 143         new ExpectedTenuringFlags());
 144 
 145     runTenuringFlagsConsistencyTest(
 146         new String[]{"-XX:InitialTenuringThreshold=17"},
 147         true /* shouldFail */,
 148         new ExpectedTenuringFlags());
 149   }
 150 
 151   private static void runTenuringFlagsConsistencyTest(String[] tenuringFlags,
 152           boolean shouldFail,
 153           ExpectedTenuringFlags expectedFlags) throws Exception {
 154     List<String> vmOpts = new ArrayList<>();
 155     if (tenuringFlags.length > 0) {
 156       Collections.addAll(vmOpts, tenuringFlags);
 157     }
 158     Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version");
 159 
 160     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
 161     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 162 
 163     if (shouldFail) {
 164       output.shouldHaveExitValue(1);
 165     } else {
 166       output.shouldHaveExitValue(0);




  31  * @build TestObjectTenuringFlags FlagsValue
  32  * @run main/othervm TestObjectTenuringFlags
  33  */
  34 
  35 import com.oracle.java.testlibrary.*;
  36 
  37 import java.util.*;
  38 
  39 public class TestObjectTenuringFlags {
  40   public static void main(String args[]) throws Exception {
  41     // default case
  42     runTenuringFlagsConsistencyTest(
  43         new String[]{},
  44         false /* shouldFail */,
  45         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 15));
  46 
  47     // valid cases
  48     runTenuringFlagsConsistencyTest(
  49         new String[]{"-XX:+NeverTenure"},
  50         false /* shouldFail */,
  51         new ExpectedTenuringFlags(false /* alwaysTenure */, true /* neverTenure */, 7, 32));
  52 
  53     runTenuringFlagsConsistencyTest(
  54         new String[]{"-XX:+AlwaysTenure"},
  55         false /* shouldFail */,
  56         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
  57 
  58     runTenuringFlagsConsistencyTest(
  59         new String[]{"-XX:MaxTenuringThreshold=0"},
  60         false /* shouldFail */,
  61         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
  62 
  63     runTenuringFlagsConsistencyTest(
  64         new String[]{"-XX:MaxTenuringThreshold=5"},
  65         false /* shouldFail */,
  66         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 5, 5));
  67 
  68     runTenuringFlagsConsistencyTest(
  69         new String[]{"-XX:MaxTenuringThreshold=10"},
  70         false /* shouldFail */,
  71         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 10));
  72 
  73     runTenuringFlagsConsistencyTest(
  74         new String[]{"-XX:MaxTenuringThreshold=31"},
  75         false /* shouldFail */,
  76         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 31));
  77 
  78     runTenuringFlagsConsistencyTest(
  79         new String[]{"-XX:MaxTenuringThreshold=32"},
  80         false /* shouldFail */,
  81         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 32));
  82 
  83     runTenuringFlagsConsistencyTest(
  84         new String[]{"-XX:InitialTenuringThreshold=0"},
  85         false /* shouldFail */,
  86         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 0, 15));
  87 
  88     runTenuringFlagsConsistencyTest(
  89         new String[]{"-XX:InitialTenuringThreshold=5"},
  90         false /* shouldFail */,
  91         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 5, 15));
  92 
  93     runTenuringFlagsConsistencyTest(
  94         new String[]{"-XX:InitialTenuringThreshold=10"},
  95         false /* shouldFail */,
  96         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 10, 15));
  97 
  98     runTenuringFlagsConsistencyTest(
  99         new String[]{"-XX:InitialTenuringThreshold=15"},
 100         false /* shouldFail */,
 101         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 15, 15));
 102 
 103     // "Last option wins" cases
 104     runTenuringFlagsConsistencyTest(
 105         new String[]{"-XX:+AlwaysTenure", "-XX:+NeverTenure"},
 106         false /* shouldFail */,
 107         new ExpectedTenuringFlags(false /* alwaysTenure */, true /* neverTenure */, 7, 32));
 108 
 109     runTenuringFlagsConsistencyTest(
 110         new String[]{"-XX:+NeverTenure", "-XX:+AlwaysTenure"},
 111         false /* shouldFail */,
 112         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
 113 
 114     runTenuringFlagsConsistencyTest(
 115         new String[]{"-XX:MaxTenuringThreshold=32", "-XX:+AlwaysTenure"},
 116         false /* shouldFail */,
 117         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
 118 
 119     runTenuringFlagsConsistencyTest(
 120         new String[]{"-XX:+AlwaysTenure", "-XX:MaxTenuringThreshold=32"},
 121         false /* shouldFail */,
 122         new ExpectedTenuringFlags(false /* alwaysTenure */, false /* neverTenure */, 7, 32));
 123 
 124     runTenuringFlagsConsistencyTest(
 125         new String[]{"-XX:MaxTenuringThreshold=0", "-XX:+NeverTenure"},
 126         false /* shouldFail */,
 127         new ExpectedTenuringFlags(false /* alwaysTenure */, true /* neverTenure */, 7, 32));
 128 
 129     runTenuringFlagsConsistencyTest(
 130         new String[]{"-XX:+NeverTenure", "-XX:MaxTenuringThreshold=0"},
 131         false /* shouldFail */,
 132         new ExpectedTenuringFlags(true /* alwaysTenure */, false /* neverTenure */, 0, 0));
 133 
 134     // Illegal cases
 135     runTenuringFlagsConsistencyTest(
 136         new String[]{"-XX:MaxTenuringThreshold=33"},
 137         true /* shouldFail */,
 138         new ExpectedTenuringFlags());
 139 
 140     runTenuringFlagsConsistencyTest(
 141         new String[]{"-XX:InitialTenuringThreshold=32"},
 142         true /* shouldFail */,
 143         new ExpectedTenuringFlags());
 144 
 145     runTenuringFlagsConsistencyTest(
 146         new String[]{"-XX:InitialTenuringThreshold=33"},
 147         true /* shouldFail */,
 148         new ExpectedTenuringFlags());
 149   }
 150 
 151   private static void runTenuringFlagsConsistencyTest(String[] tenuringFlags,
 152           boolean shouldFail,
 153           ExpectedTenuringFlags expectedFlags) throws Exception {
 154     List<String> vmOpts = new ArrayList<>();
 155     if (tenuringFlags.length > 0) {
 156       Collections.addAll(vmOpts, tenuringFlags);
 157     }
 158     Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version");
 159 
 160     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
 161     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 162 
 163     if (shouldFail) {
 164       output.shouldHaveExitValue(1);
 165     } else {
 166       output.shouldHaveExitValue(0);


< prev index next >