JDK-4411102 : javac language could use a __FILE__ and __LINE__ capability
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2001-02-02
  • Updated: 2001-02-07
  • Resolved: 2001-02-07
Related Reports
Relates :  
Description

Name: boT120536			Date: 02/01/2001


O:\>java -version
java version "1.2.1"
Classic VM (build JDK-1.2.1-A, native threads)

If the java compiler could have an __FILE__ and and __LINE__ capability as in C
and C++ it would be very useful.  The __FILE__ macro gets replaced with the
filename.  The __LINE__ macro gets replaced with the line number.

In many error and debugging messages, it is just as important where the message
came from as well as the message itself.  How many times do you find yourself
grepping through files trying to find where a message came from.  Although you
can get some of this info from a throwable, it is only accurrate for non-JIT
classes. The file name and line number information is lost in the JIT.
(Review ID: 116199) 
======================================================================

Comments
PUBLIC COMMENTS See JSR-47; it may help with this kind of issue.
10-06-2004

EVALUATION The logging API under development for Merlin addresses these issues to a certain extent. See JSR-47. Certainly, one doesn't want to formulate a solution along the lines proposed here. The writer assumes that source code is stored in files, for example. This isn't always the case, and certainly not a requirement the language should impose. gilad.bracha@eng 2001-02-07
07-02-2001

WORK AROUND Newer JIT compilers preserve the line numbers. As the author observes, something approximating this capability is in throwable. neal.gafter@Eng 2001-02-06
06-02-2001