ILOG JRules User Guide > Running and Debugging > Tasks > Troubleshooting Execution > Using Code Density

This section describes how you can troubleshoot bytecode errors generated in sequential mode. The bytecode that is generated on the fly by the sequential mode can handle a huge number of rules without reaching the Java .class format limits. The bytecode is automatically split, when necessary, among several .class files in memory. Since the sequential mode compiler deals with a high-level language, it does not recognize if the bytecode that corresponds to the rules will reach the Java .class limits or not. (This is also true for traditional javac compilers.) The sequential mode compiler can only estimate when Java .class limits will almost certainly be reached.

You can control the .class splitting that is performed by the sequential mode compiler using a code density property.

The generated bytecode density is a floating-point value between 0.1 and 2.

A low code density should be specified only when the rules are obviously complicated and individually crowded with code in the condition part or in the action part. Large amounts of code tend to consume the .class resources more quickly than small amounts.

A high code density should be specified only when the rules are obviously simple.

Important
The code density property is relevant only for troubleshooting. You would not normally need to adjust it.

You can specify the generated bytecode density for the sequential mode:

Specifying Code Density in IRL

You can specify the generated bytecode density in IRL at task level, or for a particular task.

To specify code density in IRL at task level:

ruletask T {
       property ilog.rules.engine.sequential.code.density = 0.5;
       algorithm = sequential;
       ...
}
Another means is to set a property at the ruleset level:
ruleset R {
       property ilog.rules.engine.sequential.code.density = 0.5;
}
 
ruletask T1 {
       algorithm = sequential;
       ...
}
 
ruletask T2 {
       algorithm = sequential;
       ...
}
In this case, the code density of the generated bytecode will be defined for both T1 and T2.

You can also define the code density for a particular task using a special generic notation.

To define the code density for a particular task:

ruleset R {
       property ilog.rules.engine.sequential.code.density.T1 = true;
}
 
ruletask T1 {
       algorithm = sequential;
       ...
}
 
ruletask T2 {
       algorithm = sequential;
       ...
}
In this case, a code density will be specified for T1 and not for T2.

Specifying Code Density Using the API

You can set the ruleset property using the API. In this case, you need to set the property prior to any parsing. This enables the code density property to be taken into account even in the static case where the sequential ruletask is defined by an explicit list of rule names.

To specify code density using the API:

package myPackage;
 
import ilog.rules.engine.IlrRuleset;
import ilog.rules.factory.IlrPropertyList;
 
public class MyCodeDensitySetter {
 
       public static void setCodeDensity(IlrRuleset rs,
                                         double density)
       {
          IlrPropertyList props = rs.getProperties();
          Double          density = new Double(density);
       
          // Pass a Double wrapper, not a String !
          props.put("ilog.rules.engine.sequential.code.density",wrapper);
       }
}

Specifying Code Density in Java

You can define the code density for the sequential mode by setting a Java property, typically when launching the application.

To specify code density in Java:

java -Dilog.rules.engine.sequential.code.density=0.5 myApp 

Notice that the name of the variable must be fully qualified with ilog.rules.engine so as not to conflict with other Java variables.

Related Concepts

Sequential

Related Tasks

Choosing an Execution Mode

Related Reference

The Sequential Algorithm

Related Samples and Tutorials

Rule-Based Programming