As you can see from Figure 1, the generated code executes much faster than reflection in every case.
从图1中可以看出,不管在什么情况下,生成的代码执行都比反射要快得多。
2
I also wrote a similar timing test program for creating objects using reflection. The differences for this case aren't nearly as significant as for the field and method call cases, though.
In their case, they avoided using reflection by instead working directly with class files, adding code to the classes generated by the compiler in order to provide direct access for the framework.