javac error message does not display entire filepath

喜欢而已 提交于 2019-12-12 08:53:21

问题


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;
              ^

What I would like is,

$ javac src/path/to/Filename.java
src/path/to/Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
              ^

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.

I'm using:

  • Debian wheezy
  • openjdk-6-jdk v6b23~pre7-1
  • javac v1.6.0_23

回答1:


I don't think there is a simple way to do this.

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.

Here are some relevant links:

  • Package javax.tools - provides interfaces for tools which can be invoked from a program, for example, compilers.
  • JavaCompiler - the interface implemented by the compiler
  • FileObject - the interface that the compiler uses to represent source files; e.g. in diagnostics. Note the toUri() method!


来源:https://stackoverflow.com/questions/7136283/javac-error-message-does-not-display-entire-filepath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!