Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1171

Java native compiler throws ClassCastException (so when using -Ddrools.dialect.java.compiler=NATIVE)

    XMLWordPrintable

Details

    • NEW
    • NEW

    Description

      To reproduce, add this VM option: -Ddrools.dialect.java.compiler=NATIVE
      when running for example XStreamXmlSolverFactoryTest in optaplanner-core (but any DRL, in drools-compiler's tests should suffice already).

      I get this stacktrace:

      java.lang.RuntimeException: java.lang.ClassCastException: org.drools.compiler.kie.builder.impl.MemoryKieModule$MemoryFolderURLConnection cannot be cast to java.net.JarURLConnection
      
      	at com.sun.tools.javac.main.Main.compile(Main.java:559)
      	at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
      	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
      	at org.drools.compiler.commons.jci.compilers.NativeJavaCompiler.compile(NativeJavaCompiler.java:91)
      	at org.drools.compiler.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
      	at org.drools.compiler.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:417)
      	at org.drools.compiler.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:61)
      	at org.drools.compiler.compiler.PackageRegistry.compileAll(PackageRegistry.java:138)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileAll(KnowledgeBuilderImpl.java:1357)
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.compileAllRules(KnowledgeBuilderImpl.java:991)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildRules(CompositeKnowledgeBuilderImpl.java:260)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:121)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
      	at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:243)
      	at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:64)
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:230)
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:198)
      	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:450)
      	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:300)
      	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:231)
      	at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:216)
      	at org.optaplanner.core.impl.solver.XStreamXmlSolverFactoryTest.configFileRemainsSameAfterReadWrite(XStreamXmlSolverFactoryTest.java:41)
      	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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
      	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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
      Caused by: java.lang.ClassCastException: org.drools.compiler.kie.builder.impl.MemoryKieModule$MemoryFolderURLConnection cannot be cast to java.net.JarURLConnection
      	at org.drools.compiler.commons.jci.compilers.NativeJavaCompiler$MemoryFileManager.processJar(NativeJavaCompiler.java:358)
      	at org.drools.compiler.commons.jci.compilers.NativeJavaCompiler$MemoryFileManager.findClassesInExternalJars(NativeJavaCompiler.java:336)
      	at org.drools.compiler.commons.jci.compilers.NativeJavaCompiler$MemoryFileManager.list(NativeJavaCompiler.java:302)
      	at com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.list(ClientCodeWrapper.java:231)
      	at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2796)
      	at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2446)
      	at com.sun.tools.javac.jvm.ClassReader.access$000(ClassReader.java:76)
      	at com.sun.tools.javac.jvm.ClassReader$1.complete(ClassReader.java:240)
      	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)
      	at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:300)
      	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
      	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
      	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
      	at com.sun.tools.javac.comp.Enter.complete(Enter.java:486)
      	at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
      	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
      	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
      	at com.sun.tools.javac.main.Main.compile(Main.java:523)
      	... 48 more
      

      Reproduced on both JDK 8 and JDK 9.

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              gdesmet@redhat.com Geoffrey De Smet
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: