eclipselink icon indicating copy to clipboard operation
eclipselink copied to clipboard

[master] ASM separation

Open rfelcman opened this issue 2 years ago • 0 comments

Refactor EL to allow usage booth ASM implementations (standard provided by org.ow2.asm and internal org.eclipse.persistence.asm).

Main reason behind this enhancement is quickly adopt new Java version as Java release cycle is quicker now. Usage of ASM implementation is controlled by new system property eclipselink.asm.service . There are following values possible

  • eclipselink - use ASM implementation from org.eclipse.persistence.asm project
  • ow2 - use ASM implementation from org.ow2.asm project (DEFAULT) Various EclipseLink tests should be executed with this system property e.g.
mvn verify -pl :org.eclipse.persistence.jpa.jse.test -P mysql -Declipselink.asm.service=ow2
mvn verify -pl :org.eclipse.persistence.jpa.jse.test -P mysql -Declipselink.asm.service=eclipselink

mvn test -pl :org.eclipse.persistence.moxy -P test-moxy-lrg -Declipselink.asm.service=ow2
mvn test -pl :org.eclipse.persistence.moxy -P test-moxy-lrg -Declipselink.asm.service=eclipselink

mvn clean verify -pl :org.eclipse.persistence.jpa.test -P test-jpa-lrg,mysql -Declipselink.asm.service=ow2
mvn clean verify -pl :org.eclipse.persistence.jpa.test -P test-jpa-lrg,mysql -Declipselink.asm.service=eclipselink

Code in this enhancement should be divided into following parts:

  • Adapter/wrapper classes in org.eclipse.persistence.core module in org.eclipse.persistence.asm package. There are classes which translate calls from EclipseLink into ASM implementation. Code where is ASM used is pointed to org.eclipse.persistence.asm Java package.
  • Required code changes in the rest of EclipseLink code base to use adapter/wrapper classes from the previous point. Major part of these changes is org.eclipse.persistence.internal.libraries.asm.Opcodes.ACC_PUBLIC -> org.eclipse.persistence.asm.Opcodes.valueInt("ACC_PUBLIC") or org.eclipse.persistence.internal.libraries.asm.Label l0 = new org.eclipse.persistence.internal.libraries.asm.Label(); -> org.eclipse.persistence.asm.Label l0 = org.eclipse.persistence.asm.ASMFactory.createLabel();
  • Dependency changes in pom.xml. ASM implementation artifacts are used as a compilation dependency in org.eclipse.persistence.core module and in the others usually as a dependency in test scope.
  • JPMS change as package org.eclipse.persistence.internal.libraries.asm and module org.eclipse.persistence.asm is not used directly in project submodules.
  • OSGi part is open now. There are test changes only in OSGiBundleTest.java.

This PR handle all scenarious how ASM is used in EclipseLink (sorted from most simple):

  1. Simple ASM method call or constant access without and in/out values conversion like org.eclipse.persistence.internal.libraries.asm.Opcodes.ACC_PUBLIC -> org.eclipse.persistence.asm.Opcodes.valueInt("ACC_PUBLIC")
  2. Method call with in/out value conversion like MethodVisitor mv = cw.visitMethod(....
  3. Most complex are classes from EclipseLink which instances are passed into ASM implementation and some methods are overriden there and some not. These classes inherits from ASM classes like ClassVisitor, ClassReader, ClassWriter. See org.eclipse.persistence.internal.jpa.weaving.ClassWeaver, org.eclipse.persistence.internal.jpa.weaving.ComputeClassWriter, org.eclipse.persistence.internal.jpa.weaving.MethodWeaver ...

Open questions:

  1. OSGi directives like <Import-Package> in some pom.xml files.
  2. package-rename.properties oracle.toplink.libraries.asm=org.eclipse.persistence.internal.libraries.asm
  3. Opcodes.valueInt(....) performance
  4. module-info.java
  5. org.eclipse.persistence.tools.weaving.jpa.StaticWeave classpath (OW2, EclipseLink ASM) + documentation update
  6. Test dependencies in server tests
  7. Eliminate additional ASM EclipseLink* classes like EclipseLinkClassVisitor
  8. Decide if there is some more elegant way how to distinguish calls like "super.visit...()", than "super.visit...Super()"
  9. Default implementation currently is OW2, but due a historical reasons it should be org.eclipse.persistence.asm
  10. ASM distribution in EclipseLInk bundles.
  11. Extend current tests to verify booth ASM implementaions.

Fixes #1424 .

Signed-off-by: Radek Felcman [email protected]

rfelcman avatar Apr 08 '22 12:04 rfelcman