typetools / checker-framework-inference

Inference of pluggable types for Java
10 stars 33 forks source link

Explicitly call SystemClassLoader load class in InferenceMain #33

Closed CharlesZ-Chen closed 8 years ago

CharlesZ-Chen commented 8 years ago

In InferenceMain#getRealChecker() and InferenceMain#getSolver(), we have code using URLClassLoader to load Checker class and Solver class.

However, this code is confusing and misleading, because the parent directory of checker-framework-Inference is never an effective bin dir that directly contains .class files. Also, an instance of URLClassLoader will not do a recursive searching of it's URLs, which means the URLClassLoader will never load classes by itself.

The previous code accidentally works when shell script has export classpath of Checker and Solver in environment variable CLASSPATH. This is because SystemClassLoader is an ancestor class of URLClassLoader, and thus the class files of Checker and Solver is actually loaded by SystemClassLoader through env variable CLASSPATH.

To make code be clearer on it's real behaviour, I changed code to explicitly call SystemClassLoader to load Checker and Solver class files.