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

Unable to create proxy class in some edgy cases


    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 5.1.2.Final, 6.0.0.Alpha1
    • 3.1.9.Final
    • Proxies
    • None

      Suppose a bean class X with the following characteristics:

      • it is normal-scoped (@ApplicationScoped)
      • it is package-protected
      • it implements an interface Y
      • the type of the bean is restricted to that interface with @Typed(Y.class)
      • Y lives in another package than X
      • the bean is intercepted with some @Interceptor

      At runtime, I get an error WELD-001524 that can be fixed by... moving Y to the same package as X.

      The problem comes from the proxy class name which uses the same package name as Y.

      Due to the proxy class living in another package than X, it does not have access to X which is package-protected.

      I have locally modified org.jboss.weld.bean.proxy.ProxyFactory.createCompoundProxyName() to use the bean class package in such a case and that seems to fix the problem (and all tests still pass).

      WELD-001524: Unable to load proxy class for bean Managed Bean [class eg.impl.X] with qualifiers [@Any @Default] with class class eg.impl.X
      java.lang.IllegalAccessError: class eg.api.Y$1195452725$Proxy$_$$_WeldSubclass cannot access its superclass eg.impl.X
      	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_382]
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[?:1.8.0_382]
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_382]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_382]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_382]
      	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_382]
      	at org.jboss.weld.bean.proxy.util.WeldDefaultProxyServices.defineClass(WeldDefaultProxyServices.java:102) ~[weld-core-impl-3.1.9.Final.jar:3.1.9.Final]
      	at org.jboss.weld.bean.proxy.ProxyFactory.toClass(ProxyFactory.java:940) ~[test-classes/:3.1.9.Final]
      	at org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:498) ~[test-classes/:3.1.9.Final]
      	at org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:404) ~[test-classes/:3.1.9.Final]
      	... 53 more

      I can provide whatever is needed (reproducer/tests/patch) if there is interest in fixing this problem.

            manovotn Matěj Novotný
            sfpd_x1xdy Xavier Dury (Inactive)
            0 Vote for this issue
            2 Start watching this issue