8133987: (fs) Rename GnomeFileTypeDetector to GioFileTypeDetector

Rename class and associated native file as indicated and fix some related comments in the source and test.

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2015-08-28 10:46:43 -07:00
parent bcb0095020
commit 44c462ee50
8 changed files with 24 additions and 19 deletions

View File

@ -47,7 +47,7 @@ endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
BUILD_LIBNIO_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
BUILD_LIBNIO_EXFILES += \
GnomeFileTypeDetector.c \
GioFileTypeDetector.c \
#
endif

View File

@ -135,8 +135,8 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
Java_sun_nio_fs_GnomeFileTypeDetector_probeGio;
Java_sun_nio_fs_GioFileTypeDetector_initializeGio;
Java_sun_nio_fs_GioFileTypeDetector_probeGio;
Java_sun_nio_fs_MagicFileTypeDetector_initialize0;
Java_sun_nio_fs_MagicFileTypeDetector_probe0;
Java_sun_nio_fs_LinuxWatchService_eventSize;

View File

@ -130,8 +130,8 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_SolarisEventPort_port_1get;
Java_sun_nio_ch_SolarisEventPort_port_1getn;
Java_sun_nio_ch_SolarisEventPort_port_1send;
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
Java_sun_nio_fs_GnomeFileTypeDetector_probeGio;
Java_sun_nio_fs_GioFileTypeDetector_initializeGio;
Java_sun_nio_fs_GioFileTypeDetector_probeGio;
Java_sun_nio_fs_UnixNativeDispatcher_init;
Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
Java_sun_nio_fs_UnixNativeDispatcher_strerror;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -106,7 +106,7 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
new GetPropertyAction("user.home")), ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GnomeFileTypeDetector(),
return chain(new GioFileTypeDetector(),
new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes),
new MagicFileTypeDetector());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -89,7 +89,7 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
new GetPropertyAction("user.home")), ".mime.types");
Path etcMimeTypes = Paths.get("/etc/mime.types");
return chain(new GnomeFileTypeDetector(),
return chain(new GioFileTypeDetector(),
new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes));
}

View File

@ -35,13 +35,13 @@ import java.security.PrivilegedAction;
* MIME type of a file.
*/
public class GnomeFileTypeDetector
public class GioFileTypeDetector
extends AbstractFileTypeDetector
{
// true if GIO is available
private final boolean gioAvailable;
public GnomeFileTypeDetector() {
public GioFileTypeDetector() {
gioAvailable = initializeGio();
}
@ -67,6 +67,10 @@ public class GnomeFileTypeDetector
// GIO
private static native boolean initializeGio();
//
// The probeGIO() method is synchronized to avert potential problems
// such as crashes due to a suspected lack of thread safety in GIO.
//
private static synchronized native byte[] probeGio(long pathAddress);
static {

View File

@ -73,11 +73,11 @@ static g_file_query_info_func g_file_query_info;
static g_file_info_get_content_type_func g_file_info_get_content_type;
#include "sun_nio_fs_GnomeFileTypeDetector.h"
#include "sun_nio_fs_GioFileTypeDetector.h"
JNIEXPORT jboolean JNICALL
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio
Java_sun_nio_fs_GioFileTypeDetector_initializeGio
(JNIEnv* env, jclass this)
{
void* gio_handle;
@ -120,7 +120,7 @@ Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio
}
JNIEXPORT jbyteArray JNICALL
Java_sun_nio_fs_GnomeFileTypeDetector_probeGio
Java_sun_nio_fs_GioFileTypeDetector_probeGio
(JNIEnv* env, jclass this, jlong pathAddress)
{
char* path = (char*)jlong_to_ptr(pathAddress);

View File

@ -21,17 +21,18 @@
* questions.
*/
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
/* @test
* @summary Test probing content type simultaneously from multiple threads.
* @requires (os.family == "linux") | (os.family == "solaris")
* @build ParallelProbes SimpleFileTypeDetector
* @run main/othervm ParallelProbes 10
*/
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
public class ParallelProbes {
private static final int REPEATS = 1000;