[jboss-jira] [JBoss JIRA] (WFLY-10025) Use new org.jboss.modules.ClassTransformer interface instead of j.l.i.ClassFileTransformer

Scott Marlow (JIRA) issues at jboss.org
Wed May 30 15:58:00 EDT 2018


    [ https://issues.jboss.org/browse/WFLY-10025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13584672#comment-13584672 ] 

Scott Marlow commented on WFLY-10025:
-------------------------------------

[https://docs.oracle.com/javaee/7/api/javax/persistence/spi/ClassTransformer.html#transform-java.lang.ClassLoader-java.lang.String-java.lang.Class-java.security.ProtectionDomain-byte:A-] is passed a byte[] and returns modification in the returned byte[] that represents the last modified copy of the byte[].  

If DelegatingClassFileTransformer is changed to operate on byte buffers, JPADelegatingClassFileTransformer#transform will need to accept/return a byte buffer, but JPADelegatingClassFileTransformer#transform still needs to pass byte[] to [JPADelegatingClassFileTransformer].

I'm not sure that we can avoid the extra whole-byte-array copy, especially if the JPA persistence provider transforms the class, which returns a new byte[] that we need to return a new ByteBuffer wrapper for.

I'm not sure that implementing this on top of the JPA [javax.persistence.spi.ClassTransformer|https://docs.oracle.com/javaee/7/api/javax/persistence/spi/ClassTransformer.html] interface will save us memory.  

Warning: if [WFCORE-3685] changes org.jboss.as.server.deployment.module.DelegatingClassFileTransformer to only operate on ByteBuffers, WF will have compile errors, so we will need to sync changing both projects or introduce a new DelegatingClassFileTransformerByteBuffered class so current callers aren't impacted.  

> Use new org.jboss.modules.ClassTransformer interface instead of j.l.i.ClassFileTransformer
> ------------------------------------------------------------------------------------------
>
>                 Key: WFLY-10025
>                 URL: https://issues.jboss.org/browse/WFLY-10025
>             Project: WildFly
>          Issue Type: Enhancement
>          Components: JPA / Hibernate
>            Reporter: David Lloyd
>            Assignee: Scott Marlow
>            Priority: Minor
>
> The JPA classes use {{java.lang.instrument.ClassFileTransformer}} for class transformation, however this style of transformer incurs an extra whole-byte-array copy when loading memory-mapped classes or using other resource loaders which operate on byte buffers.
> After the Modules 1.8.0.Final upgrade, switch to using {{org.jboss.modules.ClassTransformer}} instead.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list