author | jiangli |
Mon, 30 Apr 2018 16:59:05 -0400 | |
changeset 49931 | 840e26123940 |
parent 49739 | 00805b129186 |
permissions | -rw-r--r-- |
26135 | 1 |
/* |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
26135 | 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" |
|
48138 | 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: |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
37 |
jshort _app_class_paths_start_index; // Index of first app classpath entry |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
38 |
jshort _app_module_paths_start_index; // Index of first module path entry |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
39 |
bool _verify_local; // BytecodeVerificationLocal setting |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
40 |
bool _verify_remote; // BytecodeVerificationRemote setting |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
41 |
bool _has_platform_or_app_classes; // Archive contains app classes |
48138 | 42 |
|
43 |
FileMapHeaderExt() { |
|
44 |
_has_platform_or_app_classes = true; |
|
45 |
} |
|
49931 | 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; } |
|
48138 | 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 { |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
64 |
APP = 5, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
65 |
MODULE = 6 |
48138 | 66 |
}; |
67 |
||
68 |
virtual const char* type_name(int type) { |
|
69 |
switch (type) { |
|
70 |
case APP: return "APP"; |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
48138
diff
changeset
|
71 |
case MODULE: return "MODULE"; |
48138 | 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 |
}; |
|
26135 | 108 |
|
109 |
class SharedClassUtil : AllStatic { |
|
110 |
public: |
|
111 |
static SharedPathsMiscInfo* allocate_shared_paths_misc_info() { |
|
48138 | 112 |
return new SharedPathsMiscInfoExt(); |
26135 | 113 |
} |
114 |
||
115 |
static SharedPathsMiscInfo* allocate_shared_paths_misc_info(char* buf, int size) { |
|
48138 | 116 |
return new SharedPathsMiscInfoExt(buf, size); |
26135 | 117 |
} |
118 |
||
119 |
static FileMapInfo::FileMapHeader* allocate_file_map_header() { |
|
48138 | 120 |
return new FileMapHeaderExt(); |
26135 | 121 |
} |
122 |
||
123 |
static size_t file_map_header_size() { |
|
48138 | 124 |
return sizeof(FileMapHeaderExt); |
26135 | 125 |
} |
126 |
||
127 |
static size_t shared_class_path_entry_size() { |
|
48138 | 128 |
return sizeof(SharedClassPathEntryExt); |
26135 | 129 |
} |
130 |
||
48138 | 131 |
static void update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS); |
132 |
static void initialize(TRAPS); |
|
26135 | 133 |
|
48138 | 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); |
|
26135 | 139 |
}; |
140 |
||
141 |
#endif // SHARE_VM_CLASSFILE_SHAREDCLASSUTIL_HPP |