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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user