@@ -127,7 +127,7 @@ function jnew(T::Symbol, argtypes::Tuple, args...)
127
127
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, metaclass (T),
128
128
String (" <init>" ), sig)
129
129
if jmethodId == C_NULL
130
- @error ( " No constructor for $T with signature $sig " )
130
+ throw ( JavaCallError ( " No constructor for $T with signature $sig " ) )
131
131
end
132
132
return _jcall (metaclass (T), jmethodId, jnifunc. NewObjectA, JavaObject{T}, argtypes, args... )
133
133
end
@@ -217,7 +217,7 @@ for (x, y, z) in [ (:jboolean, :(jnifunc.CallBooleanMethodA), :(jnifunc.CallStat
217
217
end
218
218
@assert callmethod != C_NULL
219
219
@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" ) )
221
221
savedArgs, convertedArgs = convert_args (argtypes, args... )
222
222
result = ccall (callmethod, $ x , (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{Nothing}, Ptr{Nothing}), penv, obj. ptr, jmethodId, convertedArgs)
223
223
result== C_NULL && geterror ()
@@ -254,7 +254,7 @@ global const _jmc_cache = Dict{Symbol, JavaMetaClass}()
254
254
function _metaclass (class:: Symbol )
255
255
jclass= javaclassname (class)
256
256
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 " ) )
258
258
return JavaMetaClass (class, jclassptr)
259
259
end
260
260
@@ -275,28 +275,28 @@ function geterror(allow=false)
275
275
276
276
if isexception == JNI_TRUE
277
277
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" ) )
279
279
ccall (jnifunc. ExceptionDescribe, Nothing, (Ptr{JNIEnv},), penv ) # Print java stackstrace to stdout
280
280
ccall (jnifunc. ExceptionClear, Nothing, (Ptr{JNIEnv},), penv )
281
281
jclass = ccall (jnifunc. FindClass, Ptr{Nothing}, (Ptr{JNIEnv},Ptr{UInt8}), penv,
282
282
" 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" ) )
284
284
jmethodId= ccall (jnifunc. GetMethodID, Ptr{Nothing},
285
285
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{UInt8}, Ptr{UInt8}), penv, jclass, " toString" ,
286
286
" ()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" ) )
288
288
res = ccall (jnifunc. CallObjectMethodA, Ptr{Nothing},
289
289
(Ptr{JNIEnv}, Ptr{Nothing}, Ptr{Nothing}, Ptr{Nothing}), penv, jthrow, jmethodId,
290
290
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" ) )
292
292
msg = unsafe_string (JString (res))
293
293
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) ))
295
295
else
296
296
if allow== false
297
297
return # No exception pending, legitimate NULL returned from Java
298
298
else
299
- @error ( " Null from Java. Not known how" )
299
+ throw ( JavaCallError ( " Null from Java. Not known how" ) )
300
300
end
301
301
end
302
302
end
0 commit comments