// // "Inflation" mechanism. Loading bytecodes to implement // Method.invoke() and Constructor.newInstance() currently costs // 3-4x more than an invocation via native code for the first // invocation (though subsequent invocations have been benchmarked // to be over 20x faster). Unfortunately this cost increases // startup time for certain applications that use reflection // intensively (but only once per class) to bootstrap themselves. // To avoid this penalty we reuse the existing JVM entry points // for the first few invocations of Methods and Constructors and // then switch to the bytecode-based implementations. // // Package-private to be accessible to NativeMethodAccessorImpl // and NativeConstructorAccessorImpl privatestaticboolean noInflation = false; privatestaticint inflationThreshold = 15; // ... /** We have to defer full initialization of this class until after the static initializer is run since java.lang.reflect.Method's static initializer (more properly, that for java.lang.reflect.AccessibleObject) causes this class's to be run, before the system properties are set up. */ privatestaticvoidcheckInitted(){ if (initted) return; AccessController.doPrivileged(new PrivilegedAction() { public Object run(){ // Tests to ensure the system properties table is fully // initialized. This is needed because reflection code is // called very early in the initialization process (before // command-line arguments have been parsed and therefore // these user-settable properties installed.) We assume that // if System.out is non-null then the System class has been // fully initialized and that the bulk of the startup code // has been run.
if (System.out == null) { // java.lang.System not yet fully initialized returnnull; }
String val = System.getProperty("sun.reflect.noInflation"); if (val != null && val.equals("true")) { noInflation = true; }
val = System.getProperty("sun.reflect.inflationThreshold"); if (val != null) { try { inflationThreshold = Integer.parseInt(val); } catch (NumberFormatException e) { throw (RuntimeException) new RuntimeException("Unable to parse property sun.reflect.inflationThreshold"). initCause(e); } }
[Loaded testinvoke.A from file:/C:/Users/itliusir/git/test/Test/bin/] [Loaded sun.reflect.NativeMethodAccessorImpl from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.DelegatingMethodAccessorImpl from D:\jdk8\jre\lib\rt.jar] Hello,0 Hello,1 Hello,2 Hello,3 Hello,4 Hello,5 Hello,6 Hello,7 Hello,8 Hello,9 Hello,10 Hello,11 Hello,12 Hello,13 Hello,14 [Loaded sun.reflect.ClassFileConstants from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.AccessorGenerator from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.MethodAccessorGenerator from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.ByteVectorFactory from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.ByteVector from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.ByteVectorImpl from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.ClassFileAssembler from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.UTF8 from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.Label from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.Label$PatchInfo from D:\jdk8\jre\lib\rt.jar] [Loaded java.util.ArrayList$Itr from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.MethodAccessorGenerator$1 from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.ClassDefiner from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.ClassDefiner$1 from D:\jdk8\jre\lib\rt.jar] [Loaded java.util.concurrent.ConcurrentHashMap$ForwardingNode from D:\jdk8\jre\lib\rt.jar] [Loaded sun.reflect.GeneratedMethodAccessor1 from __JVM_DefineClass__] Hello,15 [Loaded java.lang.Shutdown from D:\jdk8\jre\lib\rt.jar] [Loaded java.lang.Shutdown$Lock from D:\jdk8\jre\lib\rt.jar]