JDK-8033581 : Incorrect comment alignment
  • Type: Bug
  • Component: tools
  • Sub-Component: javap
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-02-04
  • Updated: 2014-07-29
  • Resolved: 2014-02-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u20Fixed 9 b04Fixed
Description
1. The Javap's output for small (zero) column number (specified with -XDtab option) looks like:
.............
Constant pool:
   #1 = Methodref       #19.#54//  java/lang/Object."<init>":()V
   #2 = String             #55//  PUBLIC FINAL CONSTANT
   #3 = Fieldref           #18.#56//  StructureSampleClass.publicFinalConstant:Ljava/lang/String;
   #4 = String             #57//  PROTECTED FINAL CONSTANT
   #5 = Fieldref           #18.#58//  StructureSampleClass.protectedFinalConstant:Ljava/lang/String;
   #6 = String             #59//  PRIVATE FINAL CONSTANT
.....................
At least one space symbol should be added (or it would be even better to check a minimum column position to align comments within a logical block of output.

2. The actual comment position is not equal to the specified value but shifted by the current indent value (so comments in the constant pool and the code section are placed on different positions).
Comments
Re: double space: probably not
19-02-2014

BTW, is a double space after the comment symbols "//" intended?
19-02-2014

I have decided, for now, to retain the behavior that the tab position (mostly used for indenting comments) should be auto shifted by the indent amount.
06-02-2014

Re: it would be even better to check a minimum column position to align comments within a logical block of output That's what the tab position is meant to be ;-)
05-02-2014

1. Agreed on the need for a single space when the buffer is past the tab column 2. The current behavior is deliberate, but I can see the merit of changing to the behavior you propose. But it does that as text gets indented, the chance of overrunning the tab increases. The main thing is that the comments do align well within a block of output, as compared to the previous impl of using tab stobs every 8 columns.
05-02-2014

I'm inclined to disallow a tab of <= 0.
05-02-2014