@@ -234,9 +234,6 @@ private static RuntimeException wrapException(Throwable ex) {
234234 C_POINTER , "openslide_detect_vendor" , C_POINTER );
235235
236236 static String openslide_detect_vendor (String filename ) {
237- if (filename == null ) {
238- return null ;
239- }
240237 MemorySegment ret ;
241238 try (Arena arena = Arena .ofConfined ()) {
242239 ret = (MemorySegment ) detect_vendor .invokeExact (
@@ -254,9 +251,6 @@ static String openslide_detect_vendor(String filename) {
254251 C_POINTER , "openslide_open" , C_POINTER );
255252
256253 static OpenSlideRef openslide_open (String filename ) {
257- if (filename == null ) {
258- return null ;
259- }
260254 MemorySegment ret ;
261255 try (Arena arena = Arena .ofConfined ()) {
262256 ret = (MemorySegment ) open .invokeExact (
@@ -362,14 +356,16 @@ static void openslide_read_icc_profile(OpenSlideRef osr, byte dest[]) {
362356 static String openslide_get_error (OpenSlideRef osr ) {
363357 MemorySegment ret ;
364358 try (Ref .ScopedLock l = osr .lock ()) {
365- ret = (MemorySegment ) get_error .invokeExact (osr .getSegment ());
366- } catch (Throwable ex ) {
367- throw wrapException (ex );
368- }
369- if (ret .equals (MemorySegment .NULL )) {
370- return null ;
359+ try {
360+ ret = (MemorySegment ) get_error .invokeExact (osr .getSegment ());
361+ } catch (Throwable ex ) {
362+ throw wrapException (ex );
363+ }
364+ if (ret .equals (MemorySegment .NULL )) {
365+ return null ;
366+ }
367+ return ret .getString (0 );
371368 }
372- return ret .getString (0 );
373369 }
374370
375371 private static final MethodHandle get_property_names = function (
@@ -378,32 +374,33 @@ static String openslide_get_error(OpenSlideRef osr) {
378374 static String [] openslide_get_property_names (OpenSlideRef osr ) {
379375 MemorySegment ret ;
380376 try (Ref .ScopedLock l = osr .lock ()) {
381- ret = (MemorySegment ) get_property_names .invokeExact (
382- osr .getSegment ());
383- } catch (Throwable ex ) {
384- throw wrapException (ex );
377+ try {
378+ ret = (MemorySegment ) get_property_names .invokeExact (
379+ osr .getSegment ());
380+ } catch (Throwable ex ) {
381+ throw wrapException (ex );
382+ }
383+ return segment_to_string_array (ret );
385384 }
386- return segment_to_string_array (ret );
387385 }
388386
389387 private static final MethodHandle get_property_value = function (
390388 C_POINTER , "openslide_get_property_value" , C_POINTER , C_POINTER );
391389
392390 static String openslide_get_property_value (OpenSlideRef osr , String name ) {
393- if (name == null ) {
394- return null ;
395- }
396391 MemorySegment ret ;
397- try (Arena arena = Arena .ofConfined (); Ref .ScopedLock l = osr .lock ()) {
398- ret = (MemorySegment ) get_property_value .invokeExact (
399- osr .getSegment (), arena .allocateFrom (name ));
400- } catch (Throwable ex ) {
401- throw wrapException (ex );
402- }
403- if (ret .equals (MemorySegment .NULL )) {
404- return null ;
392+ try (Ref .ScopedLock l = osr .lock ()) {
393+ try (Arena arena = Arena .ofConfined ()) {
394+ ret = (MemorySegment ) get_property_value .invokeExact (
395+ osr .getSegment (), arena .allocateFrom (name ));
396+ } catch (Throwable ex ) {
397+ throw wrapException (ex );
398+ }
399+ if (ret .equals (MemorySegment .NULL )) {
400+ return null ;
401+ }
402+ return ret .getString (0 );
405403 }
406- return ret .getString (0 );
407404 }
408405
409406 private static final MethodHandle get_associated_image_names = function (
@@ -412,12 +409,14 @@ static String openslide_get_property_value(OpenSlideRef osr, String name) {
412409 static String [] openslide_get_associated_image_names (OpenSlideRef osr ) {
413410 MemorySegment ret ;
414411 try (Ref .ScopedLock l = osr .lock ()) {
415- ret = (MemorySegment ) get_associated_image_names .invokeExact (
416- osr .getSegment ());
417- } catch (Throwable ex ) {
418- throw wrapException (ex );
412+ try {
413+ ret = (MemorySegment ) get_associated_image_names .invokeExact (
414+ osr .getSegment ());
415+ } catch (Throwable ex ) {
416+ throw wrapException (ex );
417+ }
418+ return segment_to_string_array (ret );
419419 }
420- return segment_to_string_array (ret );
421420 }
422421
423422 private static final MethodHandle get_associated_image_dimensions = function (
@@ -426,9 +425,6 @@ static String[] openslide_get_associated_image_names(OpenSlideRef osr) {
426425
427426 static void openslide_get_associated_image_dimensions (OpenSlideRef osr ,
428427 String name , long dim []) {
429- if (name == null ) {
430- return ;
431- }
432428 try (Arena arena = Arena .ofConfined ()) {
433429 MemorySegment w = arena .allocateFrom (JAVA_LONG , 0 );
434430 MemorySegment h = arena .allocateFrom (JAVA_LONG , 0 );
@@ -449,9 +445,6 @@ static void openslide_get_associated_image_dimensions(OpenSlideRef osr,
449445
450446 static void openslide_read_associated_image (OpenSlideRef osr , String name ,
451447 int dest []) {
452- if (name == null ) {
453- return ;
454- }
455448 try (Arena arena = Arena .ofConfined ()) {
456449 MemorySegment buf = arena .allocate (JAVA_INT , dest .length );
457450 try (Ref .ScopedLock l = osr .lock ()) {
@@ -470,9 +463,6 @@ static void openslide_read_associated_image(OpenSlideRef osr, String name,
470463
471464 static long openslide_get_associated_image_icc_profile_size (
472465 OpenSlideRef osr , String name ) {
473- if (name == null ) {
474- return -1 ;
475- }
476466 try (Arena arena = Arena .ofConfined (); Ref .ScopedLock l = osr .lock ()) {
477467 return (long ) get_associated_image_icc_profile_size .invokeExact (
478468 osr .getSegment (), arena .allocateFrom (name ));
@@ -487,9 +477,6 @@ static long openslide_get_associated_image_icc_profile_size(
487477
488478 static void openslide_read_associated_image_icc_profile (OpenSlideRef osr ,
489479 String name , byte dest []) {
490- if (name == null ) {
491- return ;
492- }
493480 try (Arena arena = Arena .ofConfined ()) {
494481 MemorySegment buf = arena .allocate (JAVA_BYTE , dest .length );
495482 try (Ref .ScopedLock l = osr .lock ()) {
0 commit comments