I've used protobuf a lot. But today, when I tried to use reflection on a generated protobuf class, I got a class not found exception. (I know it's not a normal protobuf usecase). The class was being used in the same file by other methods, and it's compiled and ran without problems.
import com.foo.protobuf.Bar;
...
void method1() {
Bar.Builder bld = Bar.newBuilder();
...
}
void method2(String clsName) {
// clsName = "com.foo.protobuf.Bar"
Class clsBar = Class.forName(clsName); // CNF Exception here
}
What's wrong with my code? Thanks for any input.
Aucun commentaire:
Enregistrer un commentaire