当您在类路径中运行带有注释处理器和损坏的jar的javac时,java会出错,但会返回0作为错误代码(0表示它运行时没有任何错误)。如果在没有注释处理器的情况下运行相同的命令,则返回1作为错误代码。因此,添加annotationProcessor会删除错误代码。
下面是一些示例输出: running compile with a corrupted jar
error: error reading corruptedJar.jar; error in opening zip file
Using Test AnnotationProcessor
Error level 0
running compile without the corrupted jar
Using Test AnnotationProcessor
Error level 0
running compile without the annotationProcessor but with the corrupted jar
error: error reading corruptedJar.jar; error in opening zip file
1 error
Error level 1
我用来运行上面输出的bat文件是
@echo off
echo running compile with a corrupted jar
javac -cp annotationProcessor.jar;corruptedJar.jar HelloWorld.java
echo Error level %errorlevel%
echo running compile without the corrupted jar
javac -cp annotationProcessor.jar HelloWorld.java
echo Error level %errorlevel%
echo running compile without the annotationProcessor but with the corrupted jar
javac -cp corruptedJar.jar HelloWorld.java
echo Error level %errorlevel%
我是否错过了参数,或者这是javac中返回错误级别错误的错误?
编辑..
所有内容https://gist.github.com/ludjer/570708438dbcb3f08106
的源代码annotationProcessor.jar中有一个名为AnnotationProcessor的类
答案 0 :(得分:0)
我已经用oracle打开了一个bug,它在JDK bug跟踪器上: