Skip to content

Commit e7a1fb5

Browse files
committed
Changes in Javadoc comments and @nonnegative annotations only.
1 parent d8f3490 commit e7a1fb5

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

main/src/mockit/asm/util/BytecodeReader.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class BytecodeReader
1919
@Nonnull public final int[] items;
2020

2121
/**
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).
2525
*/
2626
@Nonnull private final String[] strings;
2727

@@ -91,16 +91,17 @@ protected BytecodeReader(@Nonnull BytecodeReader another) {
9191
/**
9292
* Reads an unsigned <tt>byte</tt> value in {@link #code}, incrementing {@link #codeIndex} by 1.
9393
*/
94+
@Nonnegative
9495
public final int readUnsignedByte() {
9596
return code[codeIndex++] & 0xFF;
9697
}
9798

9899
/**
99100
* Reads an unsigned byte value in {@link #code}.
100101
*
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}
103103
*/
104+
@Nonnegative
104105
protected final int readUnsignedByte(@Nonnegative int u1CodeIndex) {
105106
return code[u1CodeIndex] & 0xFF;
106107
}
@@ -136,13 +137,14 @@ public final int readUnsignedShort() {
136137
/**
137138
* Reads an unsigned short value in {@link #code}.
138139
*
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}
141141
*/
142142
@Nonnegative
143143
protected final int readUnsignedShort(@Nonnegative int u2CodeIndex) {
144144
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;
146148
}
147149

148150
/**
@@ -156,8 +158,7 @@ protected final short readShort() {
156158
/**
157159
* Reads a signed short value in {@link #code}.
158160
*
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}
161162
*/
162163
protected final short readShort(@Nonnegative int u2CodeIndex) {
163164
//noinspection NumericCastThatLosesPrecision
@@ -181,8 +182,7 @@ public final int readInt() {
181182
/**
182183
* Reads a signed int value in {@link #code}.
183184
*
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}
186186
*/
187187
protected final int readInt(@Nonnegative int s4CodeIndex) {
188188
byte[] b = code;
@@ -203,8 +203,7 @@ public final long readLong() {
203203
/**
204204
* Reads a signed long value in {@link #code}.
205205
*
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}
208207
*/
209208
protected final long readLong(@Nonnegative int s8CodeIndex) {
210209
long l1 = readInt(s8CodeIndex);
@@ -235,8 +234,7 @@ protected final float readFloat(@Nonnegative int s4CodeIndex) {
235234
/**
236235
* Reads an UTF8 string in {@link #code}.
237236
*
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
240238
*/
241239
@Nonnull @SuppressWarnings("CharUsedInArithmeticContext")
242240
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
282280
/**
283281
* Reads an UTF8 string constant pool item in {@link #code}, incrementing {@link #codeIndex} by 2.
284282
*
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
286284
*/
287285
@Nullable
288286
protected final String readUTF8() {
@@ -298,8 +296,8 @@ protected final String readUTF8() {
298296
/**
299297
* Reads an UTF8 string constant pool item in {@link #code}.
300298
*
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
303301
*/
304302
@Nullable
305303
protected final String readUTF8(@Nonnegative int u2CodeIndex) {
@@ -375,9 +373,9 @@ protected final Object readConstItem(@Nonnegative int u2CodeIndex) {
375373
/**
376374
* Reads a numeric or string constant pool item in {@link #code}.
377375
*
378-
* @param itemIndex the index of a constant pool item.
376+
* @param itemIndex the index of a constant pool item
379377
* @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
381379
*/
382380
@Nonnull
383381
protected final Object readConst(@Nonnegative int itemIndex) {
@@ -471,4 +469,4 @@ public final int readItem(@Nonnegative int u2CodeIndex) {
471469
int itemIndex = readUnsignedShort(u2CodeIndex);
472470
return items[itemIndex];
473471
}
474-
}
472+
}

0 commit comments

Comments
 (0)