1
1
/*
2
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
23
23
24
24
/*
25
25
* @test
26
- * @bug 8203176
26
+ * @bug 8203176 8271258
27
27
* @summary javadoc handles non-ASCII characters incorrectly
28
28
* @library /tools/lib ../../lib
29
29
* @modules jdk.javadoc/jdk.javadoc.internal.tool
33
33
34
34
import java .nio .file .Files ;
35
35
import java .nio .file .Path ;
36
- import java .nio .file .Paths ;
37
36
38
37
import javadoc .tester .JavadocTester ;
39
38
import toolbox .ToolBox ;
@@ -42,20 +41,20 @@ public class TestUnicode extends JavadocTester {
42
41
43
42
public static void main (String ... args ) throws Exception {
44
43
TestUnicode tester = new TestUnicode ();
45
- tester .runTests ();
44
+ tester .runTests (m -> new Object [] { Path . of ( m . getName ())} );
46
45
}
47
46
48
47
ToolBox tb = new ToolBox ();
49
48
50
49
@ Test
51
- public void test ( ) throws Exception {
50
+ public void testUnicode ( Path base ) throws Exception {
52
51
char ellipsis = '\u2026' ;
53
- Path src = Files .createDirectories (Paths . get ("src" ));
52
+ Path src = Files .createDirectories (base . resolve ("src" ));
54
53
tb .writeJavaFiles (src ,
55
54
"/** Hel" + ellipsis + "lo {@code World(" + ellipsis + ")}. */\n "
56
55
+ "public class Code { }\n " );
57
56
58
- javadoc ("-d" , "out" ,
57
+ javadoc ("-d" , base . resolve ( "out" ). toString () ,
59
58
"-encoding" , "utf-8" ,
60
59
src .resolve ("Code.java" ).toString ());
61
60
checkExit (Exit .OK );
@@ -65,4 +64,66 @@ public void test() throws Exception {
65
64
checkOutput ("Code.html" , false ,
66
65
"\\ u" );
67
66
}
67
+
68
+ @ Test
69
+ public void testParam (Path base ) throws Exception {
70
+ String chineseElephant = "\u5927 \u8c61 " ; // taken from JDK-8271258
71
+ Path src = Files .createDirectories (base .resolve ("src" ));
72
+ tb .writeJavaFiles (src ,
73
+ """
74
+ /**
75
+ * Comment. ##.
76
+ * @param <##> the ##
77
+ */
78
+ public class Code<##> {
79
+ /**
80
+ * Comment. ##.
81
+ * @param ## the ##
82
+ */
83
+ public void set##(int ##) { }
84
+ }""" .replaceAll ("##" , chineseElephant ));
85
+
86
+ javadoc ("-d" , base .resolve ("out" ).toString (),
87
+ "-encoding" , "utf-8" ,
88
+ "--no-platform-links" ,
89
+ src .resolve ("Code.java" ).toString ());
90
+ checkExit (Exit .OK );
91
+
92
+ checkOutput ("Code.html" , true ,
93
+ """
94
+ <h1 title="Class Code" class="title">Class Code<##></h1>
95
+ """ .replaceAll ("##" , chineseElephant ),
96
+ """
97
+ <div class="inheritance" title="Inheritance Tree">java.lang.Object
98
+ <div class="inheritance">Code<##></div>
99
+ </div>
100
+ """ .replaceAll ("##" , chineseElephant ),
101
+ """
102
+ <dl class="notes">
103
+ <dt>Type Parameters:</dt>
104
+ <dd><code>##</code> - the ##</dd>
105
+ </dl>
106
+ """ .replaceAll ("##" , chineseElephant ),
107
+ """
108
+ <section class="detail" id="set##(int)">
109
+ <h3>set##</h3>
110
+ <div class="member-signature"><span class="modifiers">public</span> <span c\
111
+ lass="return-type">void</span> <span class="element-name">set##</span><wbr>\
112
+ <span class="parameters">(int ##)</span></div>
113
+ <div class="block">Comment. ##.</div>
114
+ <dl class="notes">
115
+ <dt>Parameters:</dt>
116
+ <dd><code>##</code> - the ##</dd>
117
+ </dl>
118
+ </section>
119
+ """ .replaceAll ("##" , chineseElephant )
120
+ );
121
+
122
+ // The following checks for the numeric forms of the Unicode characters being tested:
123
+ // these numeric forms should not show up as literal character sequences.
124
+ checkOutput ("Code.html" , false ,
125
+ Integer .toHexString (chineseElephant .charAt (0 )),
126
+ Integer .toHexString (chineseElephant .charAt (1 ))
127
+ );
128
+ }
68
129
}
0 commit comments