Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/prims/jvmtiClassFileReconstituter.hpp
+++ new/src/share/vm/prims/jvmtiClassFileReconstituter.hpp
1 1 /*
2 2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
26 26 #define SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
27 27
28 28 #include "jvmtifiles/jvmtiEnv.hpp"
29 29
30 30
31 31 class JvmtiConstantPoolReconstituter : public StackObj {
32 32 private:
33 33 int _cpool_size;
34 34 SymbolHashMap* _symmap;
35 35 SymbolHashMap* _classmap;
36 36 constantPoolHandle _cpool;
37 37 instanceKlassHandle _ikh;
38 38 jvmtiError _err;
39 39
40 40 protected:
41 41 instanceKlassHandle ikh() { return _ikh; };
42 42 constantPoolHandle cpool() { return _cpool; };
43 43
44 44 u2 symbol_to_cpool_index(Symbol* sym) {
45 45 return _symmap->symbol_to_value(sym);
46 46 }
47 47
48 48 u2 class_symbol_to_cpool_index(Symbol* sym) {
49 49 return _classmap->symbol_to_value(sym);
50 50 }
51 51
52 52 public:
53 53 // Calls to this constructor must be proceeded by a ResourceMark
54 54 // and a HandleMark
55 55 JvmtiConstantPoolReconstituter(instanceKlassHandle ikh){
56 56 set_error(JVMTI_ERROR_NONE);
57 57 _ikh = ikh;
58 58 _cpool = constantPoolHandle(Thread::current(), ikh->constants());
59 59 _symmap = new SymbolHashMap();
60 60 _classmap = new SymbolHashMap();
61 61 _cpool_size = _cpool->hash_entries_to(_symmap, _classmap);
62 62 if (_cpool_size == 0) {
63 63 set_error(JVMTI_ERROR_OUT_OF_MEMORY);
64 64 } else if (_cpool_size < 0) {
65 65 set_error(JVMTI_ERROR_INTERNAL);
66 66 }
67 67 }
68 68
69 69 ~JvmtiConstantPoolReconstituter() {
70 70 if (_symmap != NULL) {
71 71 os::free(_symmap, mtClass);
72 72 _symmap = NULL;
73 73 }
74 74 if (_classmap != NULL) {
75 75 os::free(_classmap, mtClass);
76 76 _classmap = NULL;
77 77 }
78 78 }
79 79
80 80
81 81 void set_error(jvmtiError err) { _err = err; }
82 82 jvmtiError get_error() { return _err; }
83 83
84 84 int cpool_size() { return _cpool_size; }
85 85
86 86 void copy_cpool_bytes(unsigned char *cpool_bytes) {
87 87 if (cpool_bytes == NULL) {
88 88 assert(cpool_bytes != NULL, "cpool_bytes pointer must not be NULL");
89 89 return;
90 90 }
91 91 cpool()->copy_cpool_bytes(cpool_size(), _symmap, cpool_bytes);
92 92 }
93 93 };
94 94
95 95
96 96 class JvmtiClassFileReconstituter : public JvmtiConstantPoolReconstituter {
97 97 private:
98 98 size_t _buffer_size;
99 99 u1* _buffer;
100 100 u1* _buffer_ptr;
101 101 Thread* _thread;
102 102
103 103 enum {
104 104 // initial size should be power of two
105 105 initial_buffer_size = 1024
106 106 };
107 107
108 108 inline Thread* thread() { return _thread; }
109 109
110 110 void write_class_file_format();
111 111 void write_field_infos();
112 112 void write_method_infos();
↓ open down ↓ |
112 lines elided |
↑ open up ↑ |
113 113 void write_method_info(methodHandle method);
114 114 void write_code_attribute(methodHandle method);
115 115 void write_exceptions_attribute(constMethodHandle const_method);
116 116 void write_synthetic_attribute();
117 117 void write_class_attributes();
118 118 void write_source_file_attribute();
119 119 void write_source_debug_extension_attribute();
120 120 u2 line_number_table_entries(methodHandle method);
121 121 void write_line_number_table_attribute(methodHandle method, u2 num_entries);
122 122 void write_local_variable_table_attribute(methodHandle method, u2 num_entries);
123 + void write_local_variable_type_table_attribute(methodHandle method, u2 num_entries);
123 124 void write_stackmap_table_attribute(methodHandle method, int stackmap_table_len);
124 125 u2 inner_classes_attribute_length();
125 126 void write_inner_classes_attribute(int length);
126 127 void write_signature_attribute(u2 generic_signaure_index);
127 128 void write_attribute_name_index(const char* name);
128 129 void write_annotations_attribute(const char* attr_name, typeArrayHandle annos);
129 130
130 131 address writeable_address(size_t size);
131 132 void write_u1(u1 x);
132 133 void write_u2(u2 x);
133 134 void write_u4(u4 x);
134 135 void write_u8(u8 x);
135 136
136 137 public:
137 138 // Calls to this constructor must be proceeded by a ResourceMark
138 139 // and a HandleMark
139 140 JvmtiClassFileReconstituter(instanceKlassHandle ikh) :
140 141 JvmtiConstantPoolReconstituter(ikh) {
141 142 _buffer_size = initial_buffer_size;
142 143 _buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size);
143 144 _thread = Thread::current();
144 145 write_class_file_format();
145 146 };
146 147
147 148 size_t class_file_size() { return _buffer_ptr - _buffer; }
148 149
149 150 u1* class_file_bytes() { return _buffer; }
150 151
151 152 static void copy_bytecodes(methodHandle method, unsigned char* bytecodes);
152 153 };
153 154
154 155 #endif // SHARE_VM_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX