JDK-8022795 : Method.isVarargs of dynamic proxy generated method to match the proxy interface method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2013-08-09
  • Updated: 2024-11-13
  • Resolved: 2020-08-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b09Fixed
Related Reports
CSR :  
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_25 " 
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux sculpin 2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:39:49 UTC 2012 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
When creating a dynamic proxy of an Object according to an interface with a method with varargs, the created proxy method does return false when calling isVarargs on it.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided main method.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected output:
obj1 method call: varargs= true
proxy method call: varargs= true
values = [Ljava.lang.Object;@a5ae1e7
ACTUAL -
obj1 method call: varargs= true
proxy method call: varargs= false
values = [Ljava.lang.Object;@a5ae1e7

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Test.
 */
public class Test {

    public static void main(String[] args) {
        final C1 obj1 = new C1();

        Test1 proxy = (Test1) Proxy.newProxyInstance(obj1.getClass().getClassLoader(),
                                                     new Class[]{Test1.class},
                                                     new InvocationHandler() {
                                                         @Override
                                                         public Object invoke(
                                                             Object proxy,
                                                             Method method,
                                                             Object[] args) throws
                                                                            Throwable {
                                                             return method.invoke(obj1, args);
                                                         }
                                                     });

        for (Method m : obj1.getClass().getMethods()) {
            if (m.getName().equals( " call " )) {
                System.out.println( " obj1 method  "  + m.getName() +  " : varargs=  "  + m.isVarArgs());
            }
        }

        for (Method m : proxy.getClass().getMethods()) {
            if (m.getName().equals( " call " )) {
                System.out.println( " proxy method  "  + m.getName() +  " : varargs=  "  + m.isVarArgs());
            }
        }

        proxy.call();
    }
    interface Test1 {
        public void call(Object... values);
    }
    static class C1 implements Test1 {
        @Override
        public void call(Object... values) {
            System.out.println( " values =  "  + values);
        }
    }
}
---------- END SOURCE ----------
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/55670ad713a5 User: mchung Date: 2020-08-04 17:26:59 +0000
04-08-2020

This also affects debugger evaluation, see https://youtrack.jetbrains.com/issue/IDEA-202380
16-11-2018

The dynamic proxies are pre-dated var args. It would be nice if the generated methods can match the ACC_VARARGS of the methods defined in its corresonding proxy interface.
13-08-2013