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

KlassFactory::create_from_stream should never return NULL

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 17
    • hotspot
    • b13

      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) {

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

              Created:
              Updated:
              Resolved: