Skip to content

Commit f7587fa

Browse files
lrytzretronym
authored andcommitted
[asm-cherry-pick] Log names on method size overflow
REBASE NOTE: When applying this change to the ASM 6.2 rebases, I squashed 54bc3ea4 [asm-cherry-pick] Log names on method size overflow e7e86ae7 [asm-cherry-pick] Fix findItemByIndex in case of hash collisions Into this commit and reworked it to store the name in the MethodWriter, rather than trying to recover it from the constant pool, whose API changed significantly in 6.2.
1 parent 448e9fa commit f7587fa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/scala/tools/asm/MethodWriter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ final class MethodWriter extends MethodVisitor {
299299
/** The name_index field of the method_info JVMS structure. */
300300
private final int nameIndex;
301301

302+
private final String name;
303+
302304
/** The descriptor_index field of the method_info JVMS structure. */
303305
private final int descriptorIndex;
304306

@@ -591,6 +593,7 @@ final class MethodWriter extends MethodVisitor {
591593
super(Opcodes.ASM6);
592594
this.symbolTable = symbolTable;
593595
this.accessFlags = "<init>".equals(name) ? access | Constants.ACC_CONSTRUCTOR : access;
596+
this.name = name;
594597
this.nameIndex = symbolTable.addConstantUtf8(name);
595598
this.descriptorIndex = symbolTable.addConstantUtf8(descriptor);
596599
this.descriptor = descriptor;
@@ -2058,7 +2061,7 @@ int computeMethodInfoSize() {
20582061
// For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS.
20592062
if (code.length > 0) {
20602063
if (code.length > 65535) {
2061-
throw new IndexOutOfBoundsException("Method code too large!");
2064+
throw new RuntimeException("Method "+ name+ "'s code too large!");
20622065
}
20632066
symbolTable.addConstantUtf8(Constants.CODE);
20642067
// The Code attribute has 6 header bytes, plus 2, 2, 4 and 2 bytes respectively for max_stack,

0 commit comments

Comments
 (0)