Skip to content

Commit b9fd0a4

Browse files
committed
review followup: assertion message
1 parent 52d4d92 commit b9fd0a4

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+SwiftThunkPrinting.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,8 @@ extension JNISwift2JavaGenerator {
356356
}
357357
assert(\(selfPointerParam.name) != 0, "\(selfPointerParam.name) memory address was null")
358358
let selfBits$ = Int(Int64(fromJNI: \(selfPointerParam.name), in: env$))
359-
assert(selfBits$ != 0, "$self memory address was null: \(selfPointerParam.name) = \\(\(selfPointerParam.name))" )
360359
guard let \(newSelfParamName) = UnsafeMutablePointer<\(swiftParentName)>(bitPattern: selfBits$) else {
361-
fatalError("Missing self pointer in call to \\(#function)!")
360+
fatalError("self memory address was null in call to \\(#function)!")
362361
}
363362
"""
364363
)

Tests/JExtractSwiftTests/JNI/JNIClassTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,8 @@ struct JNIClassTests {
212212
}
213213
assert(selfPointer != 0, "selfPointer memory address was null")
214214
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
215-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
216215
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
217-
fatalError("Missing self pointer in call to \\(#function)!")
216+
fatalError("self memory address was null in call to \\(#function)!")
218217
}
219218
self$.deinitialize(count: 1)
220219
self$.deallocate()
@@ -266,9 +265,8 @@ struct JNIClassTests {
266265
}
267266
assert(selfPointer != 0, "selfPointer memory address was null")
268267
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
269-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
270268
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
271-
fatalError("Missing self pointer in call to \\(#function)!")
269+
fatalError("self memory address was null in call to \\(#function)!")
272270
}
273271
self$.pointee.doSomething(x: Int64(fromJNI: x, in: environment!))
274272
}

Tests/JExtractSwiftTests/JNI/JNIStructTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ struct JNIStructTests {
144144
}
145145
assert(selfPointer != 0, "selfPointer memory address was null")
146146
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
147-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
148147
guard let self$ = UnsafeMutablePointer<MyStruct>(bitPattern: selfBits$) else {
149-
fatalError("Missing self pointer in call to \\(#function)!")
148+
fatalError("self memory address was null in call to \\(#function)!")
150149
}
151150
self$.deinitialize(count: 1)
152151
self$.deallocate()
@@ -198,9 +197,8 @@ struct JNIStructTests {
198197
}
199198
assert(selfPointer != 0, "selfPointer memory address was null")
200199
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
201-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
202200
guard let self$ = UnsafeMutablePointer<MyStruct>(bitPattern: selfBits$) else {
203-
fatalError("Missing self pointer in call to \\(#function)!")
201+
fatalError("self memory address was null in call to \\(#function)!")
204202
}
205203
self$.pointee.doSomething(x: Int64(fromJNI: x, in: environment!))
206204
}

Tests/JExtractSwiftTests/JNI/JNIVariablesTests.swift

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ struct JNIVariablesTests {
7474
}
7575
assert(selfPointer != 0, "selfPointer memory address was null")
7676
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
77-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
7877
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
79-
fatalError("Missing self pointer in call to \\(#function)!")
78+
fatalError("self memory address was null in call to \\(#function)!")
8079
}
8180
let result = self$.pointee.constant
8281
return result.getJNIValue(in: environment)
@@ -144,9 +143,8 @@ struct JNIVariablesTests {
144143
}
145144
assert(selfPointer != 0, "selfPointer memory address was null")
146145
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
147-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
148146
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
149-
fatalError("Missing self pointer in call to \\(#function)!")
147+
fatalError("self memory address was null in call to \\(#function)!")
150148
}
151149
let result = self$.pointee.mutable
152150
return result.getJNIValue(in: environment)
@@ -160,9 +158,8 @@ struct JNIVariablesTests {
160158
}
161159
assert(selfPointer != 0, "selfPointer memory address was null")
162160
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
163-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
164161
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
165-
fatalError("Missing self pointer in call to \\(#function)!")
162+
fatalError("self memory address was null in call to \\(#function)!")
166163
}
167164
self$.pointee.mutable = Int64(fromJNI: newValue, in: environment!)
168165
}
@@ -214,9 +211,8 @@ struct JNIVariablesTests {
214211
}
215212
assert(selfPointer != 0, "selfPointer memory address was null")
216213
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
217-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
218214
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
219-
fatalError("Missing self pointer in call to \\(#function)!")
215+
fatalError("self memory address was null in call to \\(#function)!")
220216
}
221217
222218
let result = self$.pointee.computed
@@ -270,9 +266,8 @@ struct JNIVariablesTests {
270266
}
271267
assert(selfPointer != 0, "selfPointer memory address was null")
272268
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
273-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
274269
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
275-
fatalError("Missing self pointer in call to \\(#function)!")
270+
fatalError("self memory address was null in call to \\(#function)!")
276271
}
277272
278273
do {
@@ -346,9 +341,8 @@ struct JNIVariablesTests {
346341
}
347342
assert(selfPointer != 0, "selfPointer memory address was null")
348343
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
349-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
350344
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
351-
fatalError("Missing self pointer in call to \\(#function)!")
345+
fatalError("self memory address was null in call to \\(#function)!")
352346
}
353347
354348
let result = self$.pointee.getterAndSetter
@@ -363,9 +357,8 @@ struct JNIVariablesTests {
363357
}
364358
assert(selfPointer != 0, "selfPointer memory address was null")
365359
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
366-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
367360
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
368-
fatalError("Missing self pointer in call to \\(#function)!")
361+
fatalError("self memory address was null in call to \\(#function)!")
369362
}
370363
371364
self$.pointee.getterAndSetter = Int64(fromJNI: newValue, in: environment!)
@@ -433,9 +426,8 @@ struct JNIVariablesTests {
433426
}
434427
assert(selfPointer != 0, "selfPointer memory address was null")
435428
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
436-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
437429
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
438-
fatalError("Missing self pointer in call to \\(#function)!")
430+
fatalError("self memory address was null in call to \\(#function)!")
439431
}
440432
let result = self$.pointee.someBoolean
441433
return result.getJNIValue(in: environment)
@@ -449,9 +441,8 @@ struct JNIVariablesTests {
449441
}
450442
assert(selfPointer != 0, "selfPointer memory address was null")
451443
let selfBits$ = Int(Int64(fromJNI: selfPointer, in: env$))
452-
assert(selfBits$ != 0, "$self memory address was null: selfPointer = \\(selfPointer)" )
453444
guard let self$ = UnsafeMutablePointer<MyClass>(bitPattern: selfBits$) else {
454-
fatalError("Missing self pointer in call to \\(#function)!")
445+
fatalError("self memory address was null in call to \\(#function)!")
455446
}
456447
self$.pointee.someBoolean = Bool(fromJNI: newValue, in: environment!)
457448
}

0 commit comments

Comments
 (0)