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
17
23
public final class JavaVirtualMachine : @unchecked Sendable {
@@ -54,6 +60,12 @@ public final class JavaVirtualMachine: @unchecked Sendable {
54
60
// Construct the complete list of VM options.
55
61
var allVMOptions : [ String ] = [ ]
56
62
if !classPath. isEmpty {
63
+ let fileManager = FileManager . default
64
+ for path in classPath {
65
+ if !fileManager. fileExists ( atPath: path) {
66
+ throw JavaKitError . classPathEntryNotFound ( entry: path, classPath: classPath)
67
+ }
68
+ }
57
69
let colonSeparatedClassPath = classPath. joined ( separator: " : " )
58
70
allVMOptions. append ( " -Djava.class.path= \( colonSeparatedClassPath) " )
59
71
}
@@ -268,4 +280,8 @@ extension JavaVirtualMachine {
268
280
}
269
281
}
270
282
}
283
+
284
+ enum JavaKitError : Error {
285
+ case classPathEntryNotFound( entry: String , classPath: [ String ] )
286
+ }
271
287
}
You can’t perform that action at this time.
0 commit comments