Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8261090

Store old classfiles in static CDS archive



    • b20


      In JDK-8259275, we have a "new" class A that uses an lambda expression involving an interface B, but B is an "old" version. Because of this, we cannot pre-generate the lambda proxy in the CDS archive.

      Another example is a "new" class X that subclasses from "old" class Y. We won't be able to archive either X or Y.

      The check is here in classFileParser.cpp:

        if (DumpSharedSpaces && _major_version < JAVA_6_VERSION) {
          ResourceMark rm;
          warning("Pre JDK 6 class not supported by CDS: %u.%u %s",
                  _major_version, _minor_version, _class_name->as_C_string());
            "Unsupported major.minor version for dump time %u.%u",

      As far as I can remember, there were two reasons for not supporting "old" classes in CDS:

      #1 For (_major_version < JAVA_1_5_VERSION), in rare occasions we have to execute Java code, in ClassFileParser::skip_over_field_signature(). This was not possible at one point because we couldn't execute Java code during DumpSharedSpaces. However, that has been fixed, so this restriction no longer applies.

      #2 With the split verifier, we have to remember the verifier constraints:

      bool VerificationType::is_reference_assignable_from(
          const VerificationType& from, ClassVerifier* context,
          bool from_field_is_protected, TRAPS) const {
          if (Arguments::is_dumping_archive()) {
            if (SystemDictionaryShared::add_verification_constraint(klass,
                    name(), from.name(), from_field_is_protected, from.is_array(),
                    from.is_object())) {
              // If add_verification_constraint() returns true, the resolution/check should be
              // delayed until runtime.
              return true;

      This REF proposes to fix #1, so we can store the "old" classes in the CDS archive. This would enable more optimizations for "new" classes that use such old classes. It will also get rid of the deluge of "UnsupportedClassVersionError" warning with -Xshare:dump. Also, loading of old classes will be faster (even if they are still not as fast as new classes).

      The old classes are not verified/rewritten during dump time. Instead, they are verified/rewritten at runtime. This means that the ConstMethod of old classes must be stored in the RW region to allow runtime rewriting.

      Note that for dynamic dumping, the classes are already rewritten, so we would need to un-rewrite the old classes first. For simplicity, this RFE supports only static archive.


        Issue Links



              ccheung Calvin Cheung
              iklam Ioi Lam
              0 Vote for this issue
              8 Start watching this issue