< prev index next >

src/hotspot/share/classfile/verificationType.cpp

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 62,15 ***
      if (log_is_enabled(Debug, class, resolve)) {
        Verifier::trace_class_resolution(this_class, klass);
      }
    }
  
    if (this_class->is_interface() && (!from_field_is_protected ||
        from_name != vmSymbols::java_lang_Object())) {
      // If we are not trying to access a protected field or method in
      // java.lang.Object then, for arrays, we only allow assignability
!     // to interfaces java.lang.Cloneable and java.io.Serializable.
      // Otherwise, we treat interfaces as java.lang.Object.
      return !from_is_array ||
        this_class == vmClasses::Cloneable_klass() ||
        this_class == vmClasses::Serializable_klass();
    } else if (from_is_object) {
--- 62,22 ---
      if (log_is_enabled(Debug, class, resolve)) {
        Verifier::trace_class_resolution(this_class, klass);
      }
    }
  
+   // Need to do this check when called from CDS.
+   // if (this_class->access_flags().is_primitive_class()) {
+   //   Klass* from_class = SystemDictionary::resolve_or_fail(
+   //     from_name, Handle(THREAD, klass->class_loader()),
+   //     Handle(THREAD, klass->protection_domain()), true, CHECK_false);
+   //   return from_class == this_class;
+   // }
    if (this_class->is_interface() && (!from_field_is_protected ||
        from_name != vmSymbols::java_lang_Object())) {
      // If we are not trying to access a protected field or method in
      // java.lang.Object then, for arrays, we only allow assignability
!     // to interfaces java.lang.Cloneable and java.io.Serializable
      // Otherwise, we treat interfaces as java.lang.Object.
      return !from_is_array ||
        this_class == vmClasses::Cloneable_klass() ||
        this_class == vmClasses::Serializable_klass();
    } else if (from_is_object) {

*** 122,10 ***
--- 129,11 ---
      return resolve_and_check_assignability(klass, name(), from.name(),
            from_field_is_protected, from.is_array(), from.is_object(), THREAD);
    } else if (is_array() && from.is_array()) {
      VerificationType comp_this = get_component(context);
      VerificationType comp_from = from.get_component(context);
+ 
      if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
        return comp_this.is_component_assignable_from(comp_from, context,
                                                      from_field_is_protected, THREAD);
      }
    }
< prev index next >