CommonSeeder test needs a white-box testing mechanism to replace the default entropy source

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 11
    • Affects Version/s: None
    • Component/s: security-libs
    • b20
    • Verified

        test/jdk/sun/security/provider/SecureRandom/CommonSeeder.java

        This test currently uses reflection to hack into a Field object of a static final field to "non-final". It needs a white-box testing mechanism to replace this reflection hack.

            static void setDefaultSeeder(EntropySource es) throws Exception {
                Field f = AbstractDrbg.class.getDeclaredField("defaultES");
                f.setAccessible(true); // no more private
                Field f2 = Field.class.getDeclaredField("modifiers");
                f2.setAccessible(true);
                f2.setInt(f, f2.getInt(f) - Modifier.FINAL); // no more final
                f.set(null, es);
            }

              Assignee:
              Weijun Wang
              Reporter:
              Mandy Chung (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: