< prev index next >

test/lib/jdk/test/lib/Utils.java

Print this page
*** 495,22 ***
       * In case no seed is provided and the build under test is "promotable"
       * (its build number ({@code $BUILD} in {@link Runtime.Version}) is greater than 0,
       * the seed based on string representation of {@link Runtime#version()} is used.
       * Otherwise, the seed is randomly generated.
       * The used seed printed to stdout.
!      *
       * @return {@link java.util.Random} generator with particular seed.
       */
      public static Random getRandomInstance() {
          if (RANDOM_GENERATOR == null) {
              synchronized (Utils.class) {
                  if (RANDOM_GENERATOR == null) {
                      RANDOM_GENERATOR = new Random(SEED);
!                     System.out.printf("For random generator using seed: %d%n", SEED);
!                     System.out.printf("To re-run test with same seed value please add \"-D%s=%d\" to command line.%n", SEED_PROPERTY_NAME, SEED);
                  }
              }
          }
          return RANDOM_GENERATOR;
      }
  
      /**
--- 495,24 ---
       * In case no seed is provided and the build under test is "promotable"
       * (its build number ({@code $BUILD} in {@link Runtime.Version}) is greater than 0,
       * the seed based on string representation of {@link Runtime#version()} is used.
       * Otherwise, the seed is randomly generated.
       * The used seed printed to stdout.
!      * The printing is not in the synchronized block so as to prevent carrier threads starvation.
       * @return {@link java.util.Random} generator with particular seed.
       */
      public static Random getRandomInstance() {
          if (RANDOM_GENERATOR == null) {
              synchronized (Utils.class) {
                  if (RANDOM_GENERATOR == null) {
                      RANDOM_GENERATOR = new Random(SEED);
!                 } else {
!                     return RANDOM_GENERATOR;
                  }
              }
+             System.out.printf("For random generator using seed: %d%n", SEED);
+             System.out.printf("To re-run test with same seed value please add \"-D%s=%d\" to command line.%n", SEED_PROPERTY_NAME, SEED);
          }
          return RANDOM_GENERATOR;
      }
  
      /**
< prev index next >