From 317ede4bb1b2b25e975cd3daaba84b193ce543df Mon Sep 17 00:00:00 2001 From: jado Date: Sat, 27 Nov 2021 06:09:51 -0800 Subject: [PATCH] Add ASM API parameter to Atlas constructor Fixes GH-12 --- src/main/java/org/cadixdev/atlas/Atlas.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cadixdev/atlas/Atlas.java b/src/main/java/org/cadixdev/atlas/Atlas.java index c6f0f4f..132ab1d 100644 --- a/src/main/java/org/cadixdev/atlas/Atlas.java +++ b/src/main/java/org/cadixdev/atlas/Atlas.java @@ -13,6 +13,7 @@ import org.cadixdev.bombe.analysis.asm.ClassProviderInheritanceProvider; import org.cadixdev.bombe.provider.ClassProvider; import org.cadixdev.bombe.jar.JarEntryTransformer; +import org.objectweb.asm.Opcodes; import java.io.Closeable; import java.io.IOException; @@ -40,17 +41,31 @@ public class Atlas implements Closeable { private final ExecutorService executorService; private final boolean manageExecutor; + private final int api; /** * Creates an Atlas with an associated executor service. * * @param executorService The executor service * @param manageExecutor Whether to shutdown the executor service when closing the atlas - * @since 0.2.1 + * @param api The ASM API version to use + * @since 0.2.3 */ - private Atlas(final ExecutorService executorService, final boolean manageExecutor) { + private Atlas(final ExecutorService executorService, final boolean manageExecutor, final int api) { this.executorService = executorService; this.manageExecutor = manageExecutor; + this.api = api; + } + + /** + * Creates an Atlas with an associated executor service. + * + * @param executorService The executor service + * @param manageExecutor Whether to shutdown the executor service when closing the atlas + * @since 0.2.1 + */ + private Atlas(final ExecutorService executorService, final boolean manageExecutor) { + this(executorService, manageExecutor, Opcodes.ASM7); } /** @@ -138,7 +153,7 @@ public void run(final JarFile jar, final Path output) throws IOException { // Create the context for the JAR file final AtlasTransformerContext context = new AtlasTransformerContext( - new ClassProviderInheritanceProvider(new CompositeClassProvider(classpath)) + new ClassProviderInheritanceProvider(api, new CompositeClassProvider(classpath)) ); // Construct the transformers