Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8022795

Method.isVarargs of dynamic proxy generated method to match the proxy interface method

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 16
    • Component/s: core-libs
    • Labels:

      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 ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mchung Mandy Chung
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: