summaryrefslogtreecommitdiff
path: root/src/fjbg/ch/epfl
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2011-05-17 09:51:59 +0000
committerIulian Dragos <jaguarul@gmail.com>2011-05-17 09:51:59 +0000
commita22be1267ace5faa9c16787910ed32227367177d (patch)
tree3cd11dfe13a08f35e7cd5f45e30cf7b73c1029a2 /src/fjbg/ch/epfl
parentb3899406974bb1e2d684e4979a1a1477c0e136fc (diff)
downloadscala-a22be1267ace5faa9c16787910ed32227367177d.tar.gz
scala-a22be1267ace5faa9c16787910ed32227367177d.tar.bz2
scala-a22be1267ace5faa9c16787910ed32227367177d.zip
Error reporting when the generated code size ex...
Error reporting when the generated code size exceeds JVM limits (65,535 bytes per method). Closed #4573. review by extempore.
Diffstat (limited to 'src/fjbg/ch/epfl')
-rw-r--r--src/fjbg/ch/epfl/lamp/fjbg/JCode.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java
index 332cc7c518..d80f9f5f94 100644
--- a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java
+++ b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java
@@ -22,6 +22,8 @@ import ch.epfl.lamp.util.ByteArray;
public class JCode {
protected boolean frozen = false;
+ public static int MAX_CODE_SIZE = 65535;
+
protected final FJBGContext context;
protected final JMethod owner;
@@ -57,8 +59,8 @@ public class JCode {
this.owner = owner;
owner.setCode(this);
int size = stream.readInt();
- if (size >= 65536) // section 4.10
- throw new Error("code size must be less than 65536: " + size);
+ if (size > MAX_CODE_SIZE) // section 4.10
+ throw new Error("code size must be less than " + MAX_CODE_SIZE + ": " + size);
this.codeArray = new ByteArray(stream, size);
}
@@ -97,8 +99,19 @@ public class JCode {
// Freezing
//////////////////////////////////////////////////////////////////////
+ public static class CodeSizeTooBigException extends OffsetTooBigException {
+ public int codeSize;
+
+ public CodeSizeTooBigException(int size) {
+ codeSize = size;
+ }
+ }
+
public void freeze() throws OffsetTooBigException {
assert !frozen;
+
+ if (getSize() > MAX_CODE_SIZE) throw new CodeSizeTooBigException(getSize());
+
patchAllOffset();
codeArray.freeze();
frozen = true;