Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1141

Bean proxy class has non-varargs method for original varargs method

XMLWordPrintable

      Test case:

      @RequestScoped
      public class TestVarargs {
      public void varargsMethod(String... strings) {}
      }

      public class TestClass {
      @Inject
      TestVarargs testVarargs;

      public void runTest()

      { testClass(testVarargs.getClass()); testClass(TestVarargs.class); }

      private void testClass(Class<?> clazz) {
      for (Method m : clazz.getMethods()) {
      if (m.getName().equals("varargsMethod"))

      { System.out.println(clazz + " : " + m + " : " + m.isVarArgs()); }

      }
      }
      }

      Prints:
      class TestVarargs$Proxy$$$_WeldClientProxy : public void TestVarargs$Proxy$$$_WeldClientProxy.varargsMethod(java.lang.String[]) : false
      class TestVarargs : public void TestVarargs.varargsMethod(java.lang.String[]) : true

      The method generated in Weld proxy class is not a varargs method while the original one was. This breaks proper method lookup in tools that use reflection - in my case it was ZK EL resolver: for ${bean.method('String arg')} where signature is method(String...) there was proper code to handle a varargs call but only if the method was indeed declared as Method.isVarargs(), which was not the case when ${bean} was a Weld proxy.

              ajustin@redhat.com Ales Justin
              adammichalik Adam Michalik (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: