@ Benchmark public ExampleInterface benchmarkJdkProxy ( ) throws Exception { return ( ExampleInterface ) Proxy . newProxyInstance ( newClassLoader ( ) , new Class < ? > [ ] { baseClass } , new InvocationHandler ( ) { public Object invoke ( Object proxy , Method method , Object [ ] args ) { Class < ? > returnType = method . getReturnType ( ) ; if ( returnType . isPrimitive ( ) ) { if ( returnType == boolean . class ) { return defaultBooleanValue ; } else if ( returnType == byte . class ) { return defaultByteValue ; } else if ( returnType == short . class ) { return defaultShortValue ; } else if ( returnType == char . class ) { return defaultCharValue ; } else if ( returnType == int . class ) { return defaultIntValue ; } else if ( returnType == long . class ) { return defaultLongValue ; } else if ( returnType == float . class ) { return defaultFloatValue ; } else { return defaultDoubleValue ; } } else { return defaultReferenceValue ; } } } ) ; }
Performs a benchmark of an interface implementation using the Java Class Library s utilities .