Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java
41152 views
1
/*
2
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 6302184 6350124 6357979
27
* @summary javac hidden options that generate source should use the given
28
* encoding, if available
29
* @library /tools/lib
30
* @modules jdk.compiler/com.sun.tools.javac.api
31
* jdk.compiler/com.sun.tools.javac.main
32
* @build toolbox.ToolBox toolbox.JavacTask
33
* @run main HiddenOptionsShouldUseGivenEncodingTest
34
*/
35
36
import java.nio.charset.Charset;
37
import java.nio.file.Files;
38
import java.nio.file.Path;
39
import java.nio.file.Paths;
40
import java.util.Arrays;
41
import java.util.List;
42
43
import toolbox.JavacTask;
44
import toolbox.ToolBox;
45
46
// Original test: test/tools/javac/6302184/T6302184.sh
47
public class HiddenOptionsShouldUseGivenEncodingTest {
48
49
public static void main(String[] args) throws Exception {
50
String encoding = "iso-8859-1";
51
Path src = Paths.get("src");
52
Files.createDirectories(src);
53
Files.write(src.resolve("T6302184.java"), source, Charset.forName(encoding));
54
Files.write(src.resolve("T6302184.out"), expect, Charset.forName(encoding));
55
56
Path out = Paths.get("out");
57
Files.createDirectories(out);
58
59
ToolBox tb = new ToolBox();
60
new JavacTask(tb)
61
.outdir("out")
62
.options("-encoding", encoding, "-XD-printsource")
63
.files(src.resolve("T6302184.java"))
64
.run();
65
66
Path path1 = Paths.get("out").resolve("T6302184.java");
67
List<String> file1 = tb.readAllLines(path1, encoding);
68
Path path2 = src.resolve("T6302184.out");
69
List<String> file2 = tb.readAllLines(path2, encoding);
70
tb.checkEqual(file1, file2);
71
}
72
73
static List<String> source = Arrays.asList(
74
"class T6302184 {",
75
" int \u00c0\u00c1\u00c2\u00c3\u00c4\u00c5 = 1;",
76
"}"
77
);
78
79
static List<String> expect = Arrays.asList(
80
"",
81
"class T6302184 {",
82
" ",
83
" T6302184() {",
84
" super();",
85
" }",
86
" int \u00c0\u00c1\u00c2\u00c3\u00c4\u00c5 = 1;",
87
"}"
88
);
89
90
}
91
92