[jboss-jira] [JBoss JIRA] (JBRULES-2975) Cannot use constant from Enum declared in class any more

Edson Tirelli (Closed) (JIRA) jira-events at lists.jboss.org
Wed Jan 4 12:02:09 EST 2012


     [ https://issues.jboss.org/browse/JBRULES-2975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edson Tirelli closed JBRULES-2975.
----------------------------------


    
> Cannot use constant from Enum declared in class any more 
> ---------------------------------------------------------
>
>                 Key: JBRULES-2975
>                 URL: https://issues.jboss.org/browse/JBRULES-2975
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler
>    Affects Versions: 5.2.0.M2
>            Reporter: Wolfgang Laun
>            Assignee: Edson Tirelli
>            Priority: Critical
>             Fix For: 5.3.2.Final, 5.4.0.Beta2
>
>
> Note that this was running with a build made around 2011-02-10!
> Given the class 
> public class Triangle {
>     public enum Type {
>         INCOMPLETE, UNCLASSIFIED,
>         EQUILATERAL, ISOSCELES, RECTANGLED, ISOSCELES_RECTANGLED, ACUTE, OBTUSE;
>     }
>     private int alpha;
>     private int beta;
>     private int gamma;
>     private Type type;
>     public Triangle( int alpha, int beta ) {
>         this.alpha = alpha;
>         this.beta = beta;
>         this.type = Type.UNCLASSIFIED;
>     }
>      // getters, setter,...
> }
> and the rule
> rule equilateral
> when
>     $t: Triangle( type == Triangle.Type.UNCLASSIFIED,
>                   alpha == beta && == gamma )
> then
>     modify( $t ){ setType( Triangle.Type.EQUILATERAL ) }
> end
> this fails with
> Exception in thread "main" org.drools.RuntimeDroolsException: [Error: object is not an instance of declaring class]
> [Near : {... Triangle.Type.UNCLASSIFIED ....}]
>              ^
> [Line: 1, Column: 1]
> 	at org.drools.rule.ReturnValueRestriction.isAllowed(ReturnValueRestriction.java:258)
> 	at org.drools.rule.VariableConstraint.isAllowed(VariableConstraint.java:103)
> 	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
> 	at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
> 	at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378)
> 	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
> 	at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143)
> 	at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:332)
> 	at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:293)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:905)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:864)
> 	at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
> 	at rss.drools.setup.Application.insert(Application.java:141)
> 	at ex4.Main.makeFacts(Main.java:35)
> 	at rss.drools.setup.Application.execute(Application.java:83)
> 	at ex4.Main.main(Main.java:40)
> Caused by: [Error: object is not an instance of declaring class]
> [Near : {... Triangle.Type.UNCLASSIFIED ....}]
>              ^
> [Line: 1, Column: 1]
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:427)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
> 	at org.mvel2.ast.ASTNode.optimize(ASTNode.java:158)
> 	at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)
> 	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:87)
> 	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:125)
> 	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:118)
> 	at org.mvel2.MVEL.executeExpression(MVEL.java:954)
> 	at org.drools.base.mvel.MVELReturnValueExpression.evaluate(MVELReturnValueExpression.java:88)
> 	at org.drools.rule.ReturnValueRestriction.isAllowed(ReturnValueRestriction.java:247)
> 	... 15 more
> Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:616)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:514)
> 	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:335)
> 	... 24 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list