Fix the problem that when the --enable-preview feature is enabled, set the wrong java version in watch/trace. #1526 #1223

This commit is contained in:
hengyunabc
2020-09-24 20:35:03 +08:00
parent e40025a2df
commit 512472ed17
3 changed files with 55 additions and 3 deletions
@@ -228,9 +228,9 @@ public class Enhancer implements ClassFileTransformer {
affect.addMethodAndCount(inClassLoader, className, methodNode.name, methodNode.desc);
}
// https://github.com/alibaba/arthas/issues/1223
if (classNode.version < Opcodes.V1_5) {
classNode.version = Opcodes.V1_5;
// https://github.com/alibaba/arthas/issues/1223 , V1_5 的major version是49
if (AsmUtils.getMajorVersion(classNode.version) < 49) {
classNode.version = AsmUtils.setMajorVersion(classNode.version, 49);
}
byte[] enhanceClassByteArray = AsmUtils.toBytes(classNode, inClassLoader, classReader);