@@ -127,7 +127,7 @@ function jnew(T::Symbol, argtypes::Tuple, args...)
127127 (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass (T),
128128 String (" <init>" ), sig)
129129 if jmethodId == C_NULL
130- @error ( " No constructor for $T with signature $sig " )
130+ throw ( JavaCallError ( " No constructor for $T with signature $sig " ) )
131131 end
132132 return _jcall (metaclass (T), jmethodId, jnifunc. NewObjectA, JavaObject{T}, argtypes, args... )
133133end
@@ -217,7 +217,7 @@ for (x, y, z) in [ (:jboolean, :(jnifunc.CallBooleanMethodA), :(jnifunc.CallStat
217217 end
218218 @assert callmethod != C_NULL
219219 @assert jmethodId != C_NULL
220- isnull (obj) && @error ( " Attempt to call method on Java NULL" )
220+ isnull (obj) && throw ( JavaCallError ( " Attempt to call method on Java NULL" ) )
221221 savedArgs, convertedArgs = convert_args (argtypes, args... )
222222 result = ccall (callmethod, $ x , (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{Nothing}, Ptr{Nothing}), penv, obj. ptr, jmethodId, convertedArgs)
223223 result== C_NULL && geterror ()
@@ -254,7 +254,7 @@ global const _jmc_cache = Dict{Symbol, JavaMetaClass}()
254254function _metaclass (class:: Symbol )
255255 jclass= javaclassname (class)
256256 jclassptr = ccall (jnifunc. FindClass, Ptr{Nothing}, (Ptr{JNIEnv}, Ptr{UInt8}), penv, jclass)
257- jclassptr == C_NULL && @error ( " Class Not Found $jclass " )
257+ jclassptr == C_NULL && throw ( JavaCallError ( " Class Not Found $jclass " ) )
258258 return JavaMetaClass (class, jclassptr)
259259end
260260
@@ -275,28 +275,28 @@ function geterror(allow=false)
275275
276276 if isexception == JNI_TRUE
277277 jthrow = ccall (jnifunc. ExceptionOccurred, Ptr{Nothing}, (Ptr{JNIEnv},), penv)
278- jthrow== C_NULL && @error ( " Java Exception thrown, but no details could be retrieved from the JVM" )
278+ jthrow== C_NULL && throw ( JavaCallError ( " Java Exception thrown, but no details could be retrieved from the JVM" ) )
279279 ccall (jnifunc. ExceptionDescribe, Nothing, (Ptr{JNIEnv},), penv ) # Print java stackstrace to stdout
280280 ccall (jnifunc. ExceptionClear, Nothing, (Ptr{JNIEnv},), penv )
281281 jclass = ccall (jnifunc. FindClass, Ptr{Nothing}, (Ptr{JNIEnv},Ptr{UInt8}), penv,
282282 " java/lang/Throwable" )
283- jclass== C_NULL && @error ( " Java Exception thrown, but no details could be retrieved from the JVM" )
283+ jclass== C_NULL && throw ( JavaCallError ( " Java Exception thrown, but no details could be retrieved from the JVM" ) )
284284 jmethodId= ccall (jnifunc. GetMethodID, Ptr{Nothing},
285285 (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, jclass, " toString" ,
286286 " ()Ljava/lang/String;" )
287- jmethodId== C_NULL && @error ( " Java Exception thrown, but no details could be retrieved from the JVM" )
287+ jmethodId== C_NULL && throw ( JavaCallError ( " Java Exception thrown, but no details could be retrieved from the JVM" ) )
288288 res = ccall (jnifunc. CallObjectMethodA, Ptr{Nothing},
289289 (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{Nothing}, Ptr{Nothing}), penv, jthrow, jmethodId,
290290 C_NULL )
291- res== C_NULL && error ( " Java Exception thrown, but no details could be retrieved from the JVM" )
291+ res== C_NULL && throw ( JavaCallError ( " Java Exception thrown, but no details could be retrieved from the JVM" ) )
292292 msg = unsafe_string (JString (res))
293293 ccall (jnifunc. DeleteLocalRef, Nothing, (Ptr{JNIEnv}, Ptr{Nothing}), penv, jthrow)
294- @error ( string (" Error calling Java: " ,msg))
294+ throw ( JavaCallError ( string (" Error calling Java: " ,msg) ))
295295 else
296296 if allow== false
297297 return # No exception pending, legitimate NULL returned from Java
298298 else
299- @error ( " Null from Java. Not known how" )
299+ throw ( JavaCallError ( " Null from Java. Not known how" ) )
300300 end
301301 end
302302end
0 commit comments