Skip to content

Commit 34e3220

Browse files
adriaanmlrytz
authored andcommitted
[asm-cherry-pick] Log names on method size overflow
Cherry-pick of asm-part of 3fa2c97, which contains a test. For class size overflows, scalac's error message already contains the class name (test in 19511d8).
1 parent 2458576 commit 34e3220

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/asm/scala/tools/asm/ClassWriter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,15 @@ private void put(final Item i) {
17461746
items[index] = i;
17471747
}
17481748

1749+
/**
1750+
* Find item that whose index is `index`.
1751+
*/
1752+
public Item findItemByIndex(int index) {
1753+
int i = 0;
1754+
while (i < items.length && (items[i] == null || items[i].index != index)) i++;
1755+
return items[i];
1756+
}
1757+
17491758
/**
17501759
* Puts one byte and two shorts into the constant pool.
17511760
*

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,10 @@ final int getSize() {
20332033
int size = 8;
20342034
if (code.length > 0) {
20352035
if (code.length > 65536) {
2036-
throw new RuntimeException("Method code too large!");
2036+
String nameString = "";
2037+
Item nameItem = cw.findItemByIndex(name);
2038+
if (nameItem != null) nameString = nameItem.strVal1 +"'s ";
2039+
throw new RuntimeException("Method "+ nameString +"code too large!");
20372040
}
20382041
cw.newUTF8("Code");
20392042
size += 18 + code.length + 8 * handlerCount;

0 commit comments

Comments
 (0)