@@ -2,18 +2,19 @@ package dotty.tools.dotc.classpath
22
33import dotty .tools .dotc .core .Contexts .Context
44
5- import java .io .ByteArrayOutputStream
5+ import java .io .{ ByteArrayOutputStream , IOException }
66import java .nio .file .{FileSystems , Files , Path }
77import java .util .jar .Attributes
88import java .util .jar .Attributes .Name
99
10- import org .junit .Test
1110import org .junit .Assert ._
11+ import org .junit .Test
1212
13- import scala .util .Properties
1413import scala .collection .JavaConverters ._
14+ import scala .util .Properties
1515
1616class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
17+
1718 @ Test
1819 def mrJar (): Unit = {
1920 if (! Properties .isJavaAtLeast(" 9" )) { println(" skipping mrJar() on old JDK" ); return }
@@ -61,7 +62,10 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
6162 if Properties .isJavaAtLeast(" 10" ) then
6263 assertEquals(Set (" foo1" , " foo2" , " bar1" , " bar2" ), apiMethods(jar3, " 10" ))
6364 } finally
64- List (jar1, jar2, jar3).foreach(Files .deleteIfExists)
65+ List (jar1, jar2, jar3).forall(path =>
66+ try Files .deleteIfExists(path)
67+ catch case _ : IOException => false
68+ )
6569 }
6670
6771 @ Test
@@ -82,7 +86,6 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
8286 assertTrue(classExists(" java.lang.invoke.LambdaMetafactory" , " 9" ))
8387 }
8488
85-
8689 private def createManifest = {
8790 val manifest = new java.util.jar.Manifest ()
8891 manifest.getMainAttributes.put(Name .MANIFEST_VERSION , " 1.0" )
@@ -92,6 +95,7 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
9295 val manifestBytes = os.toByteArray
9396 manifestBytes
9497 }
98+
9599 private def createZip (zipLocation : Path , content : List [(String , Array [Byte ])]): Unit = {
96100 val env = new java.util.HashMap [String , String ]()
97101 Files .deleteIfExists(zipLocation)
@@ -113,4 +117,5 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
113117 zipfs.close()
114118 }
115119 }
120+
116121}
0 commit comments