[jboss-jira] [JBoss JIRA] Reopened: (JBRULES-1013) Two functions with Janino compiler end up with out of memory error
Edson Tirelli (JIRA)
jira-events at lists.jboss.org
Wed Jul 25 10:11:47 EDT 2007
[ http://jira.jboss.com/jira/browse/JBRULES-1013?page=all ]
Edson Tirelli reopened JBRULES-1013:
------------------------------------
Edson,
I think that the bug is not corrected when using Janino compiler. Here
is a simple modification of the
testFunctionCallingFunction test
(org.drools.integrationtests.MiscTest.java) that fails with
java.lang.OutOfMemoryError. The modification is only an addition of the
first tree lines.
public void testFunctionCallingFunctionJanino() throws Exception {
final PackageBuilderConfiguration config = new
PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = ( JavaDialectConfiguration )
config.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.JANINO );
final PackageBuilder builder = new PackageBuilder( config );
builder.addPackageFromDrl( new InputStreamReader(
getClass().getResourceAsStream( "test_functionCallingFunction.drl" ) ) );
final Package pkg = builder.getPackage();
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final List list = new ArrayList();
workingMemory.setGlobal( "results",
list );
workingMemory.fireAllRules();
assertEquals( 1,
list.size() );
}
It fails when compiling the classes generated for the functions. The two
classes look like :
package test;
import static test.Func2.func2;
public class Func1 {
private static final long serialVersionUID = 400L;
public static boolean func1() throws Exception {
return true;,
}
}
package test;
import static test.Func1.func1;
public class Func2 {
private static final long serialVersionUID = 400L;
public static boolean func2() throws Exception {
return true;,
}
}
When compiling Func1, the compiler ask for compiling Func2 because of
the import statement. But to compile Func2, the compiler needs Func1 and
so on.
> Two functions with Janino compiler end up with out of memory error
> ------------------------------------------------------------------
>
> Key: JBRULES-1013
> URL: http://jira.jboss.com/jira/browse/JBRULES-1013
> Project: JBoss Rules
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Environment: Ubuntu Feisty, JDK 1.4 or 1.5, Drools Snapshot
> Reporter: Pierre Paysant-Le Roux
> Assigned To: Edson Tirelli
> Fix For: 4.0.0.GA
>
>
> Compiling a simple rules file containing two functions with janino causes an out of memory error.
> Rules file example :
> package test
> function boolean func1() {
> return true;
> }
> function boolean func2() {
> return true;
> }
> rule "test"
> when
> Object()
> then
> System.out.println("fired");
> end
> and the code that generate the error :
> package test;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.util.Properties;
> import org.drools.compiler.DroolsParserException;
> import org.drools.compiler.PackageBuilder;
> import org.drools.compiler.PackageBuilderConfiguration;
> public class Test {
> public static void main (String[] args) {
> Properties properties = new Properties();
> properties.setProperty("drools.dialect.java.compiler",
> "JANINO");
> PackageBuilderConfiguration pkgBuilderCfg = new PackageBuilderConfiguration(properties);
> PackageBuilder builder = new PackageBuilder(pkgBuilderCfg);
> try {
> builder.addPackageFromDrl(getSource());
> } catch (DroolsParserException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
> private static InputStreamReader getSource() {
> return new InputStreamReader(Test.class.getResourceAsStream( "Sample.drl" ));
> }
> }
> After profiling, I identified that the problematic line is the 146 one in class JaninoJavaCompiler. It causes the loadIClass method to loop with a cycle that I don't understand. Placing a breakpoint on the line 91 of JaninoJavaCompiler class permit to observe the loop iterations.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list