I should have added that the script still completes successfully, it is only
the JIT optimization that is having problems and only when some threshold is
reached causing an attempt at performing the optimization - as per
descriptions I have read earlier. The problem is that I thought there was a
fix already in place for this problem if I read the earlier posts correctly
but perhaps I do not know how to enable it.
paulk_asert wrote
When I run this Groovy script using drools 5.5.0.CR1 with numAnimals
= 8
and numLegs = 120, it works fine. If I set numAnimals = 17 and numLegs =
1020 then it fails with a JITting error. I saw a bunch of Jira issues
related to JITting issues but no open ones seemed to match exactly.
@GrabResolver('https://repository.jboss.org/nexus/content/groups/public-jboss/')
@Grab('org.drools:knowledge-api:5.5.0.CR1')
@Grab('org.drools:drools-compiler:5.5.0.CR1')
@Grab('org.drools:drools-core:5.5.0.CR1')
@Grab('com.sun.xml.bind:jaxb-xjc:2.2.5.jboss-1')
@GrabExclude('com.github.relaxng:relaxngDatatype')
@GrabResolver('http://repo2.maven.org/maven2/')
@Grab('org.mvel#mvel2;2.1.2.Final')
@Grab('org.slf4j#slf4j-simple;1.6.4')
import groovy.transform.Immutable
import static org.drools.KnowledgeBaseFactory.newKnowledgeBase
import static
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder
import static org.drools.builder.ResourceType.DRL
import static org.drools.io.ResourceFactory.newReaderResource
def numAnimals = 8
def numLegs = 120
def kbuilder = newKnowledgeBuilder()
def drl = '''
dialect "mvel"
rule "deduce animal counts"
when
$crane : Crane( )
$centipede : Centipede( )
$tortoise : Tortoise(
quantity + $crane.quantity + $centipede.quantity == ''' + numAnimals
+ ''',
quantity * numLegs + $crane.quantity * $crane.numLegs +
$centipede.quantity * $centipede.numLegs == ''' + numLegs + '''
)
then
System.out.println( "Cranes " + $crane.getQuantity() )
System.out.println( "Tortoises " + $tortoise.getQuantity() )
System.out.println( "Centipedes " + $centipede.getQuantity() )
end
'''
kbuilder.add(newReaderResource(new StringReader(drl)), DRL)
def kbase = newKnowledgeBase()
kbase.addKnowledgePackages(kbuilder.knowledgePackages)
def ksession = kbase.newStatefulKnowledgeSession()
(numAnimals + 1).times { n ->
if (numLegs.intdiv(Crane.numLegs) >= n) {
ksession.insert(new Crane(n))
}
if (numLegs.intdiv(Tortoise.numLegs) >= n) {
ksession.insert(new Tortoise(n))
}
if (numLegs.intdiv(Centipede.numLegs) >= n) {
ksession.insert(new Centipede(n))
}
}
ksession.fireAllRules()
ksession.dispose()
@Immutable
class Crane {
static int numLegs = 2
int quantity
}
@Immutable
class Tortoise {
static int numLegs = 4
int quantity
}
@Immutable
class Centipede {
static int numLegs = 100
int quantity
}
Here is the error message:
Exception in thread "Thread-1" java.lang.RuntimeException: Exception
jitting: quantity + $crane.quantity + $centipede.quantity == 17 &&
quantity * numLegs + $crane.quantity * $crane.numLegs +
$centipede.quantity * $centipede.numLegs == 1020
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:275)
at
org.drools.rule.constraint.MvelConstraint.access$200(MvelConstraint.java:51)
at
org.drools.rule.constraint.MvelConstraint$ConditionJitter.run(MvelConstraint.java:250)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Error
writing method evaluate
at
org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:200)
at
org.drools.rule.constraint.ASMConditionEvaluatorJitter.jitEvaluator(ASMConditionEvaluatorJitter.java:53)
at
org.drools.rule.constraint.MvelConstraint.executeJitting(MvelConstraint.java:273)
... 5 more
Caused by: java.lang.RuntimeException: Error writing method evaluate
at
org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:881)
at
org.drools.rule.builder.dialect.asm.ClassGenerator.generateBytecode(ClassGenerator.java:128)
at
org.drools.rule.builder.dialect.asm.ClassGenerator.generateClass(ClassGenerator.java:144)
at
org.drools.rule.builder.dialect.asm.ClassGenerator.newInstance(ClassGenerator.java:198)
... 7 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.mvel2.asm.Frame.merge(Frame.java:1373)
at org.mvel2.asm.Frame.merge(Frame.java:1329)
at org.mvel2.asm.MethodWriter.visitMaxs(MethodWriter.java:1282)
at
org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:879)
... 10 more
Is this a known issue?
Thanks, Paul.
--
View this message in context:
http://drools.46999.n3.nabble.com/JITting-error-with-5-5-0-CR1-tp4020565p...
Sent from the Drools: User forum mailing list archive at
Nabble.com.