[Soot-list] loading class files with Soot in abc

Ondrej Lhotak olhotak at uwaterloo.ca
Sun Feb 5 15:51:23 EST 2006


On Sun, Feb 05, 2006 at 04:37:54PM +0000, Oege de Moor wrote:
> In abc, we load *.class files for weaving with this bit of code
> (in abc.main.Main.loadJars)
> 
>        jari = OptionsParser.v().inpath().iterator();
>          while (jari.hasNext()) {
>              String jar = (String)jari.next();
>              List/*String*/ this_jar_classes =
>                 soot.SourceLocator.v().getClassesUnder(jar);
>              jar_classes.addAll(this_jar_classes);
>          }
> 
> Unfortunately, the call to getClassesUnder(..) picks up not
> only *.class files, but also *.java and *.jimple, which we
> do not want: it should pick up *.class and nothing else.
> 
> Any suggestions on what to do?

The getClassesUnder() method in Soot is a utility method that implements
the Soot -process-dir option, for which this is the defined semantics.
The ajc -inpath option (which abc presumably wants to emulate) has
different semantics than the Soot -process-dir option. Soot does not
have any option with equivalent semantics as the ajc -inpath option,
which is why Soot does not implement the ajc -inpath option.

I believe that the simplest and most logical solution is to not attempt
to call the Soot -process-dir code to implement the abc -inpath option,
but instead to implement the desired -inpath semantics. I said
this to the rest of the abc'ers way back when this part of abc
was first being written.

A second somewhat plausible alternative would be to attempt to
generalize and refactor the Soot code, so that parts of the same code
could be reused for both the Soot -process-dir option and the abc
-inpath option. However, the differences in semantics are big enough
that I think this would end up being more complicated than having two
separate implementations of the two different options. Not only do
-process-dir and -inpath expect different filename extensions, but the
ajc treatment of directories vs. jar files is also different.

Of course, parts of the -process-dir code could be used in writing the
-inpath implementation (i.e. cut, paste, and modify).

Ondrej



More information about the Soot-list mailing list