开发者

javac error message does not display entire filepath

开发者 https://www.devze.com 2023-03-29 08:12 出处:网络
When u开发者_如何学Gosing javac (or the ant task ), the error message does not include the entire filepath, it only includes the file name. For example,

When u开发者_如何学Gosing 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


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!
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号