Skip to content

Commit 17be00b

Browse files
committed
Install fix for using nothing as null. Closes #130
1 parent d30ca80 commit 17be00b

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "JavaCall"
22
uuid = "494afd89-becb-516b-aafa-70d2670c0337"
3-
version = "0.7.5"
3+
version = "0.7.6"
44

55
[deps]
66
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"

src/convert.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ convert(::Type{JavaObject{:short}}, n) = convert(jshort, n)
2121
convert(::Type{JavaObject{:float}}, n) = convert(jfloat, n)
2222
convert(::Type{JavaObject{:double}}, n) = convert(jdouble, n)
2323
convert(::Type{JavaObject{:void}}, n) = convert(jvoid, n)
24-
convert(::Type{JavaObject{T}}, ::Nothing) where T = jnull
24+
convert(o::Type{JavaObject{T}}, ::Nothing) where T = o(J_NULL)
2525

2626
#Cast java object from S to T . Needed for polymorphic calls
2727
function convert(::Type{JavaObject{T}}, obj::JavaObject{S}) where {T,S}

src/core.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ JavaGlobalRef(ref::JavaRef) = JavaGlobalRef(JNI.NewGlobalRef(Ptr(ref)))
5252
# _deleteref does local/global reference deletion without null or state checking
5353
_deleteref(ref::JavaLocalRef ) = JNI.DeleteLocalRef( Ptr(ref))
5454
_deleteref(ref::JavaGlobalRef) = JNI.DeleteGlobalRef(Ptr(ref))
55+
_deleteref(ref::JavaNullRef) = nothing
5556

5657
"""
5758
deleteref deletes a JavaRef using either JNI.DeleteLocalRef or JNI.DeleteGlobalRef

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ JAVACALL_FORCE_ASYNC_TEST = get(ENV,"JAVACALL_FORCE_ASYNC_TEST","") ∈ ("1","ye
3030
end
3131

3232
System = @jimport java.lang.System
33+
System_out = jfield(System, "out", @jimport java.io.PrintStream )
3334
@info "Java Version: ", jcall(System, "getProperty", JString, (JString,), "java.version")
3435

3536
@testset "unsafe_strings_1" begin
@@ -96,6 +97,17 @@ end
9697
H=@jimport java.util.HashMap
9798
a=jcall(T, "testNull", H, ())
9899
@test_throws ErrorException jcall(a, "toString", JString, ())
100+
101+
jlist = @jimport java.util.ArrayList
102+
@test jcall( jlist(), "add", jboolean, (JObject,), JObject(C_NULL)) === 0x01
103+
@test jcall( jlist(), "add", jboolean, (JObject,), JObject(JavaCall.J_NULL)) === 0x01
104+
@test jcall( jlist(), "add", jboolean, (JObject,), nothing) === 0x01
105+
@test jcall( System_out , "print", Nothing , (JObject,), JObject(C_NULL)) === nothing
106+
@test jcall( System_out , "print", Nothing , (JObject,), JObject(JavaCall.J_NULL)) === nothing
107+
@test jcall( System_out , "print", Nothing , (JObject,), nothing) === nothing
108+
@test jcall( System_out , "print", Nothing , (JString,), JString(C_NULL)) === nothing
109+
@test jcall( System_out , "print", Nothing , (JString,), JString(JavaCall.J_NULL)) === nothing
110+
@test jcall( System_out , "print", Nothing , (JString,), nothing) === nothing
99111
end
100112

101113
@testset "arrays_1" begin

0 commit comments

Comments
 (0)