public void test_subclassing() throws Exception {
    // http://b/2502231
    // Ensure that Random's constructors call setSeed by emulating the active ingredient
    // from the bug: the subclass' setSeed had a side-effect necessary for the correct
    // functioning of next.
    class MyRandom extends Random {
      public String state;

      public MyRandom() {
        super();
      }

      public MyRandom(long l) {
        super(l);
      }

      @Override
      protected synchronized int next(int bits) {
        return state.length();
      }

      @Override
      public synchronized void setSeed(long seed) {
        state = Long.toString(seed);
      }
    }
    // Test the 0-argument constructor...
    MyRandom r1 = new MyRandom();
    r1.nextInt();
    assertNotNull(r1.state);
    // Test the 1-argument constructor...
    MyRandom r2 = new MyRandom(123L);
    r2.nextInt();
    assertNotNull(r2.state);
  }