47 private static final Path CLASSES_DIR = Paths.get("classes");
48
49 private static final Map<String, String> REPLACEMENTS = Map.of(
50 "sun.security.util.HostnameChecker",
51 "Use javax.net.ssl.SSLParameters.setEndpointIdentificationAlgorithm(\"HTTPS\") @since 1.7",
52 "",
53 "or javax.net.ssl.HttpsURLConnection.setHostnameVerifier() @since 1.4");
54
55 /**
56 * Compiles classes used by the test
57 */
58 @BeforeTest
59 public void compileAll() throws Exception {
60 CompilerUtils.cleanDir(CLASSES_DIR);
61
62 Path tmp = Paths.get("tmp");
63 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "apple"), tmp));
64 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "q"),
65 CLASSES_DIR,
66 "-cp", tmp.toString(),
67 "-XaddExports:java.base/sun.security.util=ALL-UNNAMED"));
68 }
69
70 @Test
71 public void withReplacement() {
72 Path file = Paths.get("q", "WithRepl.class");
73 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
74 int i = 0;
75 while (!output[i].contains("Suggested Replacement")) {
76 i++;
77 }
78
79 // must match the number of JDK internal APIs
80 int count = output.length-i-2;
81 assertEquals(count, REPLACEMENTS.size());
82
83 for (int j=i+2; j < output.length; j++) {
84 String line = output[j];
85 int pos = line.indexOf("Use ");
86 if (pos < 0)
87 pos = line.indexOf("or");
|
47 private static final Path CLASSES_DIR = Paths.get("classes");
48
49 private static final Map<String, String> REPLACEMENTS = Map.of(
50 "sun.security.util.HostnameChecker",
51 "Use javax.net.ssl.SSLParameters.setEndpointIdentificationAlgorithm(\"HTTPS\") @since 1.7",
52 "",
53 "or javax.net.ssl.HttpsURLConnection.setHostnameVerifier() @since 1.4");
54
55 /**
56 * Compiles classes used by the test
57 */
58 @BeforeTest
59 public void compileAll() throws Exception {
60 CompilerUtils.cleanDir(CLASSES_DIR);
61
62 Path tmp = Paths.get("tmp");
63 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "apple"), tmp));
64 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "q"),
65 CLASSES_DIR,
66 "-cp", tmp.toString(),
67 "--add-exports=java.base/sun.security.util=ALL-UNNAMED"));
68 }
69
70 @Test
71 public void withReplacement() {
72 Path file = Paths.get("q", "WithRepl.class");
73 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
74 int i = 0;
75 while (!output[i].contains("Suggested Replacement")) {
76 i++;
77 }
78
79 // must match the number of JDK internal APIs
80 int count = output.length-i-2;
81 assertEquals(count, REPLACEMENTS.size());
82
83 for (int j=i+2; j < output.length; j++) {
84 String line = output[j];
85 int pos = line.indexOf("Use ");
86 if (pos < 0)
87 pos = line.indexOf("or");
|