add null checks to asm constructors
This commit is contained in:
@@ -2,6 +2,7 @@ package jef.asm;
|
||||
|
||||
import jef.serializable.SerializableFunction;
|
||||
import jef.serializable.SerializablePredicate;
|
||||
import jef.util.Check;
|
||||
import lombok.Getter;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -18,18 +19,18 @@ public class AsmParser {
|
||||
private final Method method;
|
||||
|
||||
public AsmParser(SerializablePredicate<?> predicate) {
|
||||
this.lambda = predicate;
|
||||
this.lambda = Check.notNull(predicate, "predicate");
|
||||
this.method = null;
|
||||
}
|
||||
|
||||
public AsmParser(SerializableFunction<?, ?> function) {
|
||||
this.lambda = function;
|
||||
this.lambda = Check.notNull(function, "function");
|
||||
this.method = null;
|
||||
}
|
||||
|
||||
public AsmParser(Method method) {
|
||||
this.lambda = null;
|
||||
this.method = method;
|
||||
this.method = Check.notNull(method, "method");
|
||||
}
|
||||
|
||||
public AsmParseResult parse() throws AsmParseException {
|
||||
@@ -39,7 +40,7 @@ public class AsmParser {
|
||||
} else if (this.method != null) {
|
||||
return parseMethodExpression();
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Illegal state");
|
||||
} catch (Exception e) {
|
||||
throw new AsmParseException("PredicateParser: failed to parse expression: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
@@ -58,11 +59,7 @@ public class AsmParser {
|
||||
cls = Class.forName(classname.replace("/", "."));
|
||||
var is = loader.getResourceAsStream(cls.getName().replace(".", "/") + ".class");
|
||||
|
||||
var cr = new ClassReader(is);
|
||||
var visiter = new FilterClassVisitor(Opcodes.ASM9, lambdaname, args);
|
||||
cr.accept(visiter, 0);
|
||||
|
||||
return visiter.getResult();
|
||||
return parseCommon(is, lambdaname, args);
|
||||
}
|
||||
|
||||
private AsmParseResult parseMethodExpression() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user