@@ -2,18 +2,19 @@ package dotty.tools.dotc.classpath
2
2
3
3
import dotty .tools .dotc .core .Contexts .Context
4
4
5
- import java .io .ByteArrayOutputStream
5
+ import java .io .{ ByteArrayOutputStream , IOException }
6
6
import java .nio .file .{FileSystems , Files , Path }
7
7
import java .util .jar .Attributes
8
8
import java .util .jar .Attributes .Name
9
9
10
- import org .junit .Test
11
10
import org .junit .Assert ._
11
+ import org .junit .Test
12
12
13
- import scala .util .Properties
14
13
import scala .collection .JavaConverters ._
14
+ import scala .util .Properties
15
15
16
16
class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
17
+
17
18
@ Test
18
19
def mrJar (): Unit = {
19
20
if (! Properties .isJavaAtLeast(" 9" )) { println(" skipping mrJar() on old JDK" ); return }
@@ -61,7 +62,10 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
61
62
if Properties .isJavaAtLeast(" 10" ) then
62
63
assertEquals(Set (" foo1" , " foo2" , " bar1" , " bar2" ), apiMethods(jar3, " 10" ))
63
64
} 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
+ )
65
69
}
66
70
67
71
@ Test
@@ -82,7 +86,6 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
82
86
assertTrue(classExists(" java.lang.invoke.LambdaMetafactory" , " 9" ))
83
87
}
84
88
85
-
86
89
private def createManifest = {
87
90
val manifest = new java.util.jar.Manifest ()
88
91
manifest.getMainAttributes.put(Name .MANIFEST_VERSION , " 1.0" )
@@ -92,6 +95,7 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
92
95
val manifestBytes = os.toByteArray
93
96
manifestBytes
94
97
}
98
+
95
99
private def createZip (zipLocation : Path , content : List [(String , Array [Byte ])]): Unit = {
96
100
val env = new java.util.HashMap [String , String ]()
97
101
Files .deleteIfExists(zipLocation)
@@ -113,4 +117,5 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
113
117
zipfs.close()
114
118
}
115
119
}
120
+
116
121
}
0 commit comments