87 }
88 ~SharedPathsMiscInfo() {
89 if (_allocated) {
90 FREE_C_HEAP_ARRAY(char, _buf_start);
91 }
92 }
93 int get_used_bytes() {
94 return _cur_ptr - _buf_start;
95 }
96 void* buffer() {
97 return _buf_start;
98 }
99
100 // writing --
101
102 // The path must not exist at run-time
103 void add_nonexist_path(const char* path) {
104 add_path(path, NON_EXIST);
105 }
106
107 // The path must exist, and must contain exactly <num_entries> files/dirs
108 void add_boot_classpath(const char* path) {
109 add_path(path, BOOT);
110 }
111 int write_jint(jint num) {
112 write(&num, sizeof(num));
113 return 0;
114 }
115 void write_time(time_t t) {
116 write(&t, sizeof(t));
117 }
118 void write_long(long l) {
119 write(&l, sizeof(l));
120 }
121
122 bool dump_to_file(int fd) {
123 int n = get_used_bytes();
124 return (os::write(fd, _buf_start, n) == (size_t)n);
125 }
126
127 // reading --
128
129 enum {
130 BOOT = 1,
131 NON_EXIST = 2,
132 REQUIRED = 3
133 };
134
135 virtual const char* type_name(int type) {
136 switch (type) {
137 case BOOT: return "BOOT";
138 case NON_EXIST: return "NON_EXIST";
139 case REQUIRED: return "REQUIRED";
140 default: ShouldNotReachHere(); return "?";
141 }
142 }
143
144 virtual void print_path(int type, const char* path);
145
146 bool check();
147 bool read_jint(jint *ptr) {
148 return read(ptr, sizeof(jint));
149 }
150 bool read_long(long *ptr) {
151 return read(ptr, sizeof(long));
152 }
153 bool read_time(time_t *ptr) {
154 return read(ptr, sizeof(time_t));
155 }
156 };
157
158 #endif // SHARE_VM_CLASSFILE_SHAREDPATHSMISCINFO_HPP
|
87 }
88 ~SharedPathsMiscInfo() {
89 if (_allocated) {
90 FREE_C_HEAP_ARRAY(char, _buf_start);
91 }
92 }
93 int get_used_bytes() {
94 return _cur_ptr - _buf_start;
95 }
96 void* buffer() {
97 return _buf_start;
98 }
99
100 // writing --
101
102 // The path must not exist at run-time
103 void add_nonexist_path(const char* path) {
104 add_path(path, NON_EXIST);
105 }
106
107 // The path must exist and have required size and modification time
108 void add_required_file(const char* path) {
109 add_path(path, REQUIRED);
110
111 struct stat st;
112 if (os::stat(path, &st) != 0) {
113 assert(0, "sanity");
114 #if INCLUDE_CDS
115 ClassLoader::exit_with_path_failure("failed to os::stat(%s)", path); // should not happen
116 #endif
117 }
118 write_time(st.st_mtime);
119 write_long(st.st_size);
120 }
121
122 // The path must exist, and must contain exactly <num_entries> files/dirs
123 void add_boot_classpath(const char* path) {
124 add_path(path, BOOT);
125 }
126 void add_patch_mod_classpath(const char* path) {
127 add_path(path, PATCH_MOD);
128 }
129 int write_jint(jint num) {
130 write(&num, sizeof(num));
131 return 0;
132 }
133 void write_time(time_t t) {
134 write(&t, sizeof(t));
135 }
136 void write_long(long l) {
137 write(&l, sizeof(l));
138 }
139
140 bool dump_to_file(int fd) {
141 int n = get_used_bytes();
142 return (os::write(fd, _buf_start, n) == (size_t)n);
143 }
144
145 // reading --
146
147 enum {
148 BOOT = 1,
149 NON_EXIST = 2,
150 REQUIRED = 3,
151 PATCH_MOD = 4
152 };
153
154 virtual const char* type_name(int type) {
155 switch (type) {
156 case BOOT: return "BOOT";
157 case NON_EXIST: return "NON_EXIST";
158 case REQUIRED: return "REQUIRED";
159 case PATCH_MOD: return "PATCH_MOD";
160 default: ShouldNotReachHere(); return "?";
161 }
162 }
163
164 virtual void print_path(int type, const char* path);
165
166 bool check();
167 bool read_jint(jint *ptr) {
168 return read(ptr, sizeof(jint));
169 }
170 bool read_long(long *ptr) {
171 return read(ptr, sizeof(long));
172 }
173 bool read_time(time_t *ptr) {
174 return read(ptr, sizeof(time_t));
175 }
176 };
177
178 #endif // SHARE_VM_CLASSFILE_SHAREDPATHSMISCINFO_HPP
|