diff options
Diffstat (limited to 'src/fjbg/ch')
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java | 25 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JClass.java | 11 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JCode.java | 1 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java | 14 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java | 2 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java | 6 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java | 2 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JMember.java | 1 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java | 8 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JType.java | 2 |
10 files changed, 21 insertions, 51 deletions
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java index cfc4ed00e5..569a9ac272 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java @@ -28,31 +28,6 @@ public class FJBGContext { MINOR_VERSION = minor; } - public static class FJBGWrapper extends RuntimeException { - public String culprit; - public FJBGWrapper(Throwable cause) { - super(cause); - this.culprit = "<unknown>"; - } - public FJBGWrapper(String culprit, Throwable cause) { - super(cause); - this.culprit = culprit; - } - } - - static FJBGWrapper mkFatal(String culprit, Throwable t) { - return new FJBGWrapper(culprit, t); - } - static FJBGWrapper mkFatal(Throwable t) { - return new FJBGWrapper(t); - } - static RuntimeException mkFatal(Object obj) { - return new FJBGWrapper(new java.lang.Error(obj.toString())); - } - static RuntimeException mkFatal(String message) { - return new FJBGWrapper(new java.lang.Error(message)); - } - // Factory methods ////////////////////////////////////////////////////////////////////// diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JClass.java b/src/fjbg/ch/epfl/lamp/fjbg/JClass.java index 3839af4156..0fc604424a 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JClass.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JClass.java @@ -310,15 +310,8 @@ public class JClass extends JMember { stream.writeShort(methods.size()); Iterator methodsIt = methods.iterator(); - while (methodsIt.hasNext()) { - JMethod m = (JMethod)methodsIt.next(); - try { - m.writeTo(stream); - } - catch (Throwable t) { - throw FJBGContext.mkFatal(name + "." + m.getName(), t); - } - } + while (methodsIt.hasNext()) + ((JMethod)methodsIt.next()).writeTo(stream); // Attributes JAttribute.writeTo(attributes, stream); diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java index 2506a06c03..f7d275c8a7 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java @@ -889,6 +889,7 @@ public class JCode { public OffsetTooBigException() { super(); } public OffsetTooBigException(String message) { super(message); } } + protected void checkOffset16(int offset) throws OffsetTooBigException { if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) throw new OffsetTooBigException("offset too big to fit" diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java b/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java index 5ca4f14215..34b38c828d 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java @@ -125,7 +125,7 @@ public class JCodeIterator { else return 4; } else - throw FJBGContext.mkFatal("Unknown size for instruction " + opcode); + throw new Error("Unknown size for instruction " + opcode); } /** @@ -144,7 +144,7 @@ public class JCodeIterator { int npairsPos = pc + 1 + pad4(pc + 1) + 4; return 1 + codeArray.getS4(npairsPos); } else - throw FJBGContext.mkFatal("Unknown successors for instruction " + opcode); + throw new Error("Unknown successors for instruction " + opcode); } /** @@ -185,7 +185,7 @@ public class JCodeIterator { return pc + codeArray.getS4(defaultPos + 2*4 + 4 + 8 * (index - 1)); } default: - throw FJBGContext.mkFatal(""); + throw new Error(); } } @@ -226,7 +226,7 @@ public class JCodeIterator { else return 0; // (IINC) } default : - throw FJBGContext.mkFatal(opcode.toString()); + throw new Error(opcode.toString()); } } else return JType.getTotalSize(opcode.getProducedDataTypes()); @@ -281,7 +281,7 @@ public class JCodeIterator { case JOpcode.cMULTIANEWARRAY : return codeArray.getU1(pc + 3); default: - throw FJBGContext.mkFatal(opcode.toString()); + throw new Error(opcode.toString()); } } } @@ -315,7 +315,7 @@ public class JCodeIterator { return 0; // (IINC) } default: - throw FJBGContext.mkFatal("JOpcode implementation error"); + throw new Error("JOpcode implementation error"); } } } @@ -358,7 +358,7 @@ public class JCodeIterator { // return JOpcode.OPCODES[op].getConsumedDataTypes().length; // else return 0; // (IINC) // case 197 : return codeArray.getU1(pc + 3); // MULTIANEWARRAY -// default : throw FJBGContext.mkFatal("JOpcode implementation error"); +// default : throw new Error("JOpcode implementation error"); // } // } else return opcode.getConsumedDataTypes().length; // } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java index 765411d5fb..0df4498d8e 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java @@ -104,7 +104,7 @@ public class JConstantPool { case 12 : return "Methodref"; case 13 : return "InterfaceMethodref"; case 14 : return "NameAndType"; - default : throw FJBGContext.mkFatal("invalid constant pool tag : " + tag); + default : throw new Error("invalid constant pool tag : " + tag); } } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java index cbb0ce37db..69b522b622 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java @@ -463,7 +463,7 @@ public class JExtendedCode extends JCode { JOpcode[] conv = typeConversions[fromType.getTag() - 4][toType.getTag() - 4]; if (conv == forbidden) { - throw FJBGContext.mkFatal("inconvertible types : " + fromType.toString() + throw new Error("inconvertible types : " + fromType.toString() + " -> " + toType.toString()); } else if (conv != nothingToDo) { for (int i = 0; i < conv.length; i++) { @@ -518,7 +518,7 @@ public class JExtendedCode extends JCode { try { emitGOTO(label); } catch (OffsetTooBigException e) { - throw FJBGContext.mkFatal(e); + throw new Error(e); } } } @@ -532,7 +532,7 @@ public class JExtendedCode extends JCode { try { emitGOTO(targetPC); } catch (OffsetTooBigException e) { - throw FJBGContext.mkFatal(e); + throw new Error(e); } } } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java b/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java index b97657c196..fec7310bdf 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java @@ -110,7 +110,7 @@ abstract public class JFieldOrMethod extends JMember { freeze(); } catch (JCode.OffsetTooBigException e) { - throw FJBGContext.mkFatal(owner.name + "." + name, e); + throw new Error(e); } } stream.writeShort(accessFlags); diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JMember.java b/src/fjbg/ch/epfl/lamp/fjbg/JMember.java index 3b4ce38094..8d082fb90d 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JMember.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JMember.java @@ -13,6 +13,7 @@ import java.util.Iterator; */ abstract public class JMember { + protected boolean frozen = false; protected final FJBGContext context; diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java b/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java index ca144a6b8d..f7ee688784 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java @@ -1201,7 +1201,7 @@ public class JOpcode { case cDUP2_X2: return 6; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } @@ -1220,7 +1220,7 @@ public class JOpcode { case cDUP2_X2: return 4; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } @@ -1240,7 +1240,7 @@ public class JOpcode { case cDUP_X1: return 3; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } @@ -1256,7 +1256,7 @@ public class JOpcode { case cDUP2: case cDUP2_X1: case cPOP2: case cSWAP: return 2; default: - throw FJBGContext.mkFatal(this.toString()); + throw new Error(this.toString()); } } } diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JType.java b/src/fjbg/ch/epfl/lamp/fjbg/JType.java index a62925d1b0..b926a59f5a 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JType.java @@ -100,7 +100,7 @@ abstract public class JType { } catch (IllegalArgumentException e) { throw new IllegalArgumentException("invalid signature " + signature); } catch (IOException e) { - throw FJBGContext.mkFatal(e); + throw new Error(e); } } |