mvel icon indicating copy to clipboard operation
mvel copied to clipboard

Illegal type in constant pool

Open kreksbeks opened this issue 11 years ago • 15 comments

Environment: Windows 7, amd64 MVEL: 2.1.7.Final, 2.1.4.Final java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b118) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b60, mixed mode)

**** COMPILER BUG! REPORT THIS IMMEDIATELY AT http://jira.codehaus.org/browse/mvel2 Expression: (name.first in persons) Exception in thread "main" java.lang.VerifyError: (class: ASMAccessorImpl_4458843621386333353870, method: getKnownEgressType signature: ()Ljava/lang/Class;) Illegal type in constant pool at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2650) at java.lang.Class.getConstructor0(Class.java:2956) at java.lang.Class.newInstance(Class.java:403) at org.mvel2.optimizers.impl.asm.ASMAccessorOptimizer._initializeAccessor(ASMAccessorOptimizer.java:725) at org.mvel2.optimizers.impl.asm.ASMAccessorOptimizer.compileAccessor(ASMAccessorOptimizer.java:859) at org.mvel2.optimizers.impl.asm.ASMAccessorOptimizer.optimizeAccessor(ASMAccessorOptimizer.java:243) at org.mvel2.optimizers.dynamic.DynamicGetAccessor.optimize(DynamicGetAccessor.java:90) at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:64) at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108) at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38) at org.mvel2.ast.Fold.getReducedValue(Fold.java:137) at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:106) at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:49) at org.mvel2.MVEL.eval(MVEL.java:165) at com.pontiki.core.datasource.MVELTestCase.testCase(MVELTestCase.java:23) at com.pontiki.core.datasource.MVELTestCase.main(MVELTestCase.java:15) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


To reproduce the issue use the following test case.

import org.mvel2.MVEL;
import test.domain.Name;
import test.domain.Person;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class MVELTestCase {

public static void main(String[] args) {
    testCase();
}

public static void testCase() {
    Collection<Person> persons = getPersons(200);
    Map<String, Object> vars = new HashMap<>();
    vars.put("persons", persons);

    Object eval = MVEL.eval("(name.first in persons)", vars);
    System.out.println(eval);
}

private static Collection<Person> getPersons(int number) {
    Collection<Person> persons = new ArrayList<>();
    for (int i = 0; i < number; i++)
    {
        Person person2 = new Person();
        person2.setName(new Name(toLetter(i) + "name", "Last"));
        persons.add(person2);
    }
    return persons;
}

private static char toLetter(int i) {
    return (char) (i % (90 - 65 + 1)  + 65);
}
}

kreksbeks avatar Dec 06 '13 12:12 kreksbeks

I'm experiencing this problem too. But I'm using update from elasticsearch, in setScript(_) I'm trying to do the same thing and It's not working for some process... not all of them

asilvino avatar Jun 05 '14 18:06 asilvino

Any updates on this issue? We are also suffering this issue when upgrading to Java 8.

steveluo avatar Sep 15 '15 01:09 steveluo

Hi Steveluo , Did you find any solution to this issue?

toamitmaurya avatar Jan 04 '16 07:01 toamitmaurya

@toamitmaurya No, we simply replace the MVEL with groovy.

steveluo avatar Jan 04 '16 07:01 steveluo

I reproduced the same issue with Java8 and investigated little bit here and root cause seems to be here https://github.com/mikebrock/mvel/blob/master/src/main/java/org/mvel2/optimizers/impl/asm/ASMAccessorOptimizer.java#L81-L89

in case javaVersion 1.8, it is using OPCODES_VERSION = Opcodes.V1_2;

for now, I went a head and updated locally, for Java version 1.8, using OPCODES_VERSION = Opcodes.V1_7; and it works!!

mkornipati avatar Feb 02 '16 16:02 mkornipati

@mkornipati : Could you please elaborate what you have done to fix the issue ? I am just confused where to change the String ( OPCODES_VERSION ).

arun2arunraj avatar May 11 '16 05:05 arun2arunraj

I met the same problem, and it is blocking me. How to solve this problem without changing JDK?

kobe2000 avatar Jan 17 '17 10:01 kobe2000

Code within org.mvel2.optimizers.impl.asm.ASMAccessorOptimizer should be fixed as shown in below article: http://copyrightdev.tumblr.com/post/146315831773/getting-drools-5x-to-operate-smoothly-with-java-8

Also, this code issue has been fixed in mvel2 2.2.0.Final version.

rajmalarapu avatar Jan 20 '17 20:01 rajmalarapu

Hi, Some one can suggest the any solution for below issue. i have added janino compiler after wrong class format, again i am getting some thing like below org.drools.RuntimeDroolsException: java.lang.ClassNotFoundException: com.xxx.xxx.drools.rules.Rule_xxx_Value_Adjustment_0ConsequenceInvoker [09/24 09:50:44.847][ERROR]DroolsServlet:75 - Loading Drools Failed :org.drools.RuntimeDroolsException: java.lang.ClassNotFoundException: com.xxx.xxx.drools.rules.Rule_xxx_Value_Adjustment_0ConsequenceInvoker

NagarjunaReddyBadolla avatar Sep 24 '18 18:09 NagarjunaReddyBadolla

@mkornipati Hello Mohan - where have you published the alternate mvel-2.1.3-Final-Patch jar? I would like to use it. Please let me know.

vikasbo avatar May 13 '19 11:05 vikasbo

Our updated artifact is published to an internal repository.

But this is the code change: image

dstine avatar May 13 '19 12:05 dstine

Thanks @dstine. Actually, I could locate the patch and diff. Its here as the top commit on this branch. https://github.com/mkornipati/mvel/tree/2.1.9.Final.Patch However, in order to use it, I need either of:

  1. mvel jar for 2.1.9.Final.Patch
  2. Instructions to build the jar from maven project https://github.com/mkornipati/mvel/tree/2.1.9.Final.Patch

Both are elusive. When I try to build locally, I get this error:

`[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project mvel2: Compilation failure [ERROR] ~/mvel/src/main/java/org/mvel2/util/JITClassLoader.java:[49,33] error: method defineClass in class Unsafe cannot be applied to given types; [ERROR] [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project mvel2: Compilati on failure ~/mvel/src/main/java/org/mvel2/util/JITClassLoader.java:[49,33] error: method defineClass in class Unsafe cannot be applied to given types;

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure ~/mvel/src/main/java/org/mvel2/util/JITClassLoader.java:[49,33] error: method defineClass in class Unsafe cannot be applied to given types;

at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more

`

Appreciate help on either of the above 2.

vikasbo avatar May 13 '19 12:05 vikasbo

I could do mvn package after downgrading current java to Java 7. Thanks.

vikasbo avatar May 13 '19 13:05 vikasbo

Ah, okay. FWIW, we used JDK 6u33.

dstine avatar May 13 '19 13:05 dstine

Hello @dstine ! Is this patch purported to fix the drools rules v5.0.1 compilation with Java 8? If that is the goal, it hasn't worked for me. Do you have any pointers for me?

vikasbo avatar May 15 '19 18:05 vikasbo