The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.
--Maxence, Martin
For feedback, please contact Martin
Number of Classes | 1701 |
Number of Domain Exception Types (Thrown or Caught) | 25 |
Number of Domain Checked Exception Types | 3 |
Number of Domain Runtime Exception Types | 22 |
Number of Domain Unknown Exception Types | 0 |
nTh = Number of Throw | 364 |
nTh = Number of Throw in Catch | 45 |
Number of Catch-Rethrow (may not be correct) | 4 |
nC = Number of Catch | 158 |
nCTh = Number of Catch with Throw | 45 |
Number of Empty Catch (really Empty) | 5 |
Number of Empty Catch (with comments) | 5 |
Number of Empty Catch | 10 |
nM = Number of Methods | 7575 |
nbFunctionWithCatch = Number of Methods with Catch | 132 / 7575 |
nbFunctionWithThrow = Number of Methods with Throw | 336 / 7575 |
nbFunctionWithThrowS = Number of Methods with ThrowS | 492 / 7575 |
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) | 404 / 7575 |
P1 = nCTh / nC | 28.5% (0.285) |
P2 = nMC / nM | 1.7% (0.017) |
P3 = nbFunctionWithThrow / nbFunction | 4.4% (0.044) |
P4 = nbFunctionTransmitting / nbFunction | 5.3% (0.053) |
P5 = nbThrowInCatch / nbThrow | 12.4% (0.124) |
R2 = nCatch / nThrow | 0.434 |
A1 = Number of Caught Exception Types From External Libraries | 14 |
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) | 3 |
W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.
Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.
Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.
R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.
A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.
Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.
A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.
A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.
There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.
Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).
Thrown | Not Thrown | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Caught |
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Not caught |
|
The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.
Catch | Finally | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
This table concatenates the results of the previous tables.
Checked/Runtime | Type | Exception | Thrown | Thrown from Catch | Declared | Caught directly | Caught with Thrown |
Caught with Thrown Runtime |
---|---|---|---|---|---|---|---|---|
unknown | (Lib) | . | 0 | 0 | 0 | 0 | 0 | 0 |
runtime | (Domain) |
AbstractParseException
public class AbstractParseException extends RuntimeException { /** * This constructor is used by the method "generateParseException" in the generated parser. Calling this * constructor generates a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean flag "specialConstructor" is also set to * true to indicate that this constructor was used to create this object. This constructor calls its super * class with the empty string to force the "toString" method of parent class "Throwable" to print the * error message in the form: ParseException: <result of getMessage> */ public AbstractParseException(AbstractToken currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; AbstractToken tok = currentToken.getNextToken(); sourcePoint = new SourcePoint(tok.file, tok.beginLine, tok.beginColumn, tok.endColumn); } /** * The following constructors are for use by you for whatever purpose you can think of. Constructing the * exception in this manner makes the exception behave in the normal way - i.e., as documented in the * class "Throwable". The fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use these constructors. */ public AbstractParseException() { specialConstructor = false; } public AbstractParseException(String message) { super(message); specialConstructor = false; } /** * This variable determines which constructor was used to create this object and thereby affects the * semantics of the "getMessage" method (see below). */ protected boolean specialConstructor; /** * This is the last token that has been consumed successfully. If this object has been created due to a * parse error, the token followng this token will (therefore) be the first error token. */ public AbstractToken currentToken; /** * Each entry in this array is an array of integers. Each array of integers represents a sequence of * tokens (by their ordinal values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated parser within which the parse error * occurred. This array is defined in the generated ...Constants interface. */ public String[] tokenImage; /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); public SourcePoint sourcePoint; /** * Used to convert raw characters to their escaped version when these raw version cannot be used as part * of an ASCII string literal. */ protected String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u"); retval.append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } } return retval.toString(); } } |
0 | 0 |
1
|
0 | 0 | 0 |
runtime | (Domain) |
AddressOutOfBoundsException
public class AddressOutOfBoundsException extends Util.Error { public final int data_addr; protected AddressOutOfBoundsException(int da) { super("Segment access error", "illegal access of "+ StringUtil.quote(name) + " at " + StringUtil.addrToString(da)); this.data_addr = da; } }public static class AddressOutOfBoundsException extends Util.Error { public final String segment; public final int data_addr; public final int badPc; protected AddressOutOfBoundsException(String s, int pc, int da) { super("Program error", "at pc = " + StringUtil.addrToString(pc) + ", illegal access of " + StringUtil.quote(s) + " at " + StringUtil.addrToString(da)); this.data_addr = da; this.segment = s; this.badPc = pc; } } |
4
|
4
|
0 | 0 | 0 | 0 |
unknown | (Lib) | ArrayIndexOutOfBoundsException | 0 | 0 | 0 |
6
|
4
|
4 |
runtime | (Domain) |
AsynchronousExit
public static class AsynchronousExit extends RuntimeException { } |
0 | 0 | 0 |
1
|
0 | 0 |
runtime | (Domain) |
BreakPointException
public static class BreakPointException extends RuntimeException { /** * The <code>address</code> field stores the address of the instruction that caused the breakpoint. */ public final int address; /** * The <code>state</code> field stores a reference to the state of the simulator when the breakpoint * occurred, before executing the instruction. */ public final State state; public BreakPointException(int a, State s) { super("breakpoint @ " + StringUtil.addrToString(a) + " reached"); address = a; state = s; } } |
1
|
0 | 0 |
2
|
0 | 0 |
unknown | (Lib) | ClassNotFoundException | 0 | 0 | 0 |
2
|
0 | 0 |
runtime | (Domain) |
Error
public static class Error extends java.lang.Error { protected final String message, param; public static boolean STACKTRACES; public Error(String p) { super(p); message = "Error"; param = p; } public Error(String n, String p) { super(n); message = n; param = p; } public String getParam() { return param; } /** * The <code>report()</code> method generates a textual report that is printed * on the terminal for the user. */ public void report() { Terminal.print(Terminal.ERROR_COLOR, message); Terminal.print(": " + param + '\n'); if (STACKTRACES) { printStackTrace(); } } } |
15
|
2
|
0 |
5
|
0 | 0 |
checked | (Lib) | Exception | 0 | 0 |
42
|
12
|
3
|
0 |
unknown | (Lib) | FileNotFoundException | 0 | 0 |
3
|
1
|
0 | 0 |
checked | (Domain) |
FormatError
public class FormatError extends Exception { } |
2
|
0 |
4
|
2
|
0 | 0 |
checked | (Lib) | IOException |
3
|
0 |
76
|
74
|
26
|
0 |
unknown | (Lib) | IllegalAccessException | 0 | 0 | 0 |
1
|
0 | 0 |
runtime | (Domain) |
ImmediateRequired
public static class ImmediateRequired extends RuntimeException { public final LegacyOperand operand; ImmediateRequired(LegacyOperand o) { super("immediate required"); operand = o; } } |
2
|
0 | 0 |
1
|
0 | 0 |
unknown | (Lib) | InstantiationException | 0 | 0 | 0 |
1
|
0 | 0 |
runtime | (Domain) |
InternalError
public static class InternalError extends Error { private String category; public InternalError(String param) { super(param); category = "Internal Error"; } public InternalError(String c, String param) { super(param); category = c; } public void report() { Terminal.print(Terminal.ERROR_COLOR, category); Terminal.print(": " + param + '\n'); printStackTrace(); } } |
1
|
0 | 0 | 0 | 0 | 0 |
unknown | (Lib) | InterruptedException | 0 | 0 |
7
|
7
|
4
|
0 |
runtime | (Domain) |
InvalidImmediate
public static class InvalidImmediate extends InvalidOperand { /** * The <code>low</code> field stores the lowest value that is allowed for this operand. */ public final int low; /** * The <code>high</code> field stores the highest value that is allowed for this operand. */ public final int high; /** * The <code>value</code> field stores the actual value that was passed during the attempeted * construction of this instruction. */ public final int value; public InvalidImmediate(int num, int v, int l, int h) { super(num, "value out of required range [" + l + ", " + h + ']'); low = l; high = h; value = v; } } |
1
|
0 | 0 |
2
|
0 | 0 |
checked | (Domain) |
InvalidInstruction
public static class InvalidInstruction extends Exception { InvalidInstruction(int pc) { super("Invalid instruction at " + pc); } }public class InvalidInstruction extends Exception { public final int pc; public final int word1; InvalidInstruction(int word1, int pc) { super("Invalid Instruction at "+ StringUtil.addrToString(pc)); this.pc = pc; this.word1 = word1; } }public static class InvalidInstruction extends Exception { InvalidInstruction(int pc) { super("Invalid instruction at "+pc); } } |
3
|
0 |
159
|
1
|
0 | 0 |
runtime | (Domain) |
InvalidOperand
public static class InvalidOperand extends RuntimeException { /** * The <code>number</code> field of the <code>InvalidOperand</code> instance records which operand * this error refers to. For example, if the first operand was the source of the problem, then this * field will be set to 1. */ public final int number; InvalidOperand(int num, String msg) { super("invalid operand #" + num + ": " + msg); number = num; } } |
0 | 0 | 0 | 0 | 0 | 0 |
runtime | (Domain) |
InvalidRegister
public static class InvalidRegister extends InvalidOperand { /** * The <code>set</code> field records the expected register set for the operand. */ public final LegacyRegister.Set set; /** * The <code>register</code> field records the offending register that was found not to be in the * expected register set. */ public final LegacyRegister register; public InvalidRegister(int num, LegacyRegister reg, LegacyRegister.Set s) { super(num, "must be one of " + s.contents); set = s; register = reg; } } |
1
|
0 | 0 |
1
|
0 | 0 |
runtime | (Domain) |
LookaheadSuccess
private static class LookaheadSuccess extends Error { }private static final class LookaheadSuccess extends Error { } |
0 | 0 | 0 |
15
|
0 | 0 |
unknown | (Lib) | NoSuchElementException |
6
|
0 | 0 |
2
|
2
|
0 |
runtime | (Domain) |
NoSuchInstructionException
public static class NoSuchInstructionException extends Util.Error { public final int badPc; protected NoSuchInstructionException(int pc) { super("Program error", "attempt to execute non-existant instruction at " + StringUtil.addrToString(pc)); this.badPc = pc; } } |
1
|
0 | 0 | 0 | 0 | 0 |
unknown | (Lib) | NumberFormatException | 0 | 0 | 0 |
2
|
0 | 0 |
unknown | (Lib) | OutOfMemoryError | 0 | 0 | 0 |
2
|
0 | 0 |
runtime | (Domain) |
PCAlignmentException
public static class PCAlignmentException extends Util.Error { public final int badPc; protected PCAlignmentException(int pc) { super("Program error", "PC misaligned at " + StringUtil.addrToString(pc)); this.badPc = pc; } } |
0 | 0 | 0 | 0 | 0 | 0 |
runtime | (Domain) |
PCOutOfBoundsException
public static class PCOutOfBoundsException extends Util.Error { public final int badPc; protected PCOutOfBoundsException(int pc) { super("Program error", "PC out of bounds at " + StringUtil.addrToString(pc)); this.badPc = pc; } } |
0 | 0 | 0 | 0 | 0 | 0 |
runtime | (Domain) |
ParseException
public class ParseException extends AbstractParseException { /** * This constructor is used by the method "generateParseException" in the generated parser. Calling this * constructor generates a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean flag "specialConstructor" is also set to * true to indicate that this constructor was used to create this object. This constructor calls its super * class with the empty string to force the "toString" method of parent class "Throwable" to print the * error message in the form: ParseException: <result of getMessage> */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever purpose you can think of. Constructing the * exception in this manner makes the exception behave in the normal way - i.e., as documented in the * class "Throwable". The fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use these constructors. */ public ParseException() { specialConstructor = false; } /** * This method has the standard behavior when this object has been created using the standard * constructors. Otherwise, it uses "currentToken" and "expectedTokenSequences" to generate a parse error * message and returns it. If this object has been created due to a parse error, and you do not catch it * (it gets thrown from the parser), then this method is called during the printing of the final stack * trace, and hence the correct error message gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } String expected = ""; int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected += tokenImage[expectedTokenSequences[i][j]] + ' '; } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected += "..."; } expected += eol + " "; } String retval = "Encountered \""; Token tok = ((Token)currentToken).next; Token next = tok; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += add_escapes(tok.image); tok = tok.next; } retval += "\" at line " + next.beginLine + ", column " + next.beginColumn; retval += '.' + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected; return retval; } /** * Used to convert raw characters to their escaped version when these raw version cannot be used as part * of an ASCII string literal. */ protected String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } } return retval.toString(); } }public class ParseException extends AbstractParseException { /** * This constructor is used by the method "generateParseException" in the generated parser. Calling this * constructor generates a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean flag "specialConstructor" is also set to * true to indicate that this constructor was used to create this object. This constructor calls its super * class with the empty string to force the "toString" method of parent class "Throwable" to print the * error message in the form: ParseException: <result of getMessage> */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal) { super(currentTokenVal, expectedTokenSequencesVal, tokenImageVal); } /** * The following constructors are for use by you for whatever purpose you can think of. Constructing the * exception in this manner makes the exception behave in the normal way - i.e., as documented in the * class "Throwable". The fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use these constructors. */ public ParseException() { } /** * This method has the standard behavior when this object has been created using the standard * constructors. Otherwise, it uses "currentToken" and "expectedTokenSequences" to generate a parse error * message and returns it. If this object has been created due to a parse error, and you do not catch it * (it gets thrown from the parser), then this method is called during the printing of the final stack * trace, and hence the correct error message gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } String expected = ""; int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected += tokenImage[expectedTokenSequences[i][j]] + ' '; } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected += "..."; } expected += eol + " "; } String retval = "Encountered \""; Token tok = ((Token)currentToken).next; Token next = tok; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += add_escapes(tok.image); tok = tok.next; } retval += "\" at line " + next.beginLine + ", column " + next.beginColumn; retval += '.' + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected; return retval; } }public class ParseException extends Exception { /** * This constructor is used by the method "generateParseException" in the generated parser. Calling this * constructor generates a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean flag "specialConstructor" is also set to * true to indicate that this constructor was used to create this object. This constructor calls its super * class with the empty string to force the "toString" method of parent class "Throwable" to print the * error message in the form: ParseException: <result of getMessage> */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever purpose you can think of. Constructing the * exception in this manner makes the exception behave in the normal way - i.e., as documented in the * class "Throwable". The fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use these constructors. */ public ParseException() { specialConstructor = false; } public ParseException(String message) { super(message); specialConstructor = false; } /** * This variable determines which constructor was used to create this object and thereby affects the * semantics of the "getMessage" method (see below). */ protected boolean specialConstructor; /** * This is the last token that has been consumed successfully. If this object has been created due to a * parse error, the token followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array of integers represents a sequence of * tokens (by their ordinal values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated parser within which the parse error * occurred. This array is defined in the generated ...Constants interface. */ public String[] tokenImage; /** * This method has the standard behavior when this object has been created using the standard * constructors. Otherwise, it uses "currentToken" and "expectedTokenSequences" to generate a parse error * message and returns it. If this object has been created due to a parse error, and you do not catch it * (it gets thrown from the parser), then this method is called during the printing of the final stack * trace, and hence the correct error message gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } String expected = ""; int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected += tokenImage[expectedTokenSequences[i][j]] + ' '; } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected += "..."; } expected += eol + " "; } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += add_escapes(tok.image); tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += '.' + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected; return retval; } /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version when these raw version cannot be used as part * of an ASCII string literal. */ protected String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } } return retval.toString(); } } |
69
|
0 |
195
|
0 | 0 | 0 |
runtime | (Domain) |
RegisterRequired
public static class RegisterRequired extends RuntimeException { public final LegacyOperand operand; RegisterRequired(LegacyOperand o) { super("register required"); operand = o; } } |
1
|
0 | 0 |
1
|
0 | 0 |
runtime | (Lib) | RuntimeException |
2
|
2
|
0 | 0 | 0 | 0 |
runtime | (Domain) |
SourceError
public class SourceError extends Util.Error { /** * The <code>point</code> field stores a reference to the point in the file * where the error occured. */ public final SourcePoint point; /** * The <code>errorType</code> field stores a string representing the type * of the error. */ protected final String errorType; /** * The <code>errparams</code> field stores a list of parameters to the error * that might represent the name of the missing variable, expected types, etc. */ protected final String[] errparams; public static boolean REPORT_TYPE = false; /** * The default constructor for a source error accepts an error type, a program * point which indicates the location in a file where the error occured, a message, * and a list of parameters to the error (such as the name of a class or method * where the error occurred). * * @param type a string that indicates the type of error that occured such as * "Undefined Variable" * @param p the point in the file where the error occurred * @param msg a short message reported to the user that explains the error * @param ps a list of parameters to the error such as the name of the variable * that is undeclared, etc. */ public SourceError(String type, SourcePoint p, String msg, String[] ps) { super(msg, null); errorType = type; point = p; errparams = ps; } /** * The <code>report()</code> method generates a textual report of this error * for the user. For source errors, this method will report the file, line number, * and column number where this error occurred. */ public void report() { SourcePoint pt = point == null ? new SourcePoint("*unknown*", 0, 0, 0, 0) : point; pt.report(); Terminal.print(" "); Terminal.printRed(errorType); Terminal.print(": "); Terminal.print(message); Terminal.print("\n"); if (STACKTRACES) { printStackTrace(); } } public boolean equals(Object o) { if (this == o) return true; return o instanceof String && errorType.equals(o); } /** * The <code>getErrorType()</code> method returns a string representing the type of the * error. * * @return a string that represents the type of the error */ public String getErrorType() { return errorType; } /** * The <code>getErrorParams()</code> method returns a reference to the parameters to * the error. * * @return a reference to an array that contains the parameters to the error, if any */ public String[] getErrorParams() { return errparams; } } |
4
|
0 | 0 | 0 | 0 | 0 |
runtime | (Domain) |
SourceException
public class SourceException extends SourceError { /** * The <code>trace</code> field stores a reference to the stack trace corresponding * to where the source exception ocurred. */ public final StackTrace trace; /** * The default constructor for a source error accepts an error type, a program * point which indicates the location in a file where the error occured, a message, * and a list of parameters to the error (such as the name of a class or method * where the error occurred). * * @param type a string that indicates the type of error that occured such as * "Undefined Variable" * @param p the point in the file where the error occurred * @param msg a short message reported to the user that explains the error * @param ps a list of parameters to the error such as the name of the variable * that is undeclared, etc. */ public SourceException(String type, StackTrace p, String msg, String[] ps) { super(type, p == null ? null : p.getSourcePoint(), msg, null); trace = p; } /** * The <code>report()</code> method generates a textual report of this error * for the user. For source errors, this method will report the file, line number, * and column number where this error occurred. */ public void report() { Terminal.print(""); Terminal.printRed(errorType); Terminal.println(": " + message + ' '); for (StackTrace tr = trace; tr != null; tr = tr.prev) { Terminal.print("\t"); Terminal.print("in "); Terminal.printGreen(tr.getMethod() + ' '); SourcePoint p = tr.getSourcePoint(); if (p != null) p.report(); Terminal.nextln(); } } } |
0 | 0 | 0 | 0 | 0 | 0 |
checked | (Lib) | Throwable | 0 | 0 |
1
|
9
|
3
|
2 |
runtime | (Domain) |
TimeoutException
public static class TimeoutException extends RuntimeException { /** * The <code>address</code> field stores the address of the next instruction to be executed after the * timeout. */ public final int address; /** * The <code>state</code> field stores the state of the simulation at the point at which the timeout * occurred. */ public final State state; /** * The <code>timeout</code> field stores the value (in clock cycles) of the timeout that occurred. */ public final long timeout; public TimeoutException(int a, State s, long t, String l) { super("timeout @ " + StringUtil.addrToString(a) + " reached after " + t + ' ' + l); address = a; state = s; timeout = t; } } |
1
|
0 | 0 |
2
|
0 | 0 |
runtime | (Domain) |
TokenMgrError
public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Replaces unprintable characters by their espaced (or unicode escaped) equivalents in the given string */ protected static String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the token manager to indicate a lexical * error. Parameters : EOFSeen : indicates if EOF caused the lexicl error curLexState : lexical state * in which this error occured errorLine : line number when the error occured errorColumn : column * number when the error occured errorAfter : prefix that was seen before this error occured curchar : * the offending character Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return "Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : '\"' + addEscapes(String.valueOf(curChar)) + '\"' + " (" + (int) curChar + "), ") + "after : \"" + addEscapes(errorAfter) + '\"'; } /* * Constructors of various flavors follow. */ public TokenMgrError(String message, int reason) { super(message); } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } }public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Replaces unprintable characters by their espaced (or unicode escaped) equivalents in the given string */ protected static String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the token manager to indicate a lexical * error. Parameters : EOFSeen : indicates if EOF caused the lexicl error curLexState : lexical state * in which this error occured errorLine : line number when the error occured errorColumn : column * number when the error occured errorAfter : prefix that was seen before this error occured curchar : * the offending character Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return "Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : '\"' + addEscapes(String.valueOf(curChar)) + '\"' + " (" + (int) curChar + "), ") + "after : \"" + addEscapes(errorAfter) + '\"'; } /* * Constructors of various flavors follow. */ public TokenMgrError(String message, int reason) { super(message); } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } }public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * An attempt wass made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their espaced (or unicode escaped) equivalents in the given string */ protected static String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0: continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the token manager to indicate a lexical * error. Parameters : EOFSeen : indicates if EOF caused the lexicl error curLexState : lexical state * in which this error occured errorLine : line number when the error occured errorColumn : column * number when the error occured errorAfter : prefix that was seen before this error occured curchar : * the offending character Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? "<EOF> " : ('\"' + addEscapes(String.valueOf(curChar)) + '\"') + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + '\"'); } /* * Constructors of various flavors follow. */ public TokenMgrError() { } public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } |
6
|
0 | 0 | 0 | 0 | 0 |
checked | (Domain) |
UnboundedStackException
private class UnboundedStackException extends Exception { Path path; UnboundedStackException(Path p) { path = p; } } |
1
|
0 |
1
|
2
|
1
|
0 |
runtime | (Domain) |
Unexpected
public static class Unexpected extends Error { public final Throwable thrown; public Unexpected(Throwable t) { super(StringUtil.quote(t.getClass())); thrown = t; } public void report() { Terminal.print(Terminal.ERROR_COLOR, "Unexpected exception"); Terminal.print(": " + param + '\n'); thrown.printStackTrace(); } public void rethrow() throws Throwable { throw thrown; } } |
0 | 0 | 0 | 0 | 0 | 0 |
unknown | (Lib) | UnsupportedEncodingException | 0 | 0 |
6
|
2
|
2
|
2 |
unknown | (Lib) | UnsupportedLookAndFeelException | 0 | 0 | 0 |
1
|
0 | 0 |
runtime | (Domain) |
WrongNumberOfOperands
public static class WrongNumberOfOperands extends RuntimeException { public final int expected; public final int found; WrongNumberOfOperands(int f, int e) { super("wrong number of operands, expected " + e + " and found " + f); expected = e; found = f; } } |
1
|
0 | 0 |
1
|
0 | 0 |
nF = Number of Finally | 17 |
nF = Number of Try-Finally (without catch) | 0 |
Number of Methods with Finally (nMF) | 17 / 7575 (0.2%) |
Number of Finally with a Continue | 0 |
Number of Finally with a Return | 0 |
Number of Finally with a Throw | 0 |
Number of Finally with a Break | 0 |
Number of different exception types thrown | 20 |
Number of Domain exception types thrown | 17 |
Number of different exception types caught | 27 |
Number of Domain exception types caught | 13 |
Number of exception declarations in signatures | 500 |
Number of different exceptions types declared in method signatures | 11 |
Number of library exceptions types declared in method signatures | 6 |
Number of Domain exceptions types declared in method signatures | 5 |
Number of Catch with a continue | 3 |
Number of Catch with a return | 55 |
Number of Catch with a Break | 0 |
nbIf = Number of If | 3663 |
nbFor = Number of For | 579 |
Number of Method with an if | 1604 / 7575 |
Number of Methods with a for | 447 / 7575 |
Number of Method starting with a try | 31 / 7575 (0.4%) |
Number of Expressions | 77404 |
Number of Expressions in try | 1192 (1.5%) |