Javac error message does not display full file path

When using javac (or the ant task), the error message does not include the entire path to the file, it includes only the file name. For instance,

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

What i wish

 $ 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 did not give the whole path to the file, and not just the file name. Only with the file name after starting a new empty file is opened: make.

I use:

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

I do not think there is an easy way to do this.

However, I believe that there is a difficult way. This is mainly due to writing your own compiler, which uses the ability to install the JDK to load and run the Java compiler inside a running program. You need to implement a lot of things, but the key is a diagnostic processor that formats the compiler error messages in the way you need to format them.

Here are some relevant links:

  • javax.tools package - provides interfaces for tools that can be called from a program, such as compilers.
  • JavaCompiler - interface implemented by the compiler
  • FileObject - the interface that the compiler uses to represent the source files; for example in diagnostics. Pay attention to the toUri() method!
+1
source

Source: https://habr.com/ru/post/895516/


All Articles