JDK-8249939 : Method::isVarargs of dynamic proxy generated method should match the proxy interface method
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-07-22
  • Updated: 2020-07-28
  • Resolved: 2020-07-28
Related Reports
CSR :  
Relates :  
Description
Summary
-------

`Method::isVarargs` of a dynamic proxy generated method should match the proxy interface method.

Problem
-------

`ACC_VARARGS` flag of all dynamic proxy generated methods are always not set even if the method declared in a proxy interface takes a variable number of arguments set.

Solution
--------

If `ACC_VARARGS` flag of a proxy interface method is set, the generated method in the proxy class has the `ACC_VARARGS` flag set.   
If there are two or more proxy interfaces declaring such a method,
it matches the method declared in the first proxy interface. 

Specification
-------------

This CSR documents a behavioral change.    No spec change.  


Comments
Moving to Approved. The new behavior is clearly an improvement. I suppose an additional refinement could be OR-ing over the vararg bits of the override equivalent methods, but since the proxies aren't compiled against, that wouldn't be a help in practice. Do default methods in interfaces cause any proxy complications that aren't already dealt with?
28-07-2020

Checking if there are other method-level or type-level attributes that might be relevant to copy down: * Inherited annotations are *not* relevant since proxies are based off of interfaces and and inherited annotations are only in effect along the superclass chain. * Looking over the various attributes (https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.7), nothing leaps out. * Are there any potential interactions with hidden interfaces?
28-07-2020

A proxy interface can't never be hidden since as a hidden interface or class cannot be named in another class. This raises a good question whether `Proxy::newProxyInstance` should throw IAE if a given proxy interface is hidden. I will file a separate JBS issue to follow up. Update: `Proxy::newProxyInstance` already throws IAE if a proxy interface cannot be found by a class loader. The implementation throws proper exception while the spec should be clarified tthat the given interfaces must represent non-hidden interfaces.
23-07-2020