test/langtools/tools/jdeps/jdkinternals/RemovedJDKInternals.java
author sjohanss
Fri, 02 Mar 2018 10:09:04 +0100
changeset 49321 c3baee120706
parent 48477 b7af6f568d00
permissions -rw-r--r--
8198432: Remove Thread extension point Reviewed-by: ehelin, dholmes, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     1
/*
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     4
 *
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     8
 *
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    13
 * accompanied this code).
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    14
 *
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    18
 *
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    21
 * questions.
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    22
 */
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    23
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    24
/*
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    25
 * @test
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    26
 * @bug 8153042
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    27
 * @summary Tests JDK internal APIs that have been removed.
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    28
 * @library ../lib
41442
14db641d4a9f 8166846: jdeps fails to generate module info if there is any class in unnamed package
mchung
parents: 40599
diff changeset
    29
 * @build CompilerUtils JdepsRunner JdepsUtil ModuleMetaData
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    30
 * @modules jdk.jdeps/com.sun.tools.jdeps
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    31
 * @run testng RemovedJDKInternals
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    32
 */
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    33
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    34
import java.nio.file.Path;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    35
import java.nio.file.Paths;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    36
import java.util.Map;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    37
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    38
import com.sun.tools.jdeps.DepsAnalyzer;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    39
import com.sun.tools.jdeps.Graph;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    40
import org.testng.annotations.BeforeTest;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    41
import org.testng.annotations.DataProvider;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    42
import org.testng.annotations.Test;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    43
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    44
import static org.testng.Assert.assertEquals;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    45
import static org.testng.Assert.assertTrue;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    46
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    47
public class RemovedJDKInternals {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    48
    private static final String TEST_SRC = System.getProperty("test.src");
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    49
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    50
    private static final Path CLASSES_DIR = Paths.get("classes");
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    51
    private static final Path PATCHES_DIR = Paths.get("patches");
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    52
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    53
    private static final String JDK_UNSUPPORTED = "jdk.unsupported";
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    54
    /**
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    55
     * Compiles classes used by the test
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    56
     */
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    57
    @BeforeTest
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    58
    public void compileAll() throws Exception {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    59
        CompilerUtils.cleanDir(PATCHES_DIR);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    60
        CompilerUtils.cleanDir(CLASSES_DIR);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    61
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    62
        // compile sun.misc types
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    63
        Path sunMiscSrc = Paths.get(TEST_SRC, "patches", JDK_UNSUPPORTED);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    64
        Path patchDir = PATCHES_DIR.resolve(JDK_UNSUPPORTED);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    65
        assertTrue(CompilerUtils.compile(sunMiscSrc, patchDir,
43772
4e5350b7be75 8173777: Merge javac -Xmodule into javac--patch-module
jlahoda
parents: 41442
diff changeset
    66
                                         "--patch-module", JDK_UNSUPPORTED + "=" + sunMiscSrc.toString()));
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    67
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    68
        // compile com.sun.image.codec.jpeg types
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    69
        Path codecSrc = Paths.get(TEST_SRC, "patches", "java.desktop");
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    70
        Path codecDest = PATCHES_DIR;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    71
        assertTrue(CompilerUtils.compile(codecSrc, codecDest));
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    72
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    73
        // patch jdk.unsupported and set -cp to codec types
39671
5a4b6a035514 8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents: 38532
diff changeset
    74
        assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "p"),
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    75
                                         CLASSES_DIR,
40599
be40838eb215 8164887: update tests to remove use of old-style options
jjg
parents: 39671
diff changeset
    76
                                         "--patch-module", "jdk.unsupported=" + patchDir,
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    77
                                         "-cp", codecDest.toString()));
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    78
    }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    79
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    80
    @DataProvider(name = "deps")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    81
    public Object[][] deps() {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    82
        return new Object[][] {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    83
            { "classes", new ModuleMetaData("classes", false)
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    84
                .reference("p.Main", "java.lang.Class", "java.base")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    85
                .reference("p.Main", "java.lang.Object", "java.base")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    86
                .reference("p.Main", "java.util.Iterator", "java.base")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    87
                .reference("p.S", "java.lang.Object", "java.base")
48477
b7af6f568d00 8179424: Remove terminally deprecated sun.reflect.Reflection.getCallerClass
chegar
parents: 47216
diff changeset
    88
                .jdkInternal("p.Main", "sun.reflect.ReflectionFactory", "jdk.unsupported")
b7af6f568d00 8179424: Remove terminally deprecated sun.reflect.Reflection.getCallerClass
chegar
parents: 47216
diff changeset
    89
                .removedJdkInternal("p.Main", "sun.reflect.Reflection")
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    90
                .removedJdkInternal("p.Main", "com.sun.image.codec.jpeg.JPEGCodec")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    91
                .removedJdkInternal("p.Main", "sun.misc.Service")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    92
                .removedJdkInternal("p.Main", "sun.misc.SoftCache")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    93
            },
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    94
        };
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    95
    }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    96
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    97
    @Test(dataProvider = "deps")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    98
    public void runTest(String name, ModuleMetaData data) throws Exception {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
    99
        String cmd = String.format("jdeps -verbose:class %s%n", CLASSES_DIR);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   100
        try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   101
            jdeps.verbose("-verbose:class")
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   102
                .addRoot(CLASSES_DIR);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   103
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   104
            DepsAnalyzer analyzer = jdeps.getDepsAnalyzer();
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   105
            assertTrue(analyzer.run());
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   106
            jdeps.dumpOutput(System.err);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   107
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   108
            Graph<DepsAnalyzer.Node> g = analyzer.dependenceGraph();
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   109
            // there are two node with p.Main as origin
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   110
            // one for exported API and one for removed JDK internal
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   111
            g.nodes().stream()
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   112
                .filter(u -> u.source.equals(data.moduleName))
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   113
                .forEach(u -> g.adjacentNodes(u).stream()
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   114
                    .forEach(v -> data.checkDependence(u.name, v.name, v.source, v.info)));
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   115
        }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   116
    }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   117
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   118
    private static final Map<String, String> REPLACEMENTS = Map.of(
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   119
        "com.sun.image.codec.jpeg.JPEGCodec", "Use javax.imageio @since 1.4",
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   120
        "sun.misc.Service", "Use java.util.ServiceLoader @since 1.6",
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   121
        "sun.misc.SoftCache", "Removed. See http://openjdk.java.net/jeps/260",
48477
b7af6f568d00 8179424: Remove terminally deprecated sun.reflect.Reflection.getCallerClass
chegar
parents: 47216
diff changeset
   122
        "sun.reflect.Reflection", "Use java.lang.StackWalker @since 9",
b7af6f568d00 8179424: Remove terminally deprecated sun.reflect.Reflection.getCallerClass
chegar
parents: 47216
diff changeset
   123
        "sun.reflect.ReflectionFactory", "See http://openjdk.java.net/jeps/260"
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   124
    );
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   125
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   126
    @Test
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   127
    public void checkReplacement() {
41442
14db641d4a9f 8166846: jdeps fails to generate module info if there is any class in unnamed package
mchung
parents: 40599
diff changeset
   128
        JdepsRunner jdeps = JdepsRunner.run("-jdkinternals", CLASSES_DIR.toString());
14db641d4a9f 8166846: jdeps fails to generate module info if there is any class in unnamed package
mchung
parents: 40599
diff changeset
   129
        String[] output = jdeps.output();
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   130
        int i = 0;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   131
        while (!output[i].contains("Suggested Replacement")) {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   132
            i++;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   133
        }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   134
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   135
        // must match the number of JDK internal APIs
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   136
        int count = output.length-i-2;
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   137
        assertEquals(count, REPLACEMENTS.size());
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   138
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   139
        for (int j=i+2; j < output.length; j++) {
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   140
            String line = output[j];
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   141
            int pos = line.indexOf("Use ");
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   142
            if (pos < 0)
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   143
                pos = line.indexOf("Removed. ");
48477
b7af6f568d00 8179424: Remove terminally deprecated sun.reflect.Reflection.getCallerClass
chegar
parents: 47216
diff changeset
   144
            if (pos < 0)
b7af6f568d00 8179424: Remove terminally deprecated sun.reflect.Reflection.getCallerClass
chegar
parents: 47216
diff changeset
   145
                pos = line.indexOf("See ");
38532
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   146
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   147
            assertTrue(pos > 0);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   148
            String name = line.substring(0, pos).trim();
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   149
            String repl = line.substring(pos, line.length()).trim();
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   150
            assertEquals(REPLACEMENTS.get(name), repl);
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   151
        }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   152
    }
24f77d64bb1f 8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
diff changeset
   153
}