src/share/vm/classfile/classFileStream.hpp

changeset 9858
b985cbb00e68
parent 7090
bb239308be67
child 9931
fd44df5e3bc3
equal deleted inserted replaced
9727:c7a3e57fdf4a 9858:b985cbb00e68
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.
55 u1* _current; // Current buffer position 55 u1* _current; // Current buffer position
56 const char* _source; // Source of stream (directory name, ZIP/JAR archive name) 56 const char* _source; // Source of stream (directory name, ZIP/JAR archive name)
57 bool _need_verify; // True if verification is on for the class file 57 bool _need_verify; // True if verification is on for the class file
58 58
59 void truncated_file_error(TRAPS); 59 void truncated_file_error(TRAPS);
60
61 #if INCLUDE_JFR
62 u1* clone_buffer() const;
63 const char* const clone_source() const;
64 #endif
65
60 public: 66 public:
61 // Constructor 67 // Constructor
62 ClassFileStream(u1* buffer, int length, const char* source); 68 ClassFileStream(u1* buffer, int length, const char* source, bool need_verify = false);
63 69
64 // Buffer access 70 // Buffer access
65 u1* buffer() const { return _buffer_start; } 71 u1* buffer() const { return _buffer_start; }
66 int length() const { return _buffer_end - _buffer_start; } 72 int length() const { return _buffer_end - _buffer_start; }
67 u1* current() const { return _current; } 73 u1* current() const { return _current; }
68 void set_current(u1* pos) { _current = pos; } 74 void set_current(u1* pos) { _current = pos; }
75 // for relative positioning
76 juint current_offset() const {
77 return (juint)(_current - _buffer_start);
78 }
69 const char* source() const { return _source; } 79 const char* source() const { return _source; }
70 void set_verify(bool flag) { _need_verify = flag; } 80 void set_verify(bool flag) { _need_verify = flag; }
71 81
72 void check_truncated_file(bool b, TRAPS) { 82 void check_truncated_file(bool b, TRAPS) {
73 if (b) { 83 if (b) {
138 _current += 4 * length; 148 _current += 4 * length;
139 } 149 }
140 150
141 // Tells whether eos is reached 151 // Tells whether eos is reached
142 bool at_eos() const { return _current == _buffer_end; } 152 bool at_eos() const { return _current == _buffer_end; }
153
154 #if INCLUDE_JFR
155 ClassFileStream* clone() const;
156
157 bool need_verify() const { return _need_verify; }
158 #endif
143 }; 159 };
144 160
145 #endif // SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP 161 #endif // SHARE_VM_CLASSFILE_CLASSFILESTREAM_HPP

mercurial