You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/09/19 14:35:00 UTC

[jira] [Commented] (DELTASPIKE-1432) Proxy class definition does not work

    [ https://issues.apache.org/jira/browse/DELTASPIKE-1432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17417341#comment-17417341 ] 

ASF subversion and git services commented on DELTASPIKE-1432:
-------------------------------------------------------------

Commit e3f9ce55fe774ffde12802e94a760880c23b3c9b in deltaspike's branch refs/heads/master from Christian Beikov
[ https://gitbox.apache.org/repos/asf?p=deltaspike.git;h=e3f9ce5 ]

DELTASPIKE-1432 Implement MethodHandles.Lookup based fallback for class definition on Java 9+


> 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
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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}} or {{\--add-opens java.base/java.lang=deltaspike.proxy.module.impl.asm}} if running in modular mode. 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}
> 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 deltaspike.proxy.module.impl.asm@1.9.4/org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator.loadClass(AsmDeltaSpikeProxyClassGenerator.java:528)
> 		at deltaspike.proxy.module.impl.asm@1.9.4/org.apache.deltaspike.proxy.impl.AsmDeltaSpikeProxyClassGenerator.generateProxyClass(AsmDeltaSpikeProxyClassGenerator.java:73)
> {code}



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