8160831: GioFileTypeDetector always calls deprecated g_type_init
authorbpb
Mon, 11 Jul 2016 14:46:21 -0700
changeset 39569 ce8a7a71f56b
parent 39568 1987f3929c39
child 39570 f774415f91ad
8160831: GioFileTypeDetector always calls deprecated g_type_init Summary: Ensure that g_type_init is non-null before using it. Reviewed-by: alanb Contributed-by: Martin Walsh <martin.walsh@oracle.com>
jdk/src/java.base/linux/native/libnio/fs/GioFileTypeDetector.c
--- a/jdk/src/java.base/linux/native/libnio/fs/GioFileTypeDetector.c	Mon May 23 23:12:05 2016 +0800
+++ b/jdk/src/java.base/linux/native/libnio/fs/GioFileTypeDetector.c	Mon Jul 11 14:46:21 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,7 +91,6 @@
     }
 
     g_type_init = (g_type_init_func)dlsym(gio_handle, "g_type_init");
-    (*g_type_init)();
 
     g_object_unref = (g_object_unref_func)dlsym(gio_handle, "g_object_unref");
 
@@ -104,9 +103,7 @@
     g_file_info_get_content_type = (g_file_info_get_content_type_func)
         dlsym(gio_handle, "g_file_info_get_content_type");
 
-
-    if (g_type_init == NULL ||
-        g_object_unref == NULL ||
+    if (g_object_unref == NULL ||
         g_file_new_for_path == NULL ||
         g_file_query_info == NULL ||
         g_file_info_get_content_type == NULL)
@@ -115,7 +112,10 @@
         return JNI_FALSE;
     }
 
-    (*g_type_init)();
+    if (g_type_init != NULL) {
+        (*g_type_init)();
+    }
+
     return JNI_TRUE;
 }