mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Fix regression: wrong method chosen as evaluator
Some Java instrumentation tools (e.g. JaCoCo) insert code into classes at runtime. This means that the static eval() method *could* not be the first method of our runtime generated classes anymore. Fix this by explicitly looking for the eval() method.
This commit is contained in:
parent
dd37b94ff9
commit
629affca1c
@ -129,7 +129,7 @@ public abstract class AbstractEvaluatorFactory implements EvaluatorFactory {
|
||||
// reload
|
||||
clazz = loader.loadClass(id);
|
||||
}
|
||||
method = clazz.getDeclaredMethods()[0];
|
||||
method = findEvalMethod(clazz);
|
||||
cache.put(id, method);
|
||||
}
|
||||
|
||||
@ -143,6 +143,26 @@ public abstract class AbstractEvaluatorFactory implements EvaluatorFactory {
|
||||
}
|
||||
}
|
||||
|
||||
protected Method findEvalMethod(Class<?> clazz) {
|
||||
/*
|
||||
* Note 1:
|
||||
* Some Java instrumentation tools (e.g. JaCoCo) insert code into
|
||||
* classes at runtime. This means that the static eval() method *could*
|
||||
* not be the first method of our runtime generated classes anymore.
|
||||
*
|
||||
* Note 2:
|
||||
* We can't use clazz.getDeclaredMethod(name, classes), as the argument
|
||||
* types of the eval() method could be normalized (see createSource()).
|
||||
*/
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if ("eval".equals(method.getName())) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Couldn't find eval method!");
|
||||
}
|
||||
|
||||
protected String toId(String source, Class<?> returnType, Type[] types, Collection<Object> constants) {
|
||||
StringBuilder b = new StringBuilder(128);
|
||||
b.append("Q");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user