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 #include "precompiled.hpp"
25 #include "classfile/classFileParser.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.inline.hpp"
29 #include "classfile/defaultMethods.hpp"
30 #include "classfile/javaClasses.inline.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "classfile/symbolTable.hpp"
33 #include "classfile/systemDictionary.hpp"
34 #include "classfile/verificationType.hpp"
35 #include "classfile/verifier.hpp"
36 #include "classfile/vmSymbols.hpp"
37 #include "gc/shared/gcLocker.hpp"
38 #include "logging/log.hpp"
39 #include "memory/allocation.hpp"
40 #include "memory/metadataFactory.hpp"
41 #include "memory/oopFactory.hpp"
42 #include "memory/resourceArea.hpp"
43 #include "memory/universe.inline.hpp"
44 #include "oops/annotations.hpp"
45 #include "oops/fieldStreams.hpp"
46 #include "oops/instanceKlass.hpp"
47 #include "oops/instanceMirrorKlass.hpp"
48 #include "oops/klass.inline.hpp"
49 #include "oops/klassVtable.hpp"
50 #include "oops/metadata.hpp"
51 #include "oops/method.hpp"
52 #include "oops/oop.inline.hpp"
54 #include "prims/jvm.h"
55 #include "prims/jvmtiExport.hpp"
56 #include "prims/jvmtiThreadState.hpp"
57 #include "runtime/javaCalls.hpp"
58 #include "runtime/perfData.hpp"
59 #include "runtime/reflection.hpp"
60 #include "runtime/signature.hpp"
61 #include "runtime/timer.hpp"
62 #include "services/classLoadingService.hpp"
63 #include "services/threadService.hpp"
64 #include "trace/traceMacros.hpp"
65 #include "utilities/array.hpp"
66 #include "utilities/exceptions.hpp"
67 #include "utilities/globalDefinitions.hpp"
68 #include "utilities/macros.hpp"
69 #include "utilities/ostream.hpp"
70 #include "utilities/resourceHash.hpp"
71 #if INCLUDE_CDS
72 #include "classfile/systemDictionaryShared.hpp"
73 #endif
74
75 // We generally try to create the oops directly when parsing, rather than
76 // allocating temporary data structures and copying the bytes twice. A
77 // temporary area is only needed when parsing utf8 entries in the constant
78 // pool and when parsing line number tables.
79
80 // We add assert in debug mode when class format is not checked.
81
82 #define JAVA_CLASSFILE_MAGIC 0xCAFEBABE
83 #define JAVA_MIN_SUPPORTED_VERSION 45
84 #define JAVA_MAX_SUPPORTED_VERSION 53
85 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
86
87 // Used for two backward compatibility reasons:
88 // - to check for new additions to the class file format in JDK1.5
89 // - to check for bug fixes in the format checker in JDK1.5
90 #define JAVA_1_5_VERSION 49
91
92 // Used for backward compatibility reasons:
93 // - to check for javac bug fixes that happened after 1.5
5173 }
5174 }
5175 } // end for
5176 } // CheckIntrinsics
5177 #endif // ASSERT
5178 }
5179 }
5180
5181 InstanceKlass* ClassFileParser::create_instance_klass(bool changed_by_loadhook, TRAPS) {
5182 if (_klass != NULL) {
5183 return _klass;
5184 }
5185
5186 InstanceKlass* const ik =
5187 InstanceKlass::allocate_instance_klass(*this, CHECK_NULL);
5188
5189 fill_instance_klass(ik, changed_by_loadhook, CHECK_NULL);
5190
5191 assert(_klass == ik, "invariant");
5192
5193 return ik;
5194 }
5195
5196 void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loadhook, TRAPS) {
5197 assert(ik != NULL, "invariant");
5198
5199 set_klass_to_deallocate(ik);
5200
5201 assert(_field_info != NULL, "invariant");
5202 assert(ik->static_field_size() == _field_info->static_field_size, "sanity");
5203 assert(ik->nonstatic_oop_map_count() == _field_info->total_oop_map_count,
5204 "sanity");
5205
5206 assert(ik->is_instance_klass(), "sanity");
5207 assert(ik->size_helper() == _field_info->instance_size, "sanity");
5208
5209 // Fill in information already parsed
5210 ik->set_should_verify_class(_need_verify);
5211
5212 // Not yet: supers are done below to support the new subtype-checking fields
|
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 #include "precompiled.hpp"
25 #include "classfile/classFileParser.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.inline.hpp"
29 #include "classfile/defaultMethods.hpp"
30 #include "classfile/javaClasses.inline.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "classfile/symbolTable.hpp"
33 #include "classfile/dictionary.hpp"
34 #include "classfile/systemDictionary.hpp"
35 #include "classfile/verificationType.hpp"
36 #include "classfile/verifier.hpp"
37 #include "classfile/vmSymbols.hpp"
38 #include "gc/shared/gcLocker.hpp"
39 #include "logging/log.hpp"
40 #include "memory/allocation.hpp"
41 #include "memory/metadataFactory.hpp"
42 #include "memory/oopFactory.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "memory/universe.inline.hpp"
45 #include "oops/annotations.hpp"
46 #include "oops/fieldStreams.hpp"
47 #include "oops/instanceKlass.hpp"
48 #include "oops/instanceMirrorKlass.hpp"
49 #include "oops/klass.inline.hpp"
50 #include "oops/klassVtable.hpp"
51 #include "oops/metadata.hpp"
52 #include "oops/method.hpp"
53 #include "oops/oop.inline.hpp"
55 #include "prims/jvm.h"
56 #include "prims/jvmtiExport.hpp"
57 #include "prims/jvmtiThreadState.hpp"
58 #include "runtime/javaCalls.hpp"
59 #include "runtime/perfData.hpp"
60 #include "runtime/reflection.hpp"
61 #include "runtime/signature.hpp"
62 #include "runtime/timer.hpp"
63 #include "services/classLoadingService.hpp"
64 #include "services/threadService.hpp"
65 #include "trace/traceMacros.hpp"
66 #include "utilities/array.hpp"
67 #include "utilities/exceptions.hpp"
68 #include "utilities/globalDefinitions.hpp"
69 #include "utilities/macros.hpp"
70 #include "utilities/ostream.hpp"
71 #include "utilities/resourceHash.hpp"
72 #if INCLUDE_CDS
73 #include "classfile/systemDictionaryShared.hpp"
74 #endif
75 #include "aot/aotLoader.hpp"
76
77 // We generally try to create the oops directly when parsing, rather than
78 // allocating temporary data structures and copying the bytes twice. A
79 // temporary area is only needed when parsing utf8 entries in the constant
80 // pool and when parsing line number tables.
81
82 // We add assert in debug mode when class format is not checked.
83
84 #define JAVA_CLASSFILE_MAGIC 0xCAFEBABE
85 #define JAVA_MIN_SUPPORTED_VERSION 45
86 #define JAVA_MAX_SUPPORTED_VERSION 53
87 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
88
89 // Used for two backward compatibility reasons:
90 // - to check for new additions to the class file format in JDK1.5
91 // - to check for bug fixes in the format checker in JDK1.5
92 #define JAVA_1_5_VERSION 49
93
94 // Used for backward compatibility reasons:
95 // - to check for javac bug fixes that happened after 1.5
5175 }
5176 }
5177 } // end for
5178 } // CheckIntrinsics
5179 #endif // ASSERT
5180 }
5181 }
5182
5183 InstanceKlass* ClassFileParser::create_instance_klass(bool changed_by_loadhook, TRAPS) {
5184 if (_klass != NULL) {
5185 return _klass;
5186 }
5187
5188 InstanceKlass* const ik =
5189 InstanceKlass::allocate_instance_klass(*this, CHECK_NULL);
5190
5191 fill_instance_klass(ik, changed_by_loadhook, CHECK_NULL);
5192
5193 assert(_klass == ik, "invariant");
5194
5195 ik->set_has_passed_fingerprint_check(false);
5196 if (UseAOT && ik->supers_have_passed_fingerprint_checks()) {
5197 uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik);
5198 if (aot_fp != 0 && aot_fp == _stream->compute_fingerprint()) {
5199 // This class matches with a class saved in an AOT library
5200 ik->set_has_passed_fingerprint_check(true);
5201 } else {
5202 ResourceMark rm;
5203 log_info(classfingerprint)("%s : expected = " PTR64_FORMAT " actual = " PTR64_FORMAT,
5204 ik->external_name(), aot_fp, _stream->compute_fingerprint());
5205 }
5206 }
5207
5208 return ik;
5209 }
5210
5211 void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loadhook, TRAPS) {
5212 assert(ik != NULL, "invariant");
5213
5214 set_klass_to_deallocate(ik);
5215
5216 assert(_field_info != NULL, "invariant");
5217 assert(ik->static_field_size() == _field_info->static_field_size, "sanity");
5218 assert(ik->nonstatic_oop_map_count() == _field_info->total_oop_map_count,
5219 "sanity");
5220
5221 assert(ik->is_instance_klass(), "sanity");
5222 assert(ik->size_helper() == _field_info->instance_size, "sanity");
5223
5224 // Fill in information already parsed
5225 ik->set_should_verify_class(_need_verify);
5226
5227 // Not yet: supers are done below to support the new subtype-checking fields
|