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

KlassFactory::create_from_stream should never return NULL

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b13

      Description

      https://github.com/openjdk/jdk/blob/044e2a2a499ff63dffae355b2254ec6bfcc3e01d/src/hotspot/share/classfile/klassFactory.cpp#L209

        InstanceKlass* result = parser.create_instance_klass(old_stream != stream, *cl_inst_info, CHECK_NULL);

        if (result == NULL) {
          return NULL;
        }

      But parser.create_instance_klass() will never return NULL in a normal return.

      We should get rid of the above "if" check. Then, we can remove unnecessary NULL checks by callers of create_from_stream. E.g., here in systemDictionary.cpp:

        InstanceKlass* k = KlassFactory::create_from_stream(st,
                                                            class_name,
                                                            loader_data,
                                                            cl_info,
                                                            CHECK_NULL);
        if ((cl_info.is_hidden() || is_unsafe_anon_class) && k != NULL) {

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              coleenp Coleen Phillimore
              Reporter:
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: