File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Sources/JavaKit/JavaKitVM Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ #if canImport(FoundationEssentials)
16
+ import FoundationEssentials
17
+ #else
18
+ import Foundation
19
+ #endif
20
+
15
21
typealias JavaVMPointer = UnsafeMutablePointer < JavaVM ? >
16
22
#if canImport(Android)
17
23
typealias JNIEnvPointer = UnsafeMutablePointer < JNIEnv ? >
@@ -59,6 +65,12 @@ public final class JavaVirtualMachine: @unchecked Sendable {
59
65
// Construct the complete list of VM options.
60
66
var allVMOptions : [ String ] = [ ]
61
67
if !classPath. isEmpty {
68
+ let fileManager = FileManager . default
69
+ for path in classPath {
70
+ if !fileManager. fileExists ( atPath: path) {
71
+ throw JavaKitError . classPathNotFound ( path)
72
+ }
73
+ }
62
74
let colonSeparatedClassPath = classPath. joined ( separator: " : " )
63
75
allVMOptions. append ( " -Djava.class.path= \( colonSeparatedClassPath) " )
64
76
}
@@ -283,4 +295,8 @@ extension JavaVirtualMachine {
283
295
}
284
296
}
285
297
}
298
+
299
+ enum JavaKitError : Error {
300
+ case classPathNotFound( String )
301
+ }
286
302
}
You can’t perform that action at this time.
0 commit comments