diff options
| author | krasimir <krasimir@chalmers.se> | 2016-05-19 20:41:09 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2016-05-19 20:41:09 +0000 |
| commit | 4996d5d90b0ffcadb243e4b5ce25a3453f522699 (patch) | |
| tree | 21fc0a5bcdac85964d71ab08efc4b0e3d192741c /src/runtime/java/org | |
| parent | 214d1b1e70dbb95bea553f963b0cd07d67592221 (diff) | |
the constructor for expressions in the Java runtime now checks for null arguments. This means that a potential problem is detected earlier before we jump into the JNI code.
Diffstat (limited to 'src/runtime/java/org')
| -rw-r--r-- | src/runtime/java/org/grammaticalframework/pgf/Expr.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/java/org/grammaticalframework/pgf/Expr.java b/src/runtime/java/org/grammaticalframework/pgf/Expr.java index c8e6af224..b23e10562 100644 --- a/src/runtime/java/org/grammaticalframework/pgf/Expr.java +++ b/src/runtime/java/org/grammaticalframework/pgf/Expr.java @@ -23,6 +23,9 @@ public class Expr implements Serializable { /** Constructs an expression which represents a string literal */ public Expr(String s) { + if (s == null) + throw new IllegalArgumentException("s == null"); + this.pool = new Pool(); this.master = null; this.ref = initStringLit(s, pool.ref); @@ -33,6 +36,13 @@ public class Expr implements Serializable { * @param args the arguments for the function. */ public Expr(String fun, Expr... args) { + if (fun == null) + throw new IllegalArgumentException("fun == null"); + for (int i = 0; i < args.length; i++) { + if (args[i] == null) + throw new IllegalArgumentException("the "+i+"th argument is null"); + } + this.pool = new Pool(); this.master = Arrays.copyOf(args, args.length); this.ref = initApp(fun, args, pool.ref); |
