themaplelab / averroes

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

Running averroes on a project that uses javax/crypto #4

Closed quizzo closed 8 years ago

quizzo commented 9 years ago

When I am trying to run Averroes on a project that uses javax/crypto

I am getting the following error Loading classes ... soot.SootResolver$SootClassNotFoundException: couldn't find class: javax.crypto.Cipher (is your soot-class-path set properly?) Try adding jce.jar to Soot's classpath, e.g.: java -cp sootclasses.jar soot.Main -cp .:/path/to/jdk/jre/lib/rt.jar:/path/to/jdk/jre/lib/jce.jar at soot.SootResolver.bringToHierarchy(SootResolver.java:226) at soot.SootResolver.processResolveWorklist(SootResolver.java:171) at soot.SootResolver.resolveClass(SootResolver.java:129) at soot.Scene.loadClass(Scene.java:702) at soot.Scene.loadClassAndSupport(Scene.java:687) at soot.Scene.loadNecessaryClass(Scene.java:1339) at soot.Scene.loadNecessaryClasses(Scene.java:1350) at averroes.Main.main(Main.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)

My rt.jar file is located in jre = ./java/jre7/lib/rt.jar and under java/jre7/lib I also have jce.jar , but for some reason ave. would not find it as indicated by the error java -cp sootclasses.jar soot.Main -cp .:/path/to/jdk/jre/lib/rt.jar:/path/to/jdk/jre/lib/jce.jar

any suggestions?

karimhamdanali commented 9 years ago

Hi quizzo,

Which version of Averroes are you using? Is it the latest code-base from github? If so you need to specify the path to the JRE (where rt.jar and jce.jar are located) via the command-line arguments (Averroes no longer uses the properties file).

If you're still using the older version of Averroes with the properties file, you need to add jce.jar to the library_jars property there for it to work as Averroes won't search for other jars where rt.jar is (which is a bug I fixed in the latest version of Averroes).

cheers,

quizzo commented 9 years ago

Using an older version. Is there a readme file on how to build the new averroes ?

quizzo commented 9 years ago

Further is it possible to: a) Make averroes build with jars of soot/etc. over building several dependencies before one can build Averroes. or b) Have an Averroes jar ready for use, for users who only want to use Averroes right out of the repo?

karimhamdanali commented 9 years ago

The codebase is an Eclipse project, so you can just import it to Eclipse. There's an ANT script within averroes as well (https://github.com/karimhamdanali/averroes/blob/master/jar/averroes.xml) that you can use to generate a self-contained runnable JAR file for averroes. This ANT script assumes the presence of the project dependencies (soot, jasmin, probe, and WALA) within the same Eclipse workspace.

I'll add to my TODO list to improve the documentation on how to build Averroes from source, and I'll also make a runnable JAR available for users who just want to use it.

karimhamdanali commented 9 years ago

I've just checked in a runnable JAR at master/jar/averroes.jar that you can run as

java -jar averroes.jar [options]
quizzo commented 9 years ago

Hey Karmin,

Thank you for that jar, few comments:

a) Might be useful to add a --help flag, I am using https://github.com/karimhamdanali/averroes/blob/master/src/averroes/options/AverroesOptions.java to figure out the flags

b) for the -o option, if the directory classes is not already there, the jar will fail java.lang.IllegalArgumentException: ./classes does not exist

karimhamdanali commented 9 years ago

Hey quizzo,

a) sure, I'll add that later this week b) hmm, that's a bug in averroes that I'll also fix later this week c) I think you might want to lose the double quotes for the parameters. This message is the message commons-cli issues when there's something wrong with the command line arguments passed to the program.