1 /* 2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 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 #ifndef SHARE_VM_CLASSFILE_SHAREDCLASSUTIL_HPP 26 #define SHARE_VM_CLASSFILE_SHAREDCLASSUTIL_HPP 27 28 #include "classfile/sharedPathsMiscInfo.hpp" 29 #include "memory/filemap.hpp" 30 #include "classfile/classLoaderExt.hpp" 31 #include "classfile/dictionary.hpp" 32 #include "classfile/systemDictionaryShared.hpp" 33 #include "oops/klass.hpp" 34 35 class FileMapHeaderExt: public FileMapInfo::FileMapHeader { 36 public: 37 jshort _app_class_paths_start_index; // Index of first app classpath entry 38 jshort _app_module_paths_start_index; // Index of first module path entry 39 bool _verify_local; // BytecodeVerificationLocal setting 40 bool _verify_remote; // BytecodeVerificationRemote setting 41 bool _has_platform_or_app_classes; // Archive contains app classes 42 43 FileMapHeaderExt() { 44 _has_platform_or_app_classes = true; 45 } 46 void set_has_platform_or_app_classes(bool v) { 47 _has_platform_or_app_classes = v; 48 } 49 bool has_platform_or_app_classes() { return _has_platform_or_app_classes; } 50 virtual void populate(FileMapInfo* mapinfo, size_t alignment); 51 virtual bool validate(); 52 }; 53 54 // In addition to SharedPathsMiscInfo, the following information is also stored 55 // 56 // 57 // + The value of Arguments::get_appclasspath() used during dumping. 58 // 59 class SharedPathsMiscInfoExt : public SharedPathsMiscInfo { 60 private: 61 int _app_offset; 62 public: 63 enum { 64 APP = 5, 65 MODULE = 6 66 }; 67 68 virtual const char* type_name(int type) { 69 switch (type) { 70 case APP: return "APP"; 71 case MODULE: return "MODULE"; 72 default: return SharedPathsMiscInfo::type_name(type); 73 } 74 } 75 76 virtual void print_path(outputStream* out, int type, const char* path); 77 78 SharedPathsMiscInfoExt() : SharedPathsMiscInfo() { 79 _app_offset = 0; 80 } 81 SharedPathsMiscInfoExt(char* buf, int size) : SharedPathsMiscInfo(buf, size) { 82 _app_offset = 0; 83 } 84 85 virtual bool check(jint type, const char* path); 86 87 void add_app_classpath(const char* path) { 88 add_path(path, APP); 89 } 90 91 void record_app_offset() { 92 _app_offset = get_used_bytes(); 93 } 94 void pop_app() { 95 _cur_ptr = _buf_start + _app_offset; 96 write_jint(0); 97 } 98 }; 99 100 class SharedClassPathEntryExt: public SharedClassPathEntry { 101 public: 102 //Maniest attributes 103 bool _is_signed; 104 void set_manifest(Array<u1>* manifest) { 105 _manifest = manifest; 106 } 107 }; 108 109 class SharedClassUtil : AllStatic { 110 public: 111 static SharedPathsMiscInfo* allocate_shared_paths_misc_info() { 112 return new SharedPathsMiscInfoExt(); 113 } 114 115 static SharedPathsMiscInfo* allocate_shared_paths_misc_info(char* buf, int size) { 116 return new SharedPathsMiscInfoExt(buf, size); 117 } 118 119 static FileMapInfo::FileMapHeader* allocate_file_map_header() { 120 return new FileMapHeaderExt(); 121 } 122 123 static size_t file_map_header_size() { 124 return sizeof(FileMapHeaderExt); 125 } 126 127 static size_t shared_class_path_entry_size() { 128 return sizeof(SharedClassPathEntryExt); 129 } 130 131 static void update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS); 132 static void initialize(TRAPS); 133 134 private: 135 static void read_extra_data(const char* filename, TRAPS); 136 137 public: 138 static bool is_classpath_entry_signed(int classpath_index); 139 }; 140 141 #endif // SHARE_VM_CLASSFILE_SHAREDCLASSUTIL_HPP