HACK TransformerClassRealm - #144
Conversation
| private final ClassActionImpl classAction; | ||
| private final ServiceLoaderConfigActionImpl serviceConfigAction; | ||
|
|
||
| public static TransformerClassRealm newJakartaTransformerClassRealm( |
There was a problem hiding this comment.
Should this really be part of Classworlds? Although a common example the actual rules are usually defined by consumer...
There was a problem hiding this comment.
Exactly, in this case maven is consumer... but again, this is hack, this realm could be hidden in maven own impl package... (but rest of changes are needed here, to allow classworld to create 'custom type' realm)
There was a problem hiding this comment.
Pull request overview
This PR experiments with integrating the Eclipse Transformer into Plexus Classworlds by introducing a transformer-backed ClassRealm implementation and routing ClassWorld’s default realm creation through it (along with related test updates and new dependencies).
Changes:
- Introduces
TransformerClassRealmto transform loaded classes/resources (e.g.,javax.*→jakarta.*) at classloading time. - Refactors
ClassWorld.newRealm(...)to support a supplier-based realm factory and switches the default realm implementation when no filter is provided. - Updates tests to create realms through
ClassWorld.newRealm(...)and adds new Maven dependencies (SLF4J + Eclipse Transformer).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/org/codehaus/plexus/classworlds/realm/DefaultClassRealmTest.java | Updates realm creation to go through ClassWorld.newRealm(...) (now coupled to default realm type). |
| src/test/java/org/codehaus/plexus/classworlds/realm/ClassRealmImplTest.java | Updates realm construction to use ClassWorld.newRealm(...) and propagates DuplicateRealmException. |
| src/main/java/org/codehaus/plexus/classworlds/realm/TransformerClassRealm.java | Adds a new transformer-backed ClassRealm that wraps resources/classes via URL handlers and overrides class/resource finding. |
| src/main/java/org/codehaus/plexus/classworlds/realm/ClassRealm.java | Makes ClassRealm abstract, preventing direct instantiation. |
| src/main/java/org/codehaus/plexus/classworlds/ClassWorld.java | Adds supplier-based realm creation and changes default realm creation to use TransformerClassRealm. |
| pom.xml | Adds dependencies on slf4j-api and a SNAPSHOT org.eclipse.transformer artifact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @author Jason van Zyl | ||
| */ | ||
| public class ClassRealm extends URLClassLoader { | ||
| public abstract class ClassRealm extends URLClassLoader { |
| public ClassRealm newRealm(String id, ClassLoader classLoader, Predicate<String> filter) | ||
| throws DuplicateRealmException { | ||
| if (realms.containsKey(id)) { | ||
| throw new DuplicateRealmException(this, id); | ||
| } | ||
|
|
||
| ClassRealm realm; | ||
| return newRealm(() -> { | ||
| if (filter == null) { | ||
| // return new ClassRealm(this, id, classLoader); | ||
| return TransformerClassRealm.newJakartaTransformerClassRealm(this, id, classLoader); | ||
| } else { | ||
| return new FilteredClassRealm(filter, this, id, classLoader); | ||
| } | ||
| }); |
| <dependency> | ||
| <groupId>org.eclipse.transformer</groupId> | ||
| <artifactId>org.eclipse.transformer</artifactId> | ||
| <version>1.1.0-SNAPSHOT</version> | ||
| </dependency> |
experimenting with https://github.com/eclipse-transformer/transformer
f45096b to
ab15b9b
Compare
|
#152 proposes the
world.createRealm(id, realmId ->
TransformerClassRealm.newJakartaTransformerClassRealm(world, realmId, loader));Moving the dependency from Verified: rebased locally onto #152 with the dependency at 1.0.0 → What the rebase also shows is that nothing in classworlds would then reference Glad to push the rebase here if that is useful. This comment was created with AI assistance. |
Experimenting with https://github.com/eclipse-transformer/transformer
NO MERGE! This is A HACK yet.
To build:
mvn -Denforcer.skip(as Eclipse Transformer is Java 17)