低版本mvel在MaxCompute jdk8环境中报java.lang.VerifyError

2017/03/17 11:24
阅读数 402

最近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

https://github.com/mvel/mvel/blob/mvel2-2.0.1/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 = 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;
  }

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部