< prev index next >

src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java

Print this page
rev 49242 : 8188240: Reflection Proxy should skip static methods
Contributed-by: David Lloyd <david.lloyd@redhat.com>
Reviewed-by: mchung, sundar, shade


 432          */
 433 
 434         /*
 435          * Record that proxy methods are needed for the hashCode, equals,
 436          * and toString methods of java.lang.Object.  This is done before
 437          * the methods from the proxy interfaces so that the methods from
 438          * java.lang.Object take precedence over duplicate methods in the
 439          * proxy interfaces.
 440          */
 441         addProxyMethod(hashCodeMethod, Object.class);
 442         addProxyMethod(equalsMethod, Object.class);
 443         addProxyMethod(toStringMethod, Object.class);
 444 
 445         /*
 446          * Now record all of the methods from the proxy interfaces, giving
 447          * earlier interfaces precedence over later ones with duplicate
 448          * methods.
 449          */
 450         for (Class<?> intf : interfaces) {
 451             for (Method m : intf.getMethods()) {

 452                 addProxyMethod(m, intf);

 453             }
 454         }
 455 
 456         /*
 457          * For each set of proxy methods with the same signature,
 458          * verify that the methods' return types are compatible.
 459          */
 460         for (List<ProxyMethod> sigmethods : proxyMethods.values()) {
 461             checkReturnTypes(sigmethods);
 462         }
 463 
 464         /* ============================================================
 465          * Step 2: Assemble FieldInfo and MethodInfo structs for all of
 466          * fields and methods in the class we are generating.
 467          */
 468         try {
 469             methods.add(generateConstructor());
 470 
 471             for (List<ProxyMethod> sigmethods : proxyMethods.values()) {
 472                 for (ProxyMethod pm : sigmethods) {




 432          */
 433 
 434         /*
 435          * Record that proxy methods are needed for the hashCode, equals,
 436          * and toString methods of java.lang.Object.  This is done before
 437          * the methods from the proxy interfaces so that the methods from
 438          * java.lang.Object take precedence over duplicate methods in the
 439          * proxy interfaces.
 440          */
 441         addProxyMethod(hashCodeMethod, Object.class);
 442         addProxyMethod(equalsMethod, Object.class);
 443         addProxyMethod(toStringMethod, Object.class);
 444 
 445         /*
 446          * Now record all of the methods from the proxy interfaces, giving
 447          * earlier interfaces precedence over later ones with duplicate
 448          * methods.
 449          */
 450         for (Class<?> intf : interfaces) {
 451             for (Method m : intf.getMethods()) {
 452                 if (!Modifier.isStatic(m.getModifiers())) {
 453                     addProxyMethod(m, intf);
 454                 }
 455             }
 456         }
 457 
 458         /*
 459          * For each set of proxy methods with the same signature,
 460          * verify that the methods' return types are compatible.
 461          */
 462         for (List<ProxyMethod> sigmethods : proxyMethods.values()) {
 463             checkReturnTypes(sigmethods);
 464         }
 465 
 466         /* ============================================================
 467          * Step 2: Assemble FieldInfo and MethodInfo structs for all of
 468          * fields and methods in the class we are generating.
 469          */
 470         try {
 471             methods.add(generateConstructor());
 472 
 473             for (List<ProxyMethod> sigmethods : proxyMethods.values()) {
 474                 for (ProxyMethod pm : sigmethods) {


< prev index next >