Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ let package = Package(
targets: ["CSwiftJavaJNI"]
),

.library(
name: "SwiftJavaConfigurationShared",
targets: ["SwiftJavaConfigurationShared"]
),

.library(
name: "JavaUtil",
targets: ["JavaUtil"]
Expand Down Expand Up @@ -297,7 +302,6 @@ let package = Package(
"CSwiftJavaJNI",
"SwiftJavaMacros",
"JavaTypes",
"SwiftJavaConfigurationShared", // for Configuration reading at runtime
],
exclude: ["swift-java.config"],
swiftSettings: [
Expand Down
1 change: 1 addition & 0 deletions Samples/JavaDependencySampleApp/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ let package = Package(
name: "JavaDependencySample",
dependencies: [
.product(name: "SwiftJava", package: "swift-java"),
.product(name: "SwiftJavaConfigurationShared", package: "swift-java"),
.product(name: "CSwiftJavaJNI", package: "swift-java"),
.product(name: "JavaUtilFunction", package: "swift-java"),
"JavaCommonsCSV"
Expand Down
13 changes: 8 additions & 5 deletions Sources/SwiftJava/String+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension String {
/// For a String that's of the form java.util.Vector, return the "Vector" part.
Expand All @@ -30,11 +34,10 @@ extension String {
/// Convert a Java class name to its canonical name.
/// Replaces `$` with `.` for nested classes but preserves `$` at the start of identifiers.
package var javaClassNameToCanonicalName: String {
self.replacingOccurrences(
of: #"(?<=\w)\$"#,
with: ".",
options: .regularExpression
)
let regex = try! Regex(#"(\w)\$"#, as: (Substring, Substring).self)
return self.replacing(regex) { match in
"\(match.output.1)."
}
}

/// Whether this is the name of an anonymous class.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftJavaRuntimeSupport/_JNIMethodIDCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final class _JNIMethodIDCache: Sendable {
fatalError("Cannot get JNI.shared, it should have been initialized by JNI_OnLoad when loading the library")
}
guard let javaClass = try? jni.applicationClassLoader?.loadClass(
className.replacingOccurrences(of: "/", with: ".")
className.replacing("/", with: ".")
) else {
fatalError("Class \(className) could not be found!")
}
Expand Down
Loading