Skip to content

Commit

Permalink
Avoid letting our transformation rules getting transformed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Sep 21, 2022
1 parent 782c6ba commit 76715e9
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -57,18 +56,25 @@ private static class JakartaTransformer {

private final Logger logger;
private final ActionContext ctx;
private static final Map<String, String> renames = Collections.singletonMap(forbiddenName(), "jakarta.transaction");

JakartaTransformer() {
logger = LoggerFactory.getLogger("JakartaTransformer");
Map<String, String> renames = new HashMap<>();
//N.B. we enable only this transformation, not the full set of capabilities of Eclipse Transformer;
//N.B. we enable only this single transformation of package renames, not the full set of capabilities of Eclipse Transformer;
//this might need tailoring if the same idea gets applied to a different context.
renames.put("javax.transaction", "jakarta.transaction");
ctx = new ActionContextImpl(logger,
new SelectionRuleImpl(logger, Collections.emptyMap(), Collections.emptyMap()),
new SignatureRuleImpl(logger, renames, null, null, null, null, null, Collections.emptyMap()));
}

//Need to prevent the Eclipse Transformer - which is run on this whole code base - to actually replace this name:
private static String forbiddenName() {
StringBuilder sb = new StringBuilder("java")
.append("x.")
.append("transaction");
return sb.toString();
}

byte[] transform(final String name, final byte[] bytes) {
logger.info("Jakarta EE compatibility enhancer for Quarkus: transforming " + name);
final ClassActionImpl classTransformer = new ClassActionImpl(ctx);
Expand Down

0 comments on commit 76715e9

Please sign in to comment.