[jboss-jira] [JBoss JIRA] Created: (JBRULES-3112) Shift operator differs between Java and MVEL

Wolfgang Laun (JIRA) jira-events at lists.jboss.org
Thu Jun 30 01:48:23 EDT 2011


Shift operator differs between Java and MVEL
--------------------------------------------

                 Key: JBRULES-3112
                 URL: https://issues.jboss.org/browse/JBRULES-3112
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: drools-compiler (expert)
    Affects Versions: 5.2.0.Final
            Reporter: Wolfgang Laun
            Assignee: Mark Proctor
            Priority: Critical
             Fix For: 5.3.0.Beta1


The following DRL file can be run without and with "dialect 'mvel'"; in the latter case rules 2 and 4 do not fire, otherwise all 4 rules fire.
*** Using dialect Java ***
test1 1 << 65552 = 10000
test1 1 << 65536 = 1
test1 1 << 65568 = 1
test2 1 << 4294967296 = 1
test2 1 << 65536 = 1
test2 1 << 65552 = 10000
test2 1 << 65568 = 1
test3 1 << 4294967296 = 1
test3 1 << 65536 = 1
test3 1 << 65552 = 10000
test4 1 << 65552 = 10000
test4 1 << 65536 = 1

*** Using dialect MVEL ***
test1 1 << 65552 = 10000
test1 1 << 65536 = 1
test1 1 << 65568 = 1
test3 1 << 4294967296 = 1
test3 1 << 65536 = 1
test3 1 << 65552 = 10000

=== DRL ===
# dialect "mvel"

rule kickOff
when
then
    insert( Integer.valueOf( 1 ) );
    insert( Long.valueOf( 1 ) );
    insert( Integer.valueOf( 65552 ) );   // 0x10010
    insert( Long.valueOf( 65552 ) );
    insert( Integer.valueOf( 65568 ) );   // 0x10020
    insert( Long.valueOf( 65568 ) );
    insert( Integer.valueOf( 65536  ) );  // 0x10000
    insert( Long.valueOf( 65536L ) );
    insert( Long.valueOf( 4294967296L ) );  // 0x100000000L
end

rule test1
salience -1
when
   $a: Integer( $one:   intValue == 1 )
   $b: Integer( $shift: intValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test1 " + $a + " << " + $b + " = " + Integer.toHexString( $c ) );
end

rule test2
salience -2
when
   $a: Integer( $one:   intValue == 1 )
   $b:  Long   ( $shift: longValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test2 " + $a + " << " + $b + " = " + Integer.toHexString( $c ) );
end

rule test3
salience -3
when
   $a: Long   ( $one:   longValue == 1 )
   $b: Long   ( $shift: longValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test3 " + $a + " << " + $b + " = " + Integer.toHexString( $c ) );
end

rule test4
salience -4
when
   $a: Long   ( $one:   longValue == 1 )
   $b: Integer( $shift: intValue )
   $c: Integer( $i: intValue, intValue == ($one << $shift ) )
then
    System.out.println( "test4 " + $a + " << " + $b + " = " + Integer.toHexString( $c ) );
end



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list