javac 错误消息不显示整个文件路径 [英] javac error message does not display entire filepath
问题描述
使用 javac(或 ant 任务)时,错误信息不包括整个文件路径,它只包括文件名.例如,
When using javac (or the ant task ), the error message does not include the entire filepath, it only includes the file name. For example,
$ javac src/path/to/Filename.java
Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
^
我想要的是,
$ javac src/path/to/Filename.java
src/path/to/Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
^
我的问题是,如果没有给出整个文件路径,而不仅仅是文件名,vim quickfix 将无法工作.只需输入文件名,运行 :make 后就会打开一个新的空文件.
My problem is that vim quickfix does not work if it's not given the entire filepath, not just the filename. With just the filename, a new empty file is opened up after running :make.
我正在使用:
- Debian 喘息
- openjdk-6-jdk v6b23~pre7-1
- javac v1.6.0_23
推荐答案
我认为没有一种简单的方法可以做到这一点.
I don't think there is a simple way to do this.
但是,我相信有一个复杂的方法.它基本上涉及编写您自己的编译器运行器,该运行器利用 JDK 安装的能力在正在运行的程序中加载和运行 Java 编译器.您需要实现很多东西,但关键是诊断处理器可以按照您需要的方式格式化编译器错误消息.
However, I believe that there is a complicated way. It basically involves writing your own compiler runner that makes use of a JDK installation's ability to load and run the Java compiler inside of a running program. You need to implement a lot of stuff, but the key thing is a diagnostic processor that formats the compiler error messages in the way that you need them to be formatted.
以下是一些相关链接:
- 打包
javax.工具
- 为可以从程序调用的工具提供接口,例如编译器. JavaCompiler
- 编译器实现的接口FileObject
- 编译器用来表示源文件的接口;例如在诊断方面.注意toUri()
方法!
这篇关于javac 错误消息不显示整个文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!