Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Commit d245723

Browse files
lrytzCarsten Varming
authored andcommitted
[asm-cherry-pick] Log names on method size overflow
Cherry-pick of lrytz/scala@34e3220
1 parent 7bb61b5 commit d245723

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

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

1784+
/**
1785+
* Find item that whose index is `index`.
1786+
*/
1787+
public Item findItemByIndex(int index) {
1788+
int i = 0;
1789+
while (i < items.length && (items[i] == null || items[i].index != index)) i++;
1790+
return items[i];
1791+
}
1792+
17841793
/**
17851794
* Puts one byte and two shorts into the constant pool.
17861795
*

src/main/java/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 > 65535) {
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)