JDK 1.9 moved config files to <java.home>/conf - JDK-8049379
diff --git a/activation/src/main/java/javax/activation/MailcapCommandMap.java b/activation/src/main/java/javax/activation/MailcapCommandMap.java index bd937d9..5d3ce50 100644 --- a/activation/src/main/java/javax/activation/MailcapCommandMap.java +++ b/activation/src/main/java/javax/activation/MailcapCommandMap.java
@@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -63,12 +63,17 @@ * <ol> * <li> Programatically added entries to the MailcapCommandMap instance. * <li> The file <code>.mailcap</code> in the user's home directory. - * <li> The file <<i>java.home</i>><code>/lib/mailcap</code>. + * <li> The file <code><i>java.home</i>/<i>conf</i>/mailcap</code>. * <li> The file or resources named <code>META-INF/mailcap</code>. * <li> The file or resource named <code>META-INF/mailcap.default</code> * (usually found only in the <code>activation.jar</code> file). * </ol> * <p> + * (Where <i>java.home</i> is the value of the "java.home" System property + * and <i>conf</i> is the directory named "conf" if it exists, + * otherwise the directory named "lib"; the "conf" directory was + * introduced in JDK 1.9.) + * <p> * <b>Mailcap file format:</b><p> * * Mailcap files must conform to the mailcap @@ -136,6 +141,24 @@ private MailcapFile[] DB; private static final int PROG = 0; // programmatically added entries + private static final String confDir; + + static { + String dir = null; + try { + String home = System.getProperty("java.home"); + String newdir = home + File.separator + "conf"; + File conf = new File(newdir); + if (conf.exists()) + dir = newdir + File.separator; + else + dir = home + File.separator + "lib" + File.separator; + } catch (Exception ex) { + // ignore any exceptions + } + confDir = dir; + } + /** * The default Constructor. */ @@ -158,14 +181,12 @@ } catch (SecurityException ex) {} LogSupport.log("MailcapCommandMap: load SYS"); - try { + if (confDir != null) { // check system's home - String system_mailcap = System.getProperty("java.home") + - File.separator + "lib" + File.separator + "mailcap"; - mf = loadFile(system_mailcap); + mf = loadFile(confDir + "mailcap"); if (mf != null) dbv.add(mf); - } catch (SecurityException ex) {} + } LogSupport.log("MailcapCommandMap: load JAR"); // load from the app's jar file
diff --git a/activation/src/main/java/javax/activation/MimetypesFileTypeMap.java b/activation/src/main/java/javax/activation/MimetypesFileTypeMap.java index b1684e2..56948ba 100644 --- a/activation/src/main/java/javax/activation/MimetypesFileTypeMap.java +++ b/activation/src/main/java/javax/activation/MimetypesFileTypeMap.java
@@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -59,12 +59,17 @@ * <ol> * <li> Programmatically added entries to the MimetypesFileTypeMap instance. * <li> The file <code>.mime.types</code> in the user's home directory. - * <li> The file <<i>java.home</i>><code>/lib/mime.types</code>. + * <li> The file <code><i>java.home</i>/<i>conf</i>/mime.types</code>. * <li> The file or resources named <code>META-INF/mime.types</code>. * <li> The file or resource named <code>META-INF/mimetypes.default</code> * (usually found only in the <code>activation.jar</code> file). * </ol> * <p> + * (Where <i>java.home</i> is the value of the "java.home" System property + * and <i>conf</i> is the directory named "conf" if it exists, + * otherwise the directory named "lib"; the "conf" directory was + * introduced in JDK 1.9.) + * <p> * <b>MIME types file format:</b><p> * * <code> @@ -86,7 +91,25 @@ 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 { + String home = System.getProperty("java.home"); + String newdir = home + File.separator + "conf"; + File conf = new File(newdir); + if (conf.exists()) + dir = newdir + File.separator; + else + dir = home + File.separator + "lib" + File.separator; + } catch (Exception ex) { + // ignore any exceptions + } + confDir = dir; + } /** * The default constructor. @@ -109,14 +132,12 @@ } catch (SecurityException ex) {} LogSupport.log("MimetypesFileTypeMap: load SYS"); - try { + if (confDir != null) { // check system's home - String system_mimetypes = System.getProperty("java.home") + - File.separator + "lib" + File.separator + "mime.types"; - mf = loadFile(system_mimetypes); + mf = loadFile(confDir + "mime.types"); if (mf != null) dbv.addElement(mf); - } catch (SecurityException ex) {} + } LogSupport.log("MimetypesFileTypeMap: load JAR"); // load from the app's jar file