< prev index next >

src/hotspot/share/cds/dumpTimeClassInfo.cpp

Print this page

  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/archiveBuilder.hpp"

 26 #include "cds/dumpTimeClassInfo.inline.hpp"
 27 #include "cds/runTimeClassInfo.hpp"
 28 #include "classfile/classLoader.hpp"
 29 #include "classfile/classLoaderData.inline.hpp"
 30 #include "classfile/systemDictionaryShared.hpp"
 31 #include "memory/resourceArea.hpp"
 32 
 33 DumpTimeClassInfo::~DumpTimeClassInfo() {
 34   if (_verifier_constraints != nullptr) {
 35     assert(_verifier_constraint_flags != nullptr, "must be");
 36     delete _verifier_constraints;
 37     delete _verifier_constraint_flags;
 38   }
 39   if (_loader_constraints != nullptr) {
 40     delete _loader_constraints;
 41   }
 42 }
 43 
























 44 size_t DumpTimeClassInfo::runtime_info_bytesize() const {
 45   return RunTimeClassInfo::byte_size(_klass, num_verifier_constraints(),
 46                                      num_loader_constraints(),
 47                                      num_enum_klass_static_fields());
 48 }
 49 
 50 void DumpTimeClassInfo::add_verification_constraint(InstanceKlass* k, Symbol* name,
 51          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
 52   if (_verifier_constraints == nullptr) {
 53     _verifier_constraints = new (mtClass) GrowableArray<DTVerifierConstraint>(4, mtClass);
 54   }
 55   if (_verifier_constraint_flags == nullptr) {
 56     _verifier_constraint_flags = new (mtClass) GrowableArray<char>(4, mtClass);
 57   }
 58   GrowableArray<DTVerifierConstraint>* vc_array = _verifier_constraints;
 59   for (int i = 0; i < vc_array->length(); i++) {
 60     if (vc_array->at(i).equals(name, from_name)) {
 61       return;
 62     }
 63   }

  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/archiveBuilder.hpp"
 26 #include "cds/cdsConfig.hpp"
 27 #include "cds/dumpTimeClassInfo.inline.hpp"
 28 #include "cds/runTimeClassInfo.hpp"
 29 #include "classfile/classLoader.hpp"
 30 #include "classfile/classLoaderData.inline.hpp"
 31 #include "classfile/systemDictionaryShared.hpp"
 32 #include "memory/resourceArea.hpp"
 33 
 34 DumpTimeClassInfo::~DumpTimeClassInfo() {
 35   if (_verifier_constraints != nullptr) {
 36     assert(_verifier_constraint_flags != nullptr, "must be");
 37     delete _verifier_constraints;
 38     delete _verifier_constraint_flags;
 39   }
 40   if (_loader_constraints != nullptr) {
 41     delete _loader_constraints;
 42   }
 43 }
 44 
 45 bool DumpTimeClassInfo::is_excluded() {
 46   if (_excluded) {
 47     return true;
 48   }
 49   if (_failed_verification) {
 50     if (CDSConfig::preserve_all_dumptime_verification_states(_klass)) {
 51       assert(CDSConfig::is_dumping_aot_linked_classes(), "sanity");
 52       // If the verification states are preserved, _klass will be archived in unlinked state. This is
 53       // necessary to support the following scenario, where the verification of X requires that
 54       // A be a subclass of B:
 55       //     class X {
 56       //        B getB() { return new A(); }
 57       //     }
 58       // If X and B can be verified, but A fails verification, we still archive A (in a preloaded
 59       // SystemDictionary) so that at runtime we cannot subvert the verification of X by replacing
 60       // A with a version that is not a subtype of B.
 61     } else {
 62       // Don't archive this class. At runtime, load it from classfile and rerun verification.
 63       return true;
 64     }
 65   }
 66   return false;
 67 }
 68 
 69 size_t DumpTimeClassInfo::runtime_info_bytesize() const {
 70   return RunTimeClassInfo::byte_size(_klass, num_verifier_constraints(),
 71                                      num_loader_constraints(),
 72                                      num_enum_klass_static_fields());
 73 }
 74 
 75 void DumpTimeClassInfo::add_verification_constraint(InstanceKlass* k, Symbol* name,
 76          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
 77   if (_verifier_constraints == nullptr) {
 78     _verifier_constraints = new (mtClass) GrowableArray<DTVerifierConstraint>(4, mtClass);
 79   }
 80   if (_verifier_constraint_flags == nullptr) {
 81     _verifier_constraint_flags = new (mtClass) GrowableArray<char>(4, mtClass);
 82   }
 83   GrowableArray<DTVerifierConstraint>* vc_array = _verifier_constraints;
 84   for (int i = 0; i < vc_array->length(); i++) {
 85     if (vc_array->at(i).equals(name, from_name)) {
 86       return;
 87     }
 88   }
< prev index next >