Merge

Thu, 18 May 2017 14:31:37 -0700

author
asaha
date
Thu, 18 May 2017 14:31:37 -0700
changeset 3494
972d85327d11
parent 3493
e40ceac7d0f4
parent 3391
479c13a68ca4
child 3495
3f0ca3de4c59

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Fri Apr 28 14:30:11 2017 -0700
     1.2 +++ b/.hgtags	Thu May 18 14:31:37 2017 -0700
     1.3 @@ -711,3 +711,6 @@
     1.4  d89ea3127a93d7ea6f2b89ee3adc673136833933 jdk8u141-b04
     1.5  b8e0348df792b1c5f95cd7d77d5c05da1d435d32 jdk8u141-b05
     1.6  13b638c8e005d48be437db11835a63721ca10086 jdk8u141-b06
     1.7 +4d04a70e3207dcb46b71e6f9ad04bf0e130cf389 jdk8u141-b07
     1.8 +e2abef6f10b9b2946ce8f5f851af67a764bbe57d jdk8u141-b08
     1.9 +1df48afb34a0778df6c97a2c96c483a177135431 jdk8u141-b09
     2.1 --- a/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Fri Apr 28 14:30:11 2017 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Thu May 18 14:31:37 2017 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -34,8 +34,10 @@
    2.11  import java.nio.file.SimpleFileVisitor;
    2.12  import java.nio.file.attribute.BasicFileAttributes;
    2.13  import java.util.*;
    2.14 +import java.util.jar.Attributes;
    2.15  import java.util.jar.JarEntry;
    2.16  import java.util.jar.JarFile;
    2.17 +import java.util.jar.Manifest;
    2.18  
    2.19  /**
    2.20   * ClassFileReader reads ClassFile(s) of a given path that can be
    2.21 @@ -154,6 +156,8 @@
    2.22          }
    2.23      }
    2.24  
    2.25 +    public boolean isMultiReleaseJar() throws IOException { return false; }
    2.26 +
    2.27      public String toString() {
    2.28          return path.toString();
    2.29      }
    2.30 @@ -290,6 +294,16 @@
    2.31                  }
    2.32              };
    2.33          }
    2.34 +
    2.35 +        @Override
    2.36 +        public boolean isMultiReleaseJar() throws IOException {
    2.37 +            Manifest mf = this.jarfile.getManifest();
    2.38 +            if (mf != null) {
    2.39 +                Attributes atts = mf.getMainAttributes();
    2.40 +                return "true".equalsIgnoreCase(atts.getValue("Multi-Release"));
    2.41 +            }
    2.42 +            return false;
    2.43 +        }
    2.44      }
    2.45  
    2.46      class JarFileIterator implements Iterator<ClassFile> {
     3.1 --- a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java	Fri Apr 28 14:30:11 2017 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java	Thu May 18 14:31:37 2017 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -515,6 +515,13 @@
    3.11          // add all classpath archives to the source locations for reporting
    3.12          sourceLocations.addAll(classpaths);
    3.13  
    3.14 +        // warn about Multi-Release jars
    3.15 +        for (Archive a : sourceLocations) {
    3.16 +            if (a.reader().isMultiReleaseJar()) {
    3.17 +                warning("warn.mrjar.usejdk9", a.getPathName());
    3.18 +            }
    3.19 +        }
    3.20 +
    3.21          // Work queue of names of classfiles to be searched.
    3.22          // Entries will be unique, and for classes that do not yet have
    3.23          // dependencies in the results map.
     4.1 --- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Fri Apr 28 14:30:11 2017 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Thu May 18 14:31:37 2017 -0700
     4.3 @@ -99,6 +99,10 @@
     4.4  Please modify your code to eliminate dependency on any JDK internal APIs.\n\
     4.5  For the most recent update on JDK internal API replacements, please check:\n\
     4.6  {0}
     4.7 +warn.mrjar.usejdk9=\
     4.8 +{0} is a multi-release jar file.\n\
     4.9 +All versioned entries are analyzed. To analyze the entries for a specific\n\
    4.10 +version, use a newer version of jdeps (JDK 9 or later) \"--multi-release\" option.
    4.11  
    4.12  artifact.not.found=not found
    4.13  jdeps.wiki.url=https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool
     5.1 --- a/src/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties	Fri Apr 28 14:30:11 2017 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties	Thu May 18 14:31:37 2017 -0700
     5.3 @@ -1,22 +1,45 @@
     5.4  // No translation needed
     5.5  com.sun.crypto.provider.SunJCE=Use java.security.Security.getProvider(provider-name) @since 1.3
     5.6 -com.sun.image.codec=Use javax.imageio @since 1.4
     5.7  com.sun.org.apache.xml.internal.security=Use java.xml.crypto @since 1.6
     5.8  com.sun.org.apache.xml.internal.security.utils.Base64=Use java.util.Base64 @since 1.8
     5.9 +com.sun.org.apache.xml.internal.resolver=Use javax.xml.catalog @since 9
    5.10  com.sun.net.ssl=Use javax.net.ssl @since 1.4
    5.11  com.sun.net.ssl.internal.ssl.Provider=Use java.security.Security.getProvider(provider-name) @since 1.3
    5.12  com.sun.rowset=Use javax.sql.rowset.RowSetProvider @since 1.7
    5.13 +com.sun.tools.doclets.standard=Use jdk.javadoc.doclets.StandardDoclet @since 9.
    5.14  com.sun.tools.javac.tree=Use com.sun.source @since 1.6
    5.15  com.sun.tools.javac=Use javax.tools and javax.lang.model @since 1.6
    5.16 -sun.awt.image.codec=Use javax.imageio @since 1.4
    5.17 -sun.misc.BASE64Encoder=Use java.util.Base64 @since 1.8
    5.18 -sun.misc.BASE64Decoder=Use java.util.Base64 @since 1.8
    5.19 -sun.misc.Cleaner=Use java.lang.ref.PhantomReference @since 1.2
    5.20 -sun.misc.Service=Use java.util.ServiceLoader @since 1.6
    5.21 +java.awt.peer=Should not use. See https://bugs.openjdk.java.net/browse/JDK-8037739
    5.22 +java.awt.dnd.peer=Should not use. See https://bugs.openjdk.java.net/browse/JDK-8037739
    5.23 +jdk.internal.ref.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 or java.lang.ref.Cleaner @since 9
    5.24 +sun.awt.CausedFocusEvent=Use java.awt.event.FocusEvent::getCause @since 9
    5.25 +sun.font.FontUtilities=See java.awt.Font.textRequiresLayout @since 9
    5.26 +sun.reflect.Reflection=See http://openjdk.java.net/jeps/260
    5.27 +sun.reflect.ReflectionFactory=See http://openjdk.java.net/jeps/260
    5.28 +sun.misc.Unsafe=See http://openjdk.java.net/jeps/260
    5.29 +sun.misc.Signal=See http://openjdk.java.net/jeps/260
    5.30 +sun.misc.SignalHandler=See http://openjdk.java.net/jeps/260
    5.31  sun.security.action=Use java.security.PrivilegedAction @since 1.1
    5.32  sun.security.krb5=Use com.sun.security.jgss
    5.33  sun.security.provider.PolicyFile=Use java.security.Policy.getInstance("JavaPolicy", new URIParameter(uri)) @since 1.6
    5.34  sun.security.provider.Sun=Use java.security.Security.getProvider(provider-name) @since 1.3
    5.35 +sun.security.util.HostnameChecker=Use javax.net.ssl.SSLParameters.setEndpointIdentificationAlgorithm("HTTPS") @since 1.7\n\
    5.36 +or javax.net.ssl.HttpsURLConnection.setHostnameVerifier() @since 1.4
    5.37  sun.security.util.SecurityConstants=Use appropriate java.security.Permission subclass @since 1.1
    5.38  sun.security.x509.X500Name=Use javax.security.auth.x500.X500Principal @since 1.4
    5.39 -sun.tools.jar=Use java.util.jar or jar tool @since 1.2
    5.40 +sun.tools.jar=Use java.util.jar @since 1.2
    5.41 +sun.tools.jar.Main=Use java.util.spi.ToolProvider @since 9
    5.42 +# Internal APIs removed in JDK 9
    5.43 +com.apple.eawt=Use java.awt.Desktop @since 9.  See http://openjdk.java.net/jeps/272
    5.44 +com.apple.concurrent=Removed in JDK 9. See https://bugs.openjdk.java.net/browse/JDK-8148187
    5.45 +com.sun.image.codec.jpeg=Use javax.imageio @since 1.4
    5.46 +sun.awt.image.codec=Use javax.imageio @since 1.4
    5.47 +sun.misc.BASE64Encoder=Use java.util.Base64 @since 1.8
    5.48 +sun.misc.BASE64Decoder=Use java.util.Base64 @since 1.8
    5.49 +sun.misc.ClassLoaderUtil=Use java.net.URLClassLoader.close() @since 1.7
    5.50 +sun.misc.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 or java.lang.ref.Cleaner @since 9.\n\
    5.51 +See http://openjdk.java.net/jeps/260.
    5.52 +sun.misc.Service=Use java.util.ServiceLoader @since 1.6
    5.53 +sun.misc=Removed in JDK 9. See http://openjdk.java.net/jeps/260
    5.54 +sun.reflect=Removed in JDK 9. See http://openjdk.java.net/jeps/260
    5.55 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/jdeps/MRJarWarning.java	Thu May 18 14:31:37 2017 -0700
     6.3 @@ -0,0 +1,169 @@
     6.4 +/*
     6.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + */
    6.26 +
    6.27 +/*
    6.28 + * @test
    6.29 + * @bug 8176329
    6.30 + * @summary Test for jdeps warning when it encounters a multi-release jar
    6.31 + * @run testng MRJarWarning
    6.32 + */
    6.33 +
    6.34 +import java.io.IOException;
    6.35 +import java.io.OutputStream;
    6.36 +import java.io.PrintWriter;
    6.37 +import java.io.StringWriter;
    6.38 +import java.nio.file.Files;
    6.39 +import java.nio.file.Path;
    6.40 +import java.nio.file.Paths;
    6.41 +import java.util.Arrays;
    6.42 +import java.util.Collections;
    6.43 +import java.util.List;
    6.44 +import java.util.Locale;
    6.45 +import java.util.jar.Attributes;
    6.46 +import java.util.jar.JarEntry;
    6.47 +import java.util.jar.JarOutputStream;
    6.48 +import java.util.jar.Manifest;
    6.49 +import org.testng.Assert;
    6.50 +import org.testng.annotations.BeforeSuite;
    6.51 +import org.testng.annotations.DataProvider;
    6.52 +import org.testng.annotations.Test;
    6.53 +
    6.54 +public class MRJarWarning {
    6.55 +    private static final String WARNING = " is a multi-release jar file";
    6.56 +    private static final String MRJAR_ATTR = "Multi-Release";
    6.57 +
    6.58 +    Path mrjar1;
    6.59 +    Path mrjar2;
    6.60 +    Path nonMRjar;
    6.61 +    Path mrjarAllCaps;
    6.62 +
    6.63 +    private Attributes defaultAttributes;
    6.64 +
    6.65 +    @BeforeSuite
    6.66 +    public void setup() throws IOException {
    6.67 +        defaultAttributes = new Attributes();
    6.68 +        defaultAttributes.putValue("Manifest-Version", "1.0");
    6.69 +        defaultAttributes.putValue("Created-By", "1.8.0-internal");
    6.70 +
    6.71 +        mrjar1   = Paths.get("mrjar1.jar");
    6.72 +        mrjar2   = Paths.get("mrjar2.jar");
    6.73 +        nonMRjar = Paths.get("nonMRjar.jar");
    6.74 +        mrjarAllCaps = Paths.get("mrjarAllCaps.jar");
    6.75 +
    6.76 +        Attributes mrJarAttrs = new Attributes(defaultAttributes);
    6.77 +        mrJarAttrs.putValue(MRJAR_ATTR, "true");
    6.78 +
    6.79 +        build(mrjar1, mrJarAttrs);
    6.80 +        build(mrjar2, mrJarAttrs);
    6.81 +        build(nonMRjar, defaultAttributes);
    6.82 +
    6.83 +        // JEP 238 - "Multi-Release JAR Files" states that the attribute name
    6.84 +        // and value are case insensitive.  Try with all caps to ensure that
    6.85 +        // jdeps still recognizes a multi-release jar.
    6.86 +        Attributes allCapsAttrs = new Attributes(defaultAttributes);
    6.87 +        allCapsAttrs.putValue(MRJAR_ATTR.toUpperCase(), "TRUE");
    6.88 +        build(mrjarAllCaps, allCapsAttrs);
    6.89 +    }
    6.90 +
    6.91 +    @DataProvider(name="provider")
    6.92 +    private Object[][] args() {
    6.93 +        // jdeps warning messages may be localized.
    6.94 +        // This test only checks for the English version.  Return an empty
    6.95 +        // array (skip testing) if the default language is not English.
    6.96 +        String language = Locale.getDefault().getLanguage();
    6.97 +        System.out.println("Language: " + language);
    6.98 +
    6.99 +        if ("en".equals(language)) {
   6.100 +            return new Object[][] {
   6.101 +                // one mrjar arg
   6.102 +                {   Arrays.asList(mrjar1.toString()),
   6.103 +                    Arrays.asList(mrjar1)},
   6.104 +                // two mrjar args
   6.105 +                {   Arrays.asList(mrjar1.toString(), mrjar2.toString()),
   6.106 +                    Arrays.asList(mrjar1, mrjar2)},
   6.107 +                // one mrjar arg, with mrjar on classpath
   6.108 +                {   Arrays.asList("-cp", mrjar2.toString(), mrjar1.toString()),
   6.109 +                    Arrays.asList(mrjar1, mrjar2)},
   6.110 +                // non-mrjar arg, with mrjar on classpath
   6.111 +                {   Arrays.asList("-cp", mrjar1.toString(), nonMRjar.toString()),
   6.112 +                    Arrays.asList(mrjar1)},
   6.113 +                // mrjar arg with jar attribute name/value in ALL CAPS
   6.114 +                {   Arrays.asList(mrjarAllCaps.toString()),
   6.115 +                    Arrays.asList(mrjarAllCaps)},
   6.116 +                // non-mrjar arg
   6.117 +                {   Arrays.asList(nonMRjar.toString()),
   6.118 +                    Collections.emptyList()}
   6.119 +            };
   6.120 +        } else {
   6.121 +            System.out.println("Non-English language \""+ language +
   6.122 +                    "\"; test passes superficially");
   6.123 +            return new Object[][]{};
   6.124 +        }
   6.125 +    }
   6.126 +
   6.127 +    /* Run jdeps with the arguments given in 'args', and confirm that a warning
   6.128 +     * is issued for each Multi-Release jar in 'expectedMRpaths'.
   6.129 +     */
   6.130 +    @Test(dataProvider="provider")
   6.131 +    public void checkWarning(List<String> args, List<Path> expectedMRpaths) {
   6.132 +        StringWriter sw = new StringWriter();
   6.133 +        PrintWriter pw = new PrintWriter(sw);
   6.134 +
   6.135 +        int rc = com.sun.tools.jdeps.Main.run(args.toArray(new String[args.size()]), pw);
   6.136 +        pw.close();
   6.137 +
   6.138 +        expectedMRJars(sw.toString(), expectedMRpaths);
   6.139 +        Assert.assertEquals(rc, 0, "non-zero exit code from jdeps");
   6.140 +    }
   6.141 +
   6.142 +    /* Confirm that warnings for the specified paths are in the output (or that
   6.143 +     * warnings are absent if 'paths' is empty).
   6.144 +     * Doesn't check for extra, unexpected warnings.
   6.145 +     */
   6.146 +    private static void expectedMRJars(String output, List<Path> paths) {
   6.147 +        if (paths.isEmpty()) {
   6.148 +            Assert.assertFalse(output.contains(WARNING),
   6.149 +                               "Expected no mrjars, but found:\n" + output);
   6.150 +        } else {
   6.151 +            for (Path path : paths) {
   6.152 +                String expect = "Warning: " + path.toString() + WARNING;
   6.153 +                Assert.assertTrue(output.contains(expect),
   6.154 +                        "Did not find:\n" + expect + "\nin:\n" + output + "\n");
   6.155 +            }
   6.156 +        }
   6.157 +    }
   6.158 +
   6.159 +    /* Build a jar at the expected path, containing the given attributes */
   6.160 +    private static void build(Path path, Attributes attributes) throws IOException {
   6.161 +        try (OutputStream os = Files.newOutputStream(path);
   6.162 +             JarOutputStream jos = new JarOutputStream(os)) {
   6.163 +
   6.164 +            JarEntry me = new JarEntry("META-INF/MANIFEST.MF");
   6.165 +            jos.putNextEntry(me);
   6.166 +            Manifest manifest = new Manifest();
   6.167 +            manifest.getMainAttributes().putAll(attributes);
   6.168 +            manifest.write(jos);
   6.169 +            jos.closeEntry();
   6.170 +        }
   6.171 +    }
   6.172 +}

mercurial