--- old/jaxws/src/java.activation/share/classes/javax/activation/MimetypesFileTypeMap.java 2017-06-01 18:20:48.733569721 +0100 +++ new/jaxws/src/java.activation/share/classes/javax/activation/MimetypesFileTypeMap.java 2017-06-01 18:20:48.677569722 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -28,6 +28,8 @@ import java.io.*; import java.net.*; import java.util.*; +import java.security.AccessController; +import java.security.PrivilegedAction; import com.sun.activation.registries.MimeTypeFile; import com.sun.activation.registries.LogSupport; @@ -43,12 +45,19 @@ *
+ * (The current implementation looks for the {@code mime.types} file + * in the Java runtime in the directory java.home{@code /conf} + * if it exists, and otherwise in the directory + * java.home{@code /lib}, where java.home is the value + * of the "java.home" System property. Note that the "conf" directory was + * introduced in JDK 9.) + *
* MIME types file format: * *
{@code @@ -72,7 +81,30 @@ private MimeTypeFile[] DB; private static final int PROG = 0; // programmatically added entries - private static String defaultType = "application/octet-stream"; + private static final String defaultType = "application/octet-stream"; + + private static final String confDir; + + static { + String dir = null; + try { + dir = (String)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + String home = System.getProperty("java.home"); + String newdir = home + File.separator + "conf"; + File conf = new File(newdir); + if (conf.exists()) + return newdir + File.separator; + else + return home + File.separator + "lib" + File.separator; + } + }); + } catch (Exception ex) { + // ignore any exceptions + } + confDir = dir; + } /** * The default constructor. @@ -97,11 +129,11 @@ LogSupport.log("MimetypesFileTypeMap: load SYS"); try { // check system's home - String system_mimetypes = System.getProperty("java.home") + - File.separator + "lib" + File.separator + "mime.types"; - mf = loadFile(system_mimetypes); - if (mf != null) - dbv.addElement(mf); + if (confDir != null) { + mf = loadFile(confDir + "mime.types"); + if (mf != null) + dbv.addElement(mf); + } } catch (SecurityException ex) {} LogSupport.log("MimetypesFileTypeMap: load JAR"); @@ -239,6 +271,7 @@ * added from the named file. * * @param mimeTypeFileName the file name + * @exception IOException for errors reading the file */ public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException { this();