Minor, use "use" to automatically close JarFile

JarFile extends Closeable on JDK 8, so we can use "use" here now
This commit is contained in:
Alexander Udalov
2017-03-29 17:28:18 +03:00
parent cbc893ed17
commit 3b8110f51c
5 changed files with 5 additions and 29 deletions
@@ -77,13 +77,9 @@ class MainClassRunner(override val className: String) : AbstractRunner() {
class JarRunner(private val path: String) : AbstractRunner() {
override val className: String =
try {
val jar = JarFile(path)
try {
JarFile(path).use { jar ->
jar.manifest.mainAttributes.getValue(Attributes.Name.MAIN_CLASS)
}
finally {
jar.close()
}
}
catch (e: IOException) {
throw RunnerException("could not read manifest from " + path + ": " + e.message)