Skip to content

Commit 08e221e

Browse files
committed
wip
1 parent 6292835 commit 08e221e

File tree

3 files changed

+42
-46
lines changed

3 files changed

+42
-46
lines changed

Sources/SwiftJava/JVM/JavaVirtualMachine.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ extension JavaVirtualMachine {
190190

191191
// If we failed to attach, report that.
192192
if let attachError = VMError(fromJNIError: attachResult) {
193-
// throw attachError
194-
fatalError("JVM Error: \(attachError)")
193+
fatalError("JVM attach error: \(attachError)")
195194
}
196195

197196
JavaVirtualMachine.destroyTLS.set(jniEnv!)

Tests/SwiftJavaToolLibTests/CompileJavaWrapTools.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ func assertWrapJavaOutput(
9898
classpath: classpath.map(\.path),
9999
replace: false
100100
)
101+
102+
defer { try! jvm.destroyJVM() } // if this fails, we're kinda domed anyway, so allow the try!
101103

102104
var config = Configuration()
103105
config.minimumInputAccessLevelMode = .package

Tests/SwiftJavaToolLibTests/WrapJavaTests.swift

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,54 +49,49 @@ class WrapJavaTests: XCTestCase {
4949
}
5050

5151
func testWrapJavaGenericMethod_singleGeneric() async throws {
52-
do {
53-
let classpathURL = try await compileJava(
54-
"""
55-
package com.example;
52+
let classpathURL = try await compileJava(
53+
"""
54+
package com.example;
5655
57-
class Item<T> {
58-
final T value;
59-
Item(T item) {
60-
this.value = item;
61-
}
56+
class Item<T> {
57+
final T value;
58+
Item(T item) {
59+
this.value = item;
6260
}
63-
class Pair<First, Second> { }
61+
}
62+
class Pair<First, Second> { }
6463
65-
class ExampleSimpleClass {
66-
<KeyType> KeyType getGeneric(Item<KeyType> key) { return null; }
67-
}
68-
""")
64+
class ExampleSimpleClass {
65+
<KeyType> KeyType getGeneric(Item<KeyType> key) { return null; }
66+
}
67+
""")
6968

70-
try assertWrapJavaOutput(
71-
javaClassNames: [
72-
"com.example.Item",
73-
"com.example.Pair",
74-
"com.example.ExampleSimpleClass"
75-
],
76-
classpath: [classpathURL],
77-
expectedChunks: [
78-
"""
79-
import CSwiftJavaJNI
80-
import SwiftJava
81-
""",
82-
"""
83-
@JavaClass("com.example.ExampleSimpleClass")
84-
open class ExampleSimpleClass: JavaObject {
85-
""",
86-
"""
87-
@JavaClass("com.example.ExampleSimpleClass")
88-
open class ExampleSimpleClass: JavaObject {
89-
""",
90-
"""
91-
@JavaMethod
92-
open func getGeneric<KeyType: AnyJavaObject>(_ arg0: Item<KeyType>?) -> KeyType {
93-
""",
94-
]
95-
)
96-
} catch let error as Throwable {
97-
error.printStackTrace()
98-
XCTFail("error: \(error)")
99-
}
69+
try assertWrapJavaOutput(
70+
javaClassNames: [
71+
"com.example.Item",
72+
"com.example.Pair",
73+
"com.example.ExampleSimpleClass"
74+
],
75+
classpath: [classpathURL],
76+
expectedChunks: [
77+
"""
78+
import CSwiftJavaJNI
79+
import SwiftJava
80+
""",
81+
"""
82+
@JavaClass("com.example.ExampleSimpleClass")
83+
open class ExampleSimpleClass: JavaObject {
84+
""",
85+
"""
86+
@JavaClass("com.example.ExampleSimpleClass")
87+
open class ExampleSimpleClass: JavaObject {
88+
""",
89+
"""
90+
@JavaMethod
91+
open func getGeneric<KeyType: AnyJavaObject>(_ arg0: Item<KeyType>?) -> KeyType {
92+
""",
93+
]
94+
)
10095
}
10196

10297
// This is just a warning in Java, but a hard error in Swift, so we must 'prune' generic params

0 commit comments

Comments
 (0)