Skip to content

Commit ab5856b

Browse files
committed
Tracking ASM 5.0.4 development: Fix for ASM issue 317545
Issue: SPR-12470
1 parent a6e7044 commit ab5856b

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

spring-core/src/main/java/org/springframework/asm/ClassReader.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,14 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
11731173
if (labels[label] == null) {
11741174
readLabel(label, labels).status |= Label.DEBUG;
11751175
}
1176-
labels[label].line = readUnsignedShort(v + 12);
1176+
Label l = labels[label];
1177+
while (l.line > 0) {
1178+
if (l.next == null) {
1179+
l.next = new Label();
1180+
}
1181+
l = l.next;
1182+
}
1183+
l.line = readUnsignedShort(v + 12);
11771184
v += 4;
11781185
}
11791186
}
@@ -1288,9 +1295,15 @@ private void readCode(final MethodVisitor mv, final Context context, int u) {
12881295
// visits the label and line number for this offset, if any
12891296
Label l = labels[offset];
12901297
if (l != null) {
1298+
Label next = l.next;
1299+
l.next = null;
12911300
mv.visitLabel(l);
12921301
if ((context.flags & SKIP_DEBUG) == 0 && l.line > 0) {
12931302
mv.visitLineNumber(l.line, l);
1303+
while (next != null) {
1304+
mv.visitLineNumber(next.line, l);
1305+
next = next.next;
1306+
}
12941307
}
12951308
}
12961309

spring-core/src/main/java/org/springframework/asm/Label.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ public class Label {
131131
int status;
132132

133133
/**
134-
* The line number corresponding to this label, if known.
134+
* The line number corresponding to this label, if known. If there are
135+
* several lines, each line is stored in a separate label, all linked via
136+
* their next field (these links are created in ClassReader and removed just
137+
* before visitLabel is called, so that this does not impact the rest of the
138+
* code).
135139
*/
136140
int line;
137141

@@ -154,7 +158,7 @@ public class Label {
154158
* indicates if this reference uses 2 or 4 bytes, and its absolute value
155159
* gives the position of the bytecode instruction. This array is also used
156160
* as a bitset to store the subroutines to which a basic block belongs. This
157-
* information is needed in {@linked MethodWriter#visitMaxs}, after all
161+
* information is needed in {@link MethodWriter#visitMaxs}, after all
158162
* forward references have been resolved. Hence the same array can be used
159163
* for both purposes without problems.
160164
*/
@@ -239,7 +243,8 @@ public class Label {
239243
* The next basic block in the basic block stack. This stack is used in the
240244
* main loop of the fix point algorithm used in the second step of the
241245
* control flow analysis algorithms. It is also used in
242-
* {@link #visitSubroutine} to avoid using a recursive method.
246+
* {@link #visitSubroutine} to avoid using a recursive method, and in
247+
* ClassReader to temporarily store multiple source lines for a label.
243248
*
244249
* @see MethodWriter#visitMaxs
245250
*/

0 commit comments

Comments
 (0)