我有一个Android应用程序。
我想扫描包中的所有类以获取指定注释。
我有:
package com.sample.package;
import com.sample.core.Controller;
import com.sample.core.ProtocolId;
@Controller
public class OtherController implements ControllerInterface{
@ProtocolId(id=100)
public void doSomething(){
//do something
}
}
我找到了使用@Controller注释的类,用于指定@ProtocolId编号。
我正在使用Google Reflections library。
以下是我的扫描方式:
package com.sample.package;
import org.reflections.ReflectionUtils;
import org.reflections.Reflections;
import com.sample.core.Controller;
import com.sample.core.ProtocolId;
public class FrontController {
public void executeProperControllerMethodBasedOnId(){
Reflections ref = new Reflections("com.sample.package");
Set<Class<?>> classes = ref.getTypesAnnotatedWith(Controller.class);
System.out.println(classes.size()); //THE SIZE IS 0!!!
//The reflection doesn't worked! It didn't found any class!
}
}
上面的代码没有找到任何使用指定注释注释的类。是 当我使用谷歌反射库时,我想念的东西 的android?