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