test/tools/javah/constMacroTest/ConstMacroTest.java

changeset 1637
2e21ecd7a5ad
parent 1591
dc8b7aa7cef3
child 2525
2eb010b6cb22
equal deleted inserted replaced
1636:82dc1e827c2a 1637:2e21ecd7a5ad
36 import java.nio.file.Paths; 36 import java.nio.file.Paths;
37 37
38 //original test: test/tools/javah/ConstMacroTest.sh 38 //original test: test/tools/javah/ConstMacroTest.sh
39 public class ConstMacroTest { 39 public class ConstMacroTest {
40 40
41 private static final String SubClassConstsGoldenFile = 41 private static final String subClassConstsGoldenFileTemplate =
42 "/* DO NOT EDIT THIS FILE - it is machine generated */\n" + 42 "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
43 "#include <jni.h>\n" + 43 "#include <jni.h>\n" +
44 "/* Header for class SubClassConsts */\n" + 44 "/* Header for class SubClassConsts */\n" +
45 "\n" + 45 "\n" +
46 "#ifndef _Included_SubClassConsts\n" + 46 "#ifndef _Included_SubClassConsts\n" +
47 "#define _Included_SubClassConsts\n" + 47 "#define _Included_SubClassConsts\n" +
48 "#ifdef __cplusplus\n" + 48 "#ifdef __cplusplus\n" +
49 "extern \"C\" {\n" + 49 "extern \"C\" {\n" +
50 "#endif\n" + 50 "#endif\n" +
51 "#undef SubClassConsts_serialVersionUID\n" + 51 "#undef SubClassConsts_serialVersionUID\n" +
52 "#define SubClassConsts_serialVersionUID 6733861379283244755LL\n" + 52 "#define SubClassConsts_serialVersionUID 6733861379283244755%s\n" +
53 "#undef SubClassConsts_SUPER_INT_CONSTANT\n" + 53 "#undef SubClassConsts_SUPER_INT_CONSTANT\n" +
54 "#define SubClassConsts_SUPER_INT_CONSTANT 3L\n" + 54 "#define SubClassConsts_SUPER_INT_CONSTANT 3L\n" +
55 "#undef SubClassConsts_SUPER_FLOAT_CONSTANT\n" + 55 "#undef SubClassConsts_SUPER_FLOAT_CONSTANT\n" +
56 "#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f\n" + 56 "#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f\n" +
57 "#undef SubClassConsts_SUPER_DOUBLE_CONSTANT\n" + 57 "#undef SubClassConsts_SUPER_DOUBLE_CONSTANT\n" +
69 "#ifdef __cplusplus\n" + 69 "#ifdef __cplusplus\n" +
70 "}\n" + 70 "}\n" +
71 "#endif\n" + 71 "#endif\n" +
72 "#endif"; 72 "#endif";
73 73
74 private static final String serialVersionUIDSuffix =
75 ToolBox.isWindows() ? "i64" : "LL"; ;
76
74 public static void main(String[] args) throws Exception { 77 public static void main(String[] args) throws Exception {
75 //first steps are now done by jtreg 78 //first steps are now done by jtreg
76 // cp "${TESTSRC}${FS}SuperClassConsts.java" . 79 // cp "${TESTSRC}${FS}SuperClassConsts.java" .
77 // cp "${TESTSRC}${FS}SubClassConsts.java" . 80 // cp "${TESTSRC}${FS}SubClassConsts.java" .
78 81
83 new ToolBox.JavaToolArgs() 86 new ToolBox.JavaToolArgs()
84 .setAllArgs("-cp", System.getProperty("test.classes"), "SubClassConsts"); 87 .setAllArgs("-cp", System.getProperty("test.classes"), "SubClassConsts");
85 ToolBox.javah(successParams); 88 ToolBox.javah(successParams);
86 89
87 // diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}" 90 // diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
91 String subClassConstGoldenFile = String.format(subClassConstsGoldenFileTemplate,
92 serialVersionUIDSuffix);
88 ToolBox.compareLines(Paths.get("SubClassConsts.h"), 93 ToolBox.compareLines(Paths.get("SubClassConsts.h"),
89 ToolBox.splitLines(SubClassConstsGoldenFile), null); 94 ToolBox.splitLines(subClassConstGoldenFile, "\n"), null, true);
90 } 95 }
91 96
92 } 97 }
93 98
94 class SuperClassConsts implements Serializable { 99 class SuperClassConsts implements Serializable {

mercurial