最近MaxCompute在升级jdk8的环境,导致线上使用到MVEL的离线任务挂掉,主要是下面这个异常
Exception in thread "main" java.lang.VerifyError: (class: ASMAccessorImpl_4458843621386333353870, method: getKnownEgressType signature: ()Ljava/lang/Class;) Illegal type in constant pool
经过一系列查找最终确定这个是低版本mvel的bug,主要是ASMAccessorOptimizer这个类对高版本java没有处理,已经得到官方确认 https://github.com/mvel/mvel/pull/84
/**
* Implementation of the MVEL Just-in-Time (JIT) compiler for Property Accessors using the ASM bytecode
* engineering library.
* <p/>
*/
@SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "unchecked", "UnusedDeclaration"})
public class ASMAccessorOptimizer extends AbstractOptimizer implements AccessorOptimizer {
private static final String MAP_IMPL = "java/util/HashMap";
private static String LIST_IMPL;
private static String NAMESPACE;
private static final int OPCODES_VERSION;
static {
final String javaVersion = getProperty("java.version");
if (javaVersion.startsWith("1.4"))
OPCODES_VERSION = Opcodes.V1_4;
else if (javaVersion.startsWith("1.5"))
OPCODES_VERSION = Opcodes.V1_5;
else if (javaVersion.startsWith("1.6") || javaVersion.startsWith("1.7"))
OPCODES_VERSION = Opcodes.V1_6;
else
OPCODES_VERSION = Opcodes.V1_2;
String defaultNameSapce = getProperty("mvel2.namespace");
if (defaultNameSapce == null) NAMESPACE = "org/mvel2/";
else NAMESPACE = defaultNameSapce;
String jitListImpl = getProperty("mvel2.jit.list_impl");
if (jitListImpl == null) LIST_IMPL = NAMESPACE + "util/FastList";
else LIST_IMPL = jitListImpl;
}
从上面代码可以看到对于1.8的环境属于else部分,所以官方对这部分代码进行了升级
详见https://github.com/mvel/mvel/blob/master/src/main/java/org/mvel2/optimizers/impl/asm/ASMAccessorOptimizer.java
/**
* Implementation of the MVEL Just-in-Time (JIT) compiler for Property Accessors using the ASM bytecode
* engineering library.
* <p/>
*/
@SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "unchecked", "UnusedDeclaration"})
public class ASMAccessorOptimizer extends AbstractOptimizer implements AccessorOptimizer {
private static final String MAP_IMPL = "java/util/HashMap";
private static String LIST_IMPL;
private static String NAMESPACE;
private static final int OPCODES_VERSION;
static {
final String javaVersion = PropertyTools.getJavaVersion();
if (javaVersion.startsWith("1.4")) {
OPCODES_VERSION = Opcodes.V1_4;
} else if (javaVersion.startsWith("1.5")) {
OPCODES_VERSION = Opcodes.V1_5;
} else if (javaVersion.startsWith("1.6")
|| javaVersion.startsWith("1.7")
|| javaVersion.startsWith("1.8")
|| javaVersion.startsWith("9")) {
OPCODES_VERSION = Opcodes.V1_6;
} else {
OPCODES_VERSION = Opcodes.V1_2;
}
String defaultNameSapce = getProperty("mvel2.namespace");
if (defaultNameSapce == null) NAMESPACE = "org/mvel2/";
else NAMESPACE = defaultNameSapce;
String jitListImpl = getProperty("mvel2.jit.list_impl");
if (jitListImpl == null) LIST_IMPL = NAMESPACE + "util/FastList";
else LIST_IMPL = jitListImpl;
}
文章转自wangheng
欢迎加入“数加·MaxCompute购买咨询”钉钉群(群号: 11782920)进行咨询,群二维码如下: