我正在使用Javassist庫在運行時加載類。ClassPool.get()在類中拋出NotFoundException,顯然存在?
public class FilterClassGenerator<T, DT> {
private volatile static Long classNameIncrementor = 1L;
private Class<T> listFilterClass;
private Class<DT> dataObjectClass;
public FilterClassGenerator(Class<T> listFilterClass, Class<DT> dataObjectClass) {
this.listFilterClass = listFilterClass;
this.dataObjectClass = dataObjectClass;
}
public T createFilterClass(ApiFilter filter) {
try {
ClassPool pool = ClassPool.getDefault();
CtClass comparison = pool.makeClass("com.frammo.filterClasses." + generateNewClassName());
comparison.setSuperclass(pool.get(listFilterClass.getName()));
// More code
我收到以下錯誤的: comparison.setSuperclass(pool.get(listFilterClass.getName()));
javassist.NotFoundException: com.frammo.stocks.api.simulation.IiiAccountComparisonFilter
但顯然這個類的存在!
package com.frammo.stocks.api.simulation;
// Imports
public abstract class IiiAccountComparisonFilter extends ListComparisonFilter<IiiAccount> {
}
任何想法爲什麼找不到該類?
小錯字'ClassPool.getDefault()insertClassPath(新ClassClassPath(YourCurrentClassName.class)); ' – Eugene