This fixes an off-by-one for the Java sources. If the condition is <=, the body will read after the end of the array and throw a bounds exception. This only occurs in the situation of printing an exception that has occurred at exactly the last character.
diff --git a/node_modules/canopy/templates/java/Parser.java b/node_modules/canopy/templates/java/Parser.java
index 8d38b7a..46563ed 100644
--- a/node_modules/canopy/templates/java/Parser.java
+++ b/node_modules/canopy/templates/java/Parser.java
@@ -27,7 +27,7 @@ public class {{name}} extends Grammar {
String[] lines = input.split("\n");
int lineNo = 0, position = 0;
- while (position <= offset) {
+ while (position < offset) {
position += lines[lineNo].length() + 1;
lineNo += 1;
}
This fixes an off-by-one for the Java sources. If the condition is
<=
, the body will read after the end of the array and throw a bounds exception. This only occurs in the situation of printing an exception that has occurred at exactly the last character.