Skip to content

Commit 59973a3

Browse files
author
Mark Kittisopikul
committed
Assert root Task for jcall and jfield
1 parent 6efe8de commit 59973a3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/core.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jvalue(v::Float64) = jvalue(reinterpret(Int64, v))
101101
jvalue(v::Ptr) = jvalue(Int(v))
102102

103103

104-
function _jimport(juliaclass)
104+
function _jimport(juliaclass)
105105
for str [" ", "(", ")"]
106106
juliaclass = replace(juliaclass, str=>"")
107107
end
@@ -122,6 +122,7 @@ end
122122

123123

124124
function jnew(T::Symbol, argtypes::Tuple, args...)
125+
assertroottask()
125126
sig = method_signature(Nothing, argtypes...)
126127
jmethodId = ccall(jnifunc.GetMethodID, Ptr{Nothing},
127128
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass(T),
@@ -135,6 +136,7 @@ end
135136
# Call static methods
136137
function jcall(typ::Type{JavaObject{T}}, method::AbstractString, rettype::Type, argtypes::Tuple,
137138
args... ) where T
139+
assertroottask()
138140
sig = method_signature(rettype, argtypes...)
139141
jmethodId = ccall(jnifunc.GetStaticMethodID, Ptr{Nothing},
140142
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass(T),
@@ -145,6 +147,7 @@ end
145147

146148
# Call instance methods
147149
function jcall(obj::JavaObject, method::AbstractString, rettype::Type, argtypes::Tuple, args... )
150+
assertroottask()
148151
sig = method_signature(rettype, argtypes...)
149152
jmethodId = ccall(jnifunc.GetMethodID, Ptr{Nothing},
150153
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass(obj),
@@ -154,6 +157,7 @@ function jcall(obj::JavaObject, method::AbstractString, rettype::Type, argtypes:
154157
end
155158

156159
function jfield(typ::Type{JavaObject{T}}, field::AbstractString, fieldType::Type) where T
160+
assertroottask()
157161
jfieldID = ccall(jnifunc.GetStaticFieldID, Ptr{Nothing},
158162
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass(T),
159163
String(field), signature(fieldType))
@@ -162,6 +166,7 @@ function jfield(typ::Type{JavaObject{T}}, field::AbstractString, fieldType::Type
162166
end
163167

164168
function jfield(obj::JavaObject, field::AbstractString, fieldType::Type)
169+
assertroottask()
165170
jfieldID = ccall(jnifunc.GetFieldID, Ptr{Nothing},
166171
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass(obj),
167172
String(field), signature(fieldType))

0 commit comments

Comments
 (0)