Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Sources/JavaKit/JavaKitVM/JavaVirtualMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that's the way, thank you


typealias JavaVMPointer = UnsafeMutablePointer<JavaVM?>

public final class JavaVirtualMachine: @unchecked Sendable {
Expand Down Expand Up @@ -54,6 +60,12 @@ public final class JavaVirtualMachine: @unchecked Sendable {
// Construct the complete list of VM options.
var allVMOptions: [String] = []
if !classPath.isEmpty {
let fileManager = FileManager.default
for path in classPath {
if !fileManager.fileExists(atPath: path) {
throw JavaKitError.classPathEntryNotFound(entry: path, classPath: classPath)
}
}
let colonSeparatedClassPath = classPath.joined(separator: ":")
allVMOptions.append("-Djava.class.path=\(colonSeparatedClassPath)")
}
Expand Down Expand Up @@ -268,4 +280,8 @@ extension JavaVirtualMachine {
}
}
}

enum JavaKitError: Error {
case classPathEntryNotFound(entry: String, classPath: [String])
}
}