28 |
28 |
29 void ClassFileStream::truncated_file_error(TRAPS) { |
29 void ClassFileStream::truncated_file_error(TRAPS) { |
30 THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Truncated class file"); |
30 THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Truncated class file"); |
31 } |
31 } |
32 |
32 |
33 ClassFileStream::ClassFileStream(u1* buffer, int length, const char* source) { |
33 ClassFileStream::ClassFileStream(u1* buffer, int length, const char* source, bool need_verify) { |
34 _buffer_start = buffer; |
34 _buffer_start = buffer; |
35 _buffer_end = buffer + length; |
35 _buffer_end = buffer + length; |
36 _current = buffer; |
36 _current = buffer; |
37 _source = source; |
37 _source = source; |
38 _need_verify = false; |
38 _need_verify = need_verify; |
39 } |
39 } |
40 |
40 |
41 u1 ClassFileStream::get_u1(TRAPS) { |
41 u1 ClassFileStream::get_u1(TRAPS) { |
42 if (_need_verify) { |
42 if (_need_verify) { |
43 guarantee_more(1, CHECK_0); |
43 guarantee_more(1, CHECK_0); |
98 if (_need_verify) { |
98 if (_need_verify) { |
99 guarantee_more(length * 4, CHECK); |
99 guarantee_more(length * 4, CHECK); |
100 } |
100 } |
101 _current += length * 4; |
101 _current += length * 4; |
102 } |
102 } |
|
103 |
|
104 #if INCLUDE_JFR |
|
105 |
|
106 u1* ClassFileStream::clone_buffer() const { |
|
107 u1* const new_buffer_start = NEW_RESOURCE_ARRAY(u1, length()); |
|
108 memcpy(new_buffer_start, _buffer_start, length()); |
|
109 return new_buffer_start; |
|
110 } |
|
111 |
|
112 const char* const ClassFileStream::clone_source() const { |
|
113 const char* const src = source(); |
|
114 char* source_copy = NULL; |
|
115 if (src != NULL) { |
|
116 size_t source_len = strlen(src); |
|
117 source_copy = NEW_RESOURCE_ARRAY(char, source_len + 1); |
|
118 strncpy(source_copy, src, source_len + 1); |
|
119 } |
|
120 return source_copy; |
|
121 } |
|
122 |
|
123 ClassFileStream* ClassFileStream::clone() const { |
|
124 u1* const new_buffer_start = clone_buffer(); |
|
125 return new ClassFileStream(new_buffer_start, |
|
126 length(), |
|
127 clone_source(), |
|
128 need_verify()); |
|
129 } |
|
130 #endif // INCLUDE_JFR |