[Soot-list] JavaToJimple : OutOfMemory

Barthelemy Dagenais barthed at hotmail.com
Wed Jan 16 09:50:14 EST 2008


Hi,

I'm still stuck with bad performance (read: impossible to compile) even when 
disabling "optional" passes such as exception checking, but I think I found in 
the process of investigating this issue a bug in 
soot.javaToJimple.InitialResolver regarding anonymous classes.

Basically, if two classes (A and B) define an anonymous class (A$1 and B$1) 
which is a subtype of the same parent class, and one of the class refers to the 
other (A refers to B), you get the following exception.

Anyone encountered that bug before?

Exception in thread "main" polyglot.util.InternalCompilerError: we are 
JjTypeSystem_c but anontest.Outer2 is from JjTypeSystem_c
         at polyglot.ext.jl.types.TypeSystem_c.assert_(TypeSystem_c.java:131)
         at polyglot.ext.jl.types.TypeSystem_c.equals(TypeSystem_c.java:294)
         at polyglot.ext.jl.types.TypeObject_c.equals(TypeObject_c.java:65)
         at 
soot.javaToJimple.InitialResolver.createAnonClassName(InitialResolver.java:250)
         at 
soot.javaToJimple.InitialResolver.createLocalAndAnonClassNames(InitialResolver.java:214)
         at 
soot.javaToJimple.InitialResolver.buildInnerClassInfo(InitialResolver.java:364)
         at soot.javaToJimple.InitialResolver.resolveAST(InitialResolver.java:165)
         at soot.javaToJimple.InitialResolver.formAst(InitialResolver.java:115)
         at soot.JavaClassSource.resolve(JavaClassSource.java:46)
         at soot.SootResolver.bringToHierarchy(SootResolver.java:148)
         at soot.SootResolver.processResolveWorklist(SootResolver.java:105)
         at soot.SootResolver.resolveClass(SootResolver.java:89)
         at soot.Scene.loadClass(Scene.java:336)
         at soot.Scene.loadClassAndSupport(Scene.java:321)
         at soot.Scene.loadNecessaryClass(Scene.java:868)
         at soot.Scene.loadNecessaryClasses(Scene.java:887)
         at soot.Main.run(Main.java:170)
         at soot.Main.main(Main.java:146)

Here is the code to reproduce the bug:

Outer1.java

package anontest;

public class Outer1 {

	private Outer2 outer2;
	
	public void method1() {
		
		
		Template template1 = new Template() {
			public void doSomething() {
				System.out.println();
			}
		};
		
		template1.doSomething();
		
		
		outer2.method2();
	}
	
}

Outer2.java

package anontest;

public class Outer2 {

	public void method2() {
		Template template2 = new Template() {
			public void doSomething() {
				System.out.println();
			}
		};
		template2.doSomething();
	}
	
}

Template.java

package anontest;

public class Template {

	public void doSomething() {
		
	}
	
}

Command to launch (unmodified) soot:

java -Xms512m -Xmx1512m -cp 
"$HOME/installation/soot/jasminclasses-2.2.4.jar:$HOME/installation/soot/polyglotclasses-1.3.4.jar:$HOME/installation/soot/sootclasses-2.2.4.jar:$HOME/installation/soot/java_cup.jar" 
soot.Main -soot-class-path 
"$HOME/installation/j2sdk1.4.2_16/jre/lib/rt.jar:$HOME/workspaces/main/TestProject/src/" 
-src-prec java -output-format jimple -output-dir 
"$HOME/temp/ppabench/jythonjimple/" anontest.Outer1



This seems to be caused by the following line (250) in 
InitialResolver:createAnonClassName:

if (outerMatch.equals(outerToMatch)) {

Basically, outerMatch and outerToMatch have different "TypeSystem" so they are 
not equal: the default behavior of polyglot is to throw an exception instead of 
returning false when the type systems differ. I think one might want to add the 
following check:

if (outerMatch.typeSystem() == outerToMatch.typeSystem() && 
outerMatch.equals(outerToMatch)){

This worked for me, but I don't know if it can generalize. There is also the 
same problem when building local classes (InitialResolver:createLocalClassName).

Sorry if this is not the place to report the bug, I can also fill a bug in 
bugzilla...

Barthélémy





Eric Bodden wrote:
> Looks like a polyglot issue to me. I can look after it when I return
> to Montreal (in 5 days), if you like.
> 
> Eric
> 
> On 16/01/2008, Barthelemy Dagenais <barthed at hotmail.com> wrote:
>> Hi,
>>
>> I tried to convert a java source file into a jimple file but got an
>> OutOfMemoryException after ~two minutes (see below).
>>
>> The java file is from Jython, a program from the DaCapo suite. When I try to
>> convert the corresponding class file into a jimple file, it takes only one
>> second. I also tried to convert several source files from Jython, but was unable
>> to do so because of this exception. Any thoughts on how to proceed and why I'm
>> getting this error?
>>
>> I'm using soot version 2.2.4 (although -version says it's 2.2.3) and I'm able to
>> convert java source files from smaller toy projects into jimple files.
>>
>> Thanks,
>> Barthélémy
>>
>>




More information about the Soot-list mailing list