1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
64 u1* _current; // Current buffer position |
64 u1* _current; // Current buffer position |
65 const char* _source; // Source of stream (directory name, ZIP/JAR archive name) |
65 const char* _source; // Source of stream (directory name, ZIP/JAR archive name) |
66 bool _need_verify; // True if verification is on for the class file |
66 bool _need_verify; // True if verification is on for the class file |
67 |
67 |
68 void truncated_file_error(TRAPS); |
68 void truncated_file_error(TRAPS); |
|
69 |
|
70 #if INCLUDE_JFR |
|
71 u1* clone_buffer() const; |
|
72 const char* const clone_source() const; |
|
73 #endif |
|
74 |
69 public: |
75 public: |
70 // Constructor |
76 // Constructor |
71 ClassFileStream(u1* buffer, int length, const char* source); |
77 ClassFileStream(u1* buffer, int length, const char* source, bool need_verify = false); |
72 |
78 |
73 // Buffer access |
79 // Buffer access |
74 u1* buffer() const { return _buffer_start; } |
80 u1* buffer() const { return _buffer_start; } |
75 int length() const { return _buffer_end - _buffer_start; } |
81 int length() const { return _buffer_end - _buffer_start; } |
76 u1* current() const { return _current; } |
82 u1* current() const { return _current; } |
77 void set_current(u1* pos) { _current = pos; } |
83 void set_current(u1* pos) { _current = pos; } |
|
84 // for relative positioning |
|
85 juint current_offset() const { |
|
86 return (juint)(_current - _buffer_start); |
|
87 } |
78 const char* source() const { return _source; } |
88 const char* source() const { return _source; } |
79 void set_verify(bool flag) { _need_verify = flag; } |
89 void set_verify(bool flag) { _need_verify = flag; } |
80 |
90 |
81 void check_truncated_file(bool b, TRAPS) { |
91 void check_truncated_file(bool b, TRAPS) { |
82 if (b) { |
92 if (b) { |
147 _current += 4 * length; |
157 _current += 4 * length; |
148 } |
158 } |
149 |
159 |
150 // Tells whether eos is reached |
160 // Tells whether eos is reached |
151 bool at_eos() const { return _current == _buffer_end; } |
161 bool at_eos() const { return _current == _buffer_end; } |
|
162 |
|
163 #if INCLUDE_JFR |
|
164 ClassFileStream* clone() const; |
|
165 |
|
166 bool need_verify() const { return _need_verify; } |
|
167 #endif |
152 }; |
168 }; |
153 |
169 |
154 #endif // SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP |
170 #endif // SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP |