Christian Beikov created DELTASPIKE-1432:
--------------------------------------------

             Summary: Proxy class definition does not work
                 Key: DELTASPIKE-1432
                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1432
             Project: DeltaSpike
          Issue Type: Improvement
      Security Level: public (Regular issues)
          Components: Proxy-Module
    Affects Versions: 1.9.5
            Reporter: Christian Beikov


In 
{{org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator#loadClass}} 
the current implementation always tries to make the {{ClassLoader#defineClass}} 
method (of module java.base) accessible which is disallowed by default since 
16. To workaround this, one has to add the following command line flags 
{{--add-opens java.base/java.lang=ALL-UNNAMED}}. This can be properly 
implemented though by using the new supported API 
{{java.lang.invoke.MethodHandles.Lookup#defineClass}} like Weld 3.1.7 now also 
did. This would help usability of Deltaspike a lot.

Here is the exception one sees without the flag:
 
{code}
Suppressed: java.lang.reflect.InaccessibleObjectException: Unable to make 
protected final java.lang.Class 
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
 throws java.lang.ClassFormatError accessible: module java.base does not "opens 
java.lang" to module deltaspike.proxy.module.impl.asmSuppressed: 
java.lang.reflect.InaccessibleObjectException: Unable to make protected final 
java.lang.Class 
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
 throws java.lang.ClassFormatError accessible: module java.base does not "opens 
java.lang" to module deltaspike.proxy.module.impl.asm at 
java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
 at 
java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
 at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) 
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) at 
[email protected]/org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator.loadClass(AsmDeltaSpikeProxyClassGenerator.java:528)
 at 
[email protected]/org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator.generateProxyClass(AsmDeltaSpikeProxyClassGenerator.java:73)
 at 
[email protected]/org.apache.deltaspike.proxy.api.DeltaSpikeProxyFactory.createProxyClass(DeltaSpikeProxyFactory.java:89)
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to