Fixes IllegalStateException (#358)

* Fixes IllegalStateException

Reverts refactored code with try-with-resource back to potentially
leaking implementation. The refactored code threw an exception since
JarFileModule does not implement the AutoClosable interface. Further,
removed the printStackTrace() call, as this is not an exceptional case
but intended control-flow in case DexFileModule creation fails.

* Downgrade JarFile leak diagnostic from warning to error

This is consistent with how we are treating potential JarFile leaks in
other WALA components.  WALA issue #236 already notes that these
should be cleaned up eventually, although doing so will not be easy.
This commit is contained in:
Erik Derr 2018-09-30 21:19:14 +02:00 committed by Manu Sridharan
parent 6fd67b886e
commit 751444a656
2 changed files with 2 additions and 5 deletions

View File

@ -78,7 +78,7 @@ org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=error
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=error
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=error
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=error
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error

View File

@ -50,10 +50,7 @@ public class AndroidAnalysisScope {
try {
scope.addToScope(ClassLoaderReference.Primordial, DexFileModule.make(new File(al)));
} catch (Exception e) {
e.printStackTrace();
try (final JarFile jar = new JarFile(new File(al))) {
scope.addToScope(ClassLoaderReference.Primordial, new JarFileModule(jar));
}
scope.addToScope(ClassLoaderReference.Primordial, new JarFileModule(new JarFile(new File(al))));
}
}