diff --git a/core/src/main/java/org/teavm/parsing/AsmUtil.java b/core/src/main/java/org/teavm/parsing/AsmUtil.java new file mode 100644 index 000000000..4694b8e62 --- /dev/null +++ b/core/src/main/java/org/teavm/parsing/AsmUtil.java @@ -0,0 +1,25 @@ +/* + * Copyright 2022 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.parsing; + +import org.objectweb.asm.Opcodes; + +public final class AsmUtil { + public static final int API_VERSION = Opcodes.ASM9; + + private AsmUtil() { + } +} diff --git a/core/src/main/java/org/teavm/parsing/Parser.java b/core/src/main/java/org/teavm/parsing/Parser.java index 0b5f1ad0d..e3d8ca397 100644 --- a/core/src/main/java/org/teavm/parsing/Parser.java +++ b/core/src/main/java/org/teavm/parsing/Parser.java @@ -71,8 +71,8 @@ public class Parser { } public MethodHolder parseMethod(MethodNode node, String fileName) { - MethodNode nodeWithoutJsr = new MethodNode(Opcodes.ASM7, node.access, node.name, node.desc, node.signature, - node.exceptions.toArray(new String[0])); + MethodNode nodeWithoutJsr = new MethodNode(AsmUtil.API_VERSION, node.access, node.name, node.desc, + node.signature, node.exceptions.toArray(new String[0])); JSRInlinerAdapter adapter = new JSRInlinerAdapter(nodeWithoutJsr, node.access, node.name, node.desc, node.signature, node.exceptions.toArray(new String[0])); node.accept(adapter); diff --git a/core/src/main/java/org/teavm/parsing/ProgramParser.java b/core/src/main/java/org/teavm/parsing/ProgramParser.java index 6349e35e7..fe756cbc9 100644 --- a/core/src/main/java/org/teavm/parsing/ProgramParser.java +++ b/core/src/main/java/org/teavm/parsing/ProgramParser.java @@ -431,7 +431,7 @@ public class ProgramParser { } // TODO: invokedynamic support (a great task, involving not only parser, but every layer of TeaVM) - private MethodVisitor methodVisitor = new MethodVisitor(Opcodes.ASM7) { + private MethodVisitor methodVisitor = new MethodVisitor(AsmUtil.API_VERSION) { @Override public void visitVarInsn(int opcode, int local) { switch (opcode) { diff --git a/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java b/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java index 27d794cc1..58930516f 100644 --- a/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java +++ b/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java @@ -35,9 +35,9 @@ import java.util.stream.Collectors; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.teavm.metaprogramming.CompileTime; +import org.teavm.parsing.AsmUtil; import org.teavm.vm.spi.After; import org.teavm.vm.spi.Before; import org.teavm.vm.spi.Requires; @@ -205,8 +205,8 @@ final class TeaVMPluginReader { static class PluginDescriptorFiller extends ClassVisitor { PluginDescriptor descriptor; - public PluginDescriptorFiller(PluginDescriptor descriptor) { - super(Opcodes.ASM7); + PluginDescriptorFiller(PluginDescriptor descriptor) { + super(AsmUtil.API_VERSION); this.descriptor = descriptor; } @@ -223,12 +223,12 @@ final class TeaVMPluginReader { } private AnnotationVisitor readClassArray(Consumer resultConsumer) { - return new AnnotationVisitor(Opcodes.ASM7) { + return new AnnotationVisitor(AsmUtil.API_VERSION) { @Override public AnnotationVisitor visitArray(String name) { List values = new ArrayList<>(); if (name.equals("value")) { - return new AnnotationVisitor(Opcodes.ASM7) { + return new AnnotationVisitor(AsmUtil.API_VERSION) { @Override public void visit(String name, Object value) { values.add(((Type) value).getClassName()); diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java index 562c2656a..f851f754c 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java @@ -24,9 +24,9 @@ import org.apache.commons.io.IOUtils; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.teavm.metaprogramming.CompileTime; +import org.teavm.parsing.AsmUtil; public class MetaprogrammingClassLoader extends ClassLoader { private MetaprogrammingInstrumentation instrumentation = new MetaprogrammingInstrumentation(); @@ -129,7 +129,7 @@ public class MetaprogrammingClassLoader extends ClassLoader { boolean compileTime; CompileTimeClassVisitor() { - super(Opcodes.ASM7, null); + super(AsmUtil.API_VERSION, null); } @Override diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java index 8dd83ed00..3fe69e155 100644 --- a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java +++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java @@ -30,6 +30,7 @@ import org.teavm.metaprogramming.Action; import org.teavm.metaprogramming.Computation; import org.teavm.metaprogramming.Metaprogramming; import org.teavm.model.MethodReference; +import org.teavm.parsing.AsmUtil; public class MetaprogrammingInstrumentation { private static String lambdaMetafactory = LambdaMetafactory.class.getName().replace('.', '/'); @@ -44,9 +45,9 @@ public class MetaprogrammingInstrumentation { return writer.toByteArray(); } - class ClassTransformer extends ClassVisitor { + static class ClassTransformer extends ClassVisitor { ClassTransformer(ClassVisitor cv) { - super(Opcodes.ASM7, cv); + super(AsmUtil.API_VERSION, cv); } @Override @@ -56,11 +57,11 @@ public class MetaprogrammingInstrumentation { } } - class MethodTransformer extends MethodVisitor { + static class MethodTransformer extends MethodVisitor { private boolean instrumented; MethodTransformer(MethodVisitor mv) { - super(Opcodes.ASM7, mv); + super(AsmUtil.API_VERSION, mv); } @Override diff --git a/pom.xml b/pom.xml index 2e4852f40..ce55eac09 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 1.5 1.7.30 - 9.1 + 9.4 1.8 17