From 4996d5d90b0ffcadb243e4b5ce25a3453f522699 Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 19 May 2016 20:41:09 +0000 Subject: [PATCH] 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. --- .../java/org/grammaticalframework/pgf/Expr.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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);