@@ -19,9 +19,9 @@ public class BytecodeReader
19
19
@ Nonnull public final int [] items ;
20
20
21
21
/**
22
- * The String objects corresponding to the CONSTANT_Utf8 items. This cache avoids multiple parsing of a given CONSTANT_Utf8 constant pool
23
- * item, which GREATLY improves performances (by a factor 2 to 3). This caching strategy could be extended to all constant pool items,
24
- * but its benefit would not be so great for these items (because they are much less expensive to parse than CONSTANT_Utf8 items).
22
+ * The String objects corresponding to the CONSTANT_Utf8 items. This cache avoids multiple parsing of a given CONSTANT_Utf8 constant pool item,
23
+ * which GREATLY improves performances (by a factor 2 to 3). This caching strategy could be extended to all constant pool items, but its benefit
24
+ * would not be so great for these items (because they are much less expensive to parse than CONSTANT_Utf8 items).
25
25
*/
26
26
@ Nonnull private final String [] strings ;
27
27
@@ -91,16 +91,17 @@ protected BytecodeReader(@Nonnull BytecodeReader another) {
91
91
/**
92
92
* Reads an unsigned <tt>byte</tt> value in {@link #code}, incrementing {@link #codeIndex} by 1.
93
93
*/
94
+ @ Nonnegative
94
95
public final int readUnsignedByte () {
95
96
return code [codeIndex ++] & 0xFF ;
96
97
}
97
98
98
99
/**
99
100
* Reads an unsigned byte value in {@link #code}.
100
101
*
101
- * @param u1CodeIndex the start index of the value to be read in {@link #code}.
102
- * @return the read value.
102
+ * @param u1CodeIndex the start index of the value to be read in {@link #code}
103
103
*/
104
+ @ Nonnegative
104
105
protected final int readUnsignedByte (@ Nonnegative int u1CodeIndex ) {
105
106
return code [u1CodeIndex ] & 0xFF ;
106
107
}
@@ -136,13 +137,14 @@ public final int readUnsignedShort() {
136
137
/**
137
138
* Reads an unsigned short value in {@link #code}.
138
139
*
139
- * @param u2CodeIndex the start index of the value to be read in {@link #code}.
140
- * @return the read value.
140
+ * @param u2CodeIndex the start index of the value to be read in {@link #code}
141
141
*/
142
142
@ Nonnegative
143
143
protected final int readUnsignedShort (@ Nonnegative int u2CodeIndex ) {
144
144
byte [] b = code ;
145
- return ((b [u2CodeIndex ] & 0xFF ) << 8 ) | (b [u2CodeIndex + 1 ] & 0xFF );
145
+ int byte0 = (b [u2CodeIndex ] & 0xFF ) << 8 ;
146
+ int byte1 = b [u2CodeIndex + 1 ] & 0xFF ;
147
+ return byte0 | byte1 ;
146
148
}
147
149
148
150
/**
@@ -156,8 +158,7 @@ protected final short readShort() {
156
158
/**
157
159
* Reads a signed short value in {@link #code}.
158
160
*
159
- * @param u2CodeIndex the start index of the value to be read in {@link #code}.
160
- * @return the read value.
161
+ * @param u2CodeIndex the start index of the value to be read in {@link #code}
161
162
*/
162
163
protected final short readShort (@ Nonnegative int u2CodeIndex ) {
163
164
//noinspection NumericCastThatLosesPrecision
@@ -181,8 +182,7 @@ public final int readInt() {
181
182
/**
182
183
* Reads a signed int value in {@link #code}.
183
184
*
184
- * @param s4CodeIndex the start index of the value to be read in {@link #code}.
185
- * @return the read value.
185
+ * @param s4CodeIndex the start index of the value to be read in {@link #code}
186
186
*/
187
187
protected final int readInt (@ Nonnegative int s4CodeIndex ) {
188
188
byte [] b = code ;
@@ -203,8 +203,7 @@ public final long readLong() {
203
203
/**
204
204
* Reads a signed long value in {@link #code}.
205
205
*
206
- * @param s8CodeIndex the start index of the value to be read in {@link #code}.
207
- * @return the read value.
206
+ * @param s8CodeIndex the start index of the value to be read in {@link #code}
208
207
*/
209
208
protected final long readLong (@ Nonnegative int s8CodeIndex ) {
210
209
long l1 = readInt (s8CodeIndex );
@@ -235,8 +234,7 @@ protected final float readFloat(@Nonnegative int s4CodeIndex) {
235
234
/**
236
235
* Reads an UTF8 string in {@link #code}.
237
236
*
238
- * @param itemIndex index in {@link #items} for the UTF8 string to be read.
239
- * @return the String corresponding to the specified UTF8 string.
237
+ * @param itemIndex index in {@link #items} for the UTF8 string to be read
240
238
*/
241
239
@ Nonnull @ SuppressWarnings ("CharUsedInArithmeticContext" )
242
240
private String readUTF (@ Nonnegative int itemIndex ) {
@@ -282,7 +280,7 @@ else if (st == 1) { // byte 2 of 2-byte char or byte 3 of 3-byte char
282
280
/**
283
281
* Reads an UTF8 string constant pool item in {@link #code}, incrementing {@link #codeIndex} by 2.
284
282
*
285
- * @return the String corresponding to the UTF8 item, or <tt>null</tt> if {@link #codeIndex} points to an item whose value is zero.
283
+ * @return the String corresponding to the UTF8 item, or <tt>null</tt> if {@link #codeIndex} points to an item whose value is zero
286
284
*/
287
285
@ Nullable
288
286
protected final String readUTF8 () {
@@ -298,8 +296,8 @@ protected final String readUTF8() {
298
296
/**
299
297
* Reads an UTF8 string constant pool item in {@link #code}.
300
298
*
301
- * @param u2CodeIndex the index of an unsigned short value in {@link #code}, whose value is the index of an UTF8 constant pool item.
302
- * @return the String corresponding to the UTF8 item, or <tt>null</tt> if index is zero or points to an item whose value is zero.
299
+ * @param u2CodeIndex the index of an unsigned short value in {@link #code}, whose value is the index of an UTF8 constant pool item
300
+ * @return the String corresponding to the UTF8 item, or <tt>null</tt> if index is zero or points to an item whose value is zero
303
301
*/
304
302
@ Nullable
305
303
protected final String readUTF8 (@ Nonnegative int u2CodeIndex ) {
@@ -375,9 +373,9 @@ protected final Object readConstItem(@Nonnegative int u2CodeIndex) {
375
373
/**
376
374
* Reads a numeric or string constant pool item in {@link #code}.
377
375
*
378
- * @param itemIndex the index of a constant pool item.
376
+ * @param itemIndex the index of a constant pool item
379
377
* @return the {@link Integer}, {@link Float}, {@link Long}, {@link Double}, {@link String}, {@link JavaType} or {@link MethodHandle}
380
- * corresponding to the given constant pool item.
378
+ * corresponding to the given constant pool item
381
379
*/
382
380
@ Nonnull
383
381
protected final Object readConst (@ Nonnegative int itemIndex ) {
@@ -471,4 +469,4 @@ public final int readItem(@Nonnegative int u2CodeIndex) {
471
469
int itemIndex = readUnsignedShort (u2CodeIndex );
472
470
return items [itemIndex ];
473
471
}
474
- }
472
+ }
0 commit comments