themaplelab / averroes

Java bytecode generator for sound and precise partial program analysis
Eclipse Public License 2.0
23 stars 7 forks source link

placeholder-lib removes inner classes #3

Closed quizzo closed 9 years ago

quizzo commented 9 years ago

Hello,

I ran Averroes on the following code: list is ArrayList<Integer> arraySimple = new ArrayList<Integer>(); that was assigned variables from a txt file via BufferedReader:

public static void useWhileLoop(Collection<Integer> list){
    Iterator<Integer> it = list.iterator();
    while(it.hasNext()){
        System.out.print(it.next());
    }
}

public static void useForLoop(Collection<Integer> list){
    for(Iterator<Integer> it = list.iterator(); it.hasNext(); ){
        System.out.println(it.next());
    }
}

the placeholder-lib.jar indicated that I need Java.Util.ArrayList but when it hollows it, it removes inner classes like iter, that is actually needed for a sound slice in the useForLoop case.

Any suggestions?

karimhamdanali commented 9 years ago

Hello,

Averroes will only remove classes that it think are not needed to be present in the generated placeholder file, which is obviously not the case here.

Could you please send me the input jar files for both the application and library, and the settings you used to run Averroes? I'll try to reproduce the problem on my side.

cheers, Karim

quizzo commented 9 years ago

Shared a dropbox link with you

quizzo commented 9 years ago

Any updates regarding this issue?

karimhamdanali commented 9 years ago

Hi quizzo,

I'm really sorry it took me so long to get back to you. I was caught up in some teaching duties.

True, Averroes hollows java.util.ArrayList of all its unnecessary members (fields, methods, classes). However, Averroes creates "stub" classes for method return types that it finds no candidates for. In your cases here, Averroes will create the class IteratorAverroes() that implements the Iterator interface. It will instantiate an object of that class inside the Averroes.doItAll() method. Therefore, calls to the iterator() method will return that object of type IteratorAverroes (which is a subtype of Iterator).

Isn't that the case for your example?

karimhamdanali commented 9 years ago

oh, I forgot to add that you might want to use the latest codebase of Averroes. I've updated it to use command line arguments instead of properties file (everything else is the same).

quizzo commented 9 years ago

Great. I think this issue may be marked as closed