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

A statement containing only a parenthesized expression written in MVEL dialect causes compilation error in executable model.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.11.0.GA
    • 7.10.0.GA
    • BRE
    • False
    • False
    • CR1
    • +
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_21a.zip
        $ cd reproducer_model_compiler_21a
        
      2. Build and execute the rule.
        $ mvn clean compile exec:exec -DgenerateModel=NO
            :
            :
        ***** start
        ***** com.example.reproducer.Bus@5af9926a, weight = 12000
        ***** bd2 = 144000000
        ***** end
            :
            :
        
        $ mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        02:46:10.576 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_21a ---
        02:46:10.579 [INFO] Changes detected - recompiling the module!
        02:46:10.580 [INFO] Compiling 6 source files to /work2/testdir/reproducer_model_compiler_21a/target/classes
        02:46:10.616 [INFO] -------------------------------------------------------------
        02:46:10.616 [ERROR] COMPILATION ERROR : 
        02:46:10.617 [INFO] -------------------------------------------------------------
        02:46:10.617 [ERROR] /work2/testdir/reproducer_model_compiler_21a/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/P9D/LambdaConsequence9D5AE9174B6338FFA1F398238E0AE1A8.java:[23,9] not a statement
        02:46:10.617 [INFO] 1 error
        02:46:10.617 [INFO] -------------------------------------------------------------
            :
            :
        
      Show
      Extract reproducer. $ unzip reproducer_model_compiler_21a.zip $ cd reproducer_model_compiler_21a Build and execute the rule. $ mvn clean compile exec:exec -DgenerateModel=NO : : ***** start ***** com.example.reproducer.Bus@5af9926a, weight = 12000 ***** bd2 = 144000000 ***** end : : $ mvn clean compile exec:exec -DgenerateModel=YES : : 02:46:10.576 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_21a --- 02:46:10.579 [INFO] Changes detected - recompiling the module! 02:46:10.580 [INFO] Compiling 6 source files to /work2/testdir/reproducer_model_compiler_21a/target/classes 02:46:10.616 [INFO] ------------------------------------------------------------- 02:46:10.616 [ERROR] COMPILATION ERROR : 02:46:10.617 [INFO] ------------------------------------------------------------- 02:46:10.617 [ERROR] /work2/testdir/reproducer_model_compiler_21a/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/P9D/LambdaConsequence9D5AE9174B6338FFA1F398238E0AE1A8.java:[23,9] not a statement 02:46:10.617 [INFO] 1 error 02:46:10.617 [INFO] ------------------------------------------------------------- : :
    • 2021 Week 10-12 (from Mar 8)

      When building a rule (*1) that contains a parenthesized expression statement 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 because the statement (*2) not allowable in Java language [1] is generated from (*1-1).

      (*1)

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

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

              (bd2 *= $bus.weight);
      

      (*3) Error message

      02:46:10.576 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_21a ---
      02:46:10.579 [INFO] Changes detected - recompiling the module!
      02:46:10.580 [INFO] Compiling 6 source files to /work2/testdir/reproducer_model_compiler_21a/target/classes
      02:46:10.616 [INFO] -------------------------------------------------------------
      02:46:10.616 [ERROR] COMPILATION ERROR : 
      02:46:10.617 [INFO] -------------------------------------------------------------
      02:46:10.617 [ERROR] /work2/testdir/reproducer_model_compiler_21a/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/P9D/LambdaConsequence9D5AE9174B6338FFA1F398238E0AE1A8.java:[23,9] not a statement
      02:46:10.617 [INFO] 1 error
      02:46:10.617 [INFO] -------------------------------------------------------------
      

      [1] The Java Language Specification Java SE 11 Edition - 14.8. Expression Statements
      https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-14.8

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

                Created:
                Updated:
                Resolved: