Skip to content

Commit 98038f9

Browse files
authored
Merge branch 'main' into wip-build-cleanup
2 parents 721cb77 + a64f805 commit 98038f9

17 files changed

+88
-42
lines changed

Package.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,31 @@ let package = Package(
5353
// ==== JavaKit (i.e. calling Java directly Swift utilities)
5454
.library(
5555
name: "JavaKit",
56-
type: .dynamic,
5756
targets: ["JavaKit"]
5857
),
5958

6059
.library(
6160
name: "JavaKitJar",
62-
type: .dynamic,
6361
targets: ["JavaKitReflection"]
6462
),
6563

6664
.library(
6765
name: "JavaKitNetwork",
68-
type: .dynamic,
6966
targets: ["JavaKitReflection"]
7067
),
7168

7269
.library(
7370
name: "JavaKitReflection",
74-
type: .dynamic,
7571
targets: ["JavaKitReflection"]
7672
),
7773

7874
.library(
7975
name: "JavaKitVM",
80-
type: .dynamic,
8176
targets: ["JavaKitVM"]
8277
),
8378

8479
.library(
8580
name: "JavaTypes",
86-
type: .dynamic,
8781
targets: ["JavaTypes"]
8882
),
8983

@@ -108,7 +102,6 @@ let package = Package(
108102

109103
.library(
110104
name: "JExtractSwift",
111-
type: .dynamic,
112105
targets: ["JExtractSwift"]
113106
),
114107

Sources/Java2Swift/JavaToSwift.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import JavaKitJar
1919
import JavaKitNetwork
2020
import JavaKitReflection
2121
import JavaKitVM
22-
import JavaRuntime
2322
import SwiftSyntax
2423
import SwiftSyntaxBuilder
2524

Sources/JavaKit/AnyJavaObject.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ extension AnyJavaObject {
8181
}
8282

8383
/// Retrieve the Java class for this type.
84-
public static func getJNIClass(in environment: JNIEnvironment) -> jclass? {
85-
return environment.interface.FindClass(
86-
environment,
87-
fullJavaClassNameWithSlashes
88-
)
84+
public static func getJNIClass(in environment: JNIEnvironment) throws -> jclass {
85+
try environment.translatingJNIExceptions {
86+
environment.interface.FindClass(
87+
environment,
88+
fullJavaClassNameWithSlashes
89+
)
90+
}!
8991
}
9092
}

Sources/JavaKit/BridgedValues/JavaValue+Array.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import JavaRuntime
1615
import JavaTypes
1716

1817
extension Array: JavaValue where Element: JavaValue {

Sources/JavaKit/BridgedValues/JavaValue+Bool.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import JavaRuntime
1615
import JavaTypes
1716

1817
extension Bool: JavaValue {

Sources/JavaKit/BridgedValues/JavaValue+FloatingPoint.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import JavaRuntime
1615
import JavaTypes
1716

1817
extension Float: JavaValue {

Sources/JavaKit/BridgedValues/JavaValue+Integers.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import JavaRuntime
1615
import JavaTypes
1716

1817
extension Int8: JavaValue {

Sources/JavaKit/BridgedValues/JavaValue+String.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import JavaRuntime
1615
import JavaTypes
1716

1817
extension String: JavaValue {

Sources/JavaKit/Exceptions/ExceptionHandling.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension JNIEnvironment {
4242
// Otherwise, create a exception with a message.
4343
_ = interface.ThrowNew(
4444
self,
45-
JavaClass<Exception>.getJNIClass(in: self),
45+
try! JavaClass<Exception>.getJNIClass(in: self),
4646
String(describing: error)
4747
)
4848
}

Sources/JavaKit/JavaClass.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ import JavaRuntime
1717
/// Wrapper around a Java class that provides access to the static members of
1818
/// the class.
1919
@JavaClass("java.lang.Class")
20-
public struct JavaClass<ObjectType: AnyJavaObject> { }
20+
public struct JavaClass<ObjectType: AnyJavaObject> {
21+
/// Lookup this Java class within the given environment.
22+
public init(in environment: JNIEnvironment) throws {
23+
self.init(
24+
javaThis: try ObjectType.getJNIClass(in: environment),
25+
environment: environment
26+
)
27+
}
28+
}

0 commit comments

Comments
 (0)