Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-1621

Some expressions consisting of BigDecimal-type arithmetic operations written in MVEL dialect causes compilation errors in executable model.

    XMLWordPrintable

Details

    • Bug
    • Status: Verified (View Workflow)
    • Major
    • Resolution: Done
    • 7.10.0.GA
    • 7.11.0.GA
    • BRE
    • CR1
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_21b.zip
        $ cd reproducer_model_compiler_21b
        
      2. Build and execute the rule.
        $ mvn clean compile exec:exec -DgenerateModel=NO
            :
            :
        ***** start
        ***** com.example.reproducer.Bus@1a15b789, weight = 12200
        ***** end
            :
            :
        
        $ mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        05:29:18.595 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_21b ---
        05:29:18.598 [INFO] Changes detected - recompiling the module!
        05:29:18.599 [INFO] Compiling 6 source files to /work2/testdir/reproducer_model_compiler_21b/target/classes
        05:29:18.814 [INFO] -------------------------------------------------------------
        05:29:18.814 [ERROR] COMPILATION ERROR : 
        05:29:18.814 [INFO] -------------------------------------------------------------
        05:29:18.814 [ERROR] /work2/testdir/reproducer_model_compiler_21b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PC3/LambdaConsequenceC3EC93517F775872A1B91F3DCC90DB9B.java:[23,41] bad operand types for binary operator '+'
          first type:  java.math.BigDecimal
          second type: java.math.BigDecimal
        05:29:18.815 [INFO] 1 error
        05:29:18.815 [INFO] -------------------------------------------------------------
            :
            :
        
      Show
      Extract reproducer. $ unzip reproducer_model_compiler_21b.zip $ cd reproducer_model_compiler_21b Build and execute the rule. $ mvn clean compile exec:exec -DgenerateModel=NO : : ***** start ***** com.example.reproducer.Bus@1a15b789, weight = 12200 ***** end : : $ mvn clean compile exec:exec -DgenerateModel=YES : : 05:29:18.595 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_21b --- 05:29:18.598 [INFO] Changes detected - recompiling the module! 05:29:18.599 [INFO] Compiling 6 source files to /work2/testdir/reproducer_model_compiler_21b/target/classes 05:29:18.814 [INFO] ------------------------------------------------------------- 05:29:18.814 [ERROR] COMPILATION ERROR : 05:29:18.814 [INFO] ------------------------------------------------------------- 05:29:18.814 [ERROR] /work2/testdir/reproducer_model_compiler_21b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PC3/LambdaConsequenceC3EC93517F775872A1B91F3DCC90DB9B.java:[23,41] bad operand types for binary operator '+' first type: java.math.BigDecimal second type: java.math.BigDecimal 05:29:18.815 [INFO] 1 error 05:29:18.815 [INFO] ------------------------------------------------------------- : :
    • 2021 Week 10-12 (from Mar 8)
    • +

    Description

      When building a rule (*1) that contains a BigDecimal-type arithmetic operations written in MVEL dialect like (*1-1) with executable model enabled, a compilation error occurs with the message like (*3) in RHDM 7.10.0. The model compiler generates java code (*2) from (*1-1) but the generated code is not sufficient to perform BigDecimal-type arithmetic operations.

      (*1)

      package com.example.reproducer
      
      import java.math.BigDecimal
      
      dialect "mvel"
      
      rule "rule21b1"
          when
              $bus : Bus()
          then
              BigDecimal bd1 = 10;
              BigDecimal bd2 = 20;
              $bus.weight = $bus.weight + (bd1.multiply(bd2));    .............. (\*1-1)
              System.out.println("***** " + $bus + ", weight = " + $bus.weight);
      end
      

      (*2) Java code generated from (*1-1) in RHDM 7.10.0

              $bus.setWeight($bus.getWeight() + bd1.multiply(bd2));
      

      (*3) Error message

      05:29:18.595 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_21b ---
      05:29:18.598 [INFO] Changes detected - recompiling the module!
      05:29:18.599 [INFO] Compiling 6 source files to /work2/testdir/reproducer_model_compiler_21b/target/classes
      05:29:18.814 [INFO] -------------------------------------------------------------
      05:29:18.814 [ERROR] COMPILATION ERROR : 
      05:29:18.814 [INFO] -------------------------------------------------------------
      05:29:18.814 [ERROR] /work2/testdir/reproducer_model_compiler_21b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/PC3/LambdaConsequenceC3EC93517F775872A1B91F3DCC90DB9B.java:[23,41] bad operand types for binary operator '+'
        first type:  java.math.BigDecimal
        second type: java.math.BigDecimal
      05:29:18.815 [INFO] 1 error
      05:29:18.815 [INFO] -------------------------------------------------------------
      

      Other operations cause compilation errors as well as '+' operation.

      • $bus.weight = $bus.weight - (bd1.multiply(bd2))
      • $bus.weight = $bus.weight * (bd1.multiply(bd2))
      • $bus.weight = $bus.weight / (bd1.multiply(bd2))

      On the releases from RHDM 7.9.0 to 7.9.1, the expression using '+' or '-' operator was successfully compiled and executed.

      • $bus.weight = $bus.weight + (bd1.multiply(bd2))
      • $bus.weight = $bus.weight - (bd1.multiply(bd2))

      Attachments

        Issue Links

          Activity

            People

              lmolteni@redhat.com Luca Molteni
              rhn-support-myoshida Masato Yoshida
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: