javah我有一个 maven 项目,它通过作为 java 库的正常构建过程的一部分执行来生成 .h JNI 文件。然后将这些 .h 文件签入源代码控制(例如 git)并用于构建随附的本机库。
一个小烦恼是生成的文件javah因行尾不同而不同,具体取决于运行它的平台。因此,如果 Mac OSX 开发人员运行构建并签入(UNIX 样式的行结尾),那么 Windows 开发人员随后将看到他们的构建已更改所有 .h 文件(更改为 Windows 样式的行结尾)。但它们实际上并没有改变——javah只是以一种依赖于平台的方式表现。
javah例如,在生成 .h 文件时,如何哄骗始终使用 UNIX 样式的行尾?似乎没有适当的命令行开关:
> javah.exe
Usage:
javah [options] <classes>
where [options] include:
-o <file> Output file (only one of -d or -o may be used)
-d <dir> Output directory
-v -verbose Enable verbose output
-h --help -? Print this message
-version Print version information
-jni Generate JNI-style header file (default)
-force Always write output files
-classpath <path> Path from which to load classes
-bootclasspath <path> Path from which to load bootstrap classes
<classes> are specified with their fully qualified names
(for example, java.lang.Object).
也许可以手动启动与javah可执行文件启动相同的类,除非"line.separator"在这样做之前显式设置属性。但是,我找不到那会是什么课程,或者在哪里。