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

Commit 9971a71

Browse files
adriaanmAdriaan Moors
authored and
Adriaan Moors
committed
Report error on code size overflow, log method name.
We used to silently skip class files that would exceed the JVM's size limits. While rare, this should still be an error. While I was at it, also included the name of the offending method.
1 parent 28dfb7d commit 9971a71

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,12 @@ final int getSize() {
18531853
int size = 8;
18541854
if (code.length > 0) {
18551855
if (code.length > 65536) {
1856-
throw new RuntimeException("Method code too large!");
1856+
String nameString = "";
1857+
int i = 0;
1858+
// find item that corresponds to the index of our name
1859+
while (i < cw.items.length && (cw.items[i] == null || cw.items[i].index != name)) i++;
1860+
if (cw.items[i] != null) nameString = cw.items[i].strVal1 +"'s ";
1861+
throw new RuntimeException("Method "+ nameString +"code too large!");
18571862
}
18581863
cw.newUTF8("Code");
18591864
size += 18 + code.length + 8 * handlerCount;

0 commit comments

Comments
 (0)