JDK-8136583 : Core libraries should use blessed modifier order
  • Type: Bug
  • Component: core-libs
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-09-16
  • Updated: 2021-11-02
  • Resolved: 2015-09-16
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 9
9 b83Fixed
Related Reports
Relates :  
Relates :  
Description
There is the one true modifier order documented in the JLS and Modifier#toString().  The JDK sources should use it.

Here's my one weird hack to make it so:

#!/bin/bash
# See
# https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Modifier.html#toString-int-
#
# blessed-modifier-order src/java.base test/java/{util,io,lang}
set -eu
declare -ar dirs=("$@")
declare -ar modifiers=(
  public protected private
  abstract static final transient
  volatile synchronized native strictfp
)
declare -r SAVE_IFS="$IFS"
for ((i = 3; i < "${#modifiers[@]}"; i++)); do
  IFS='|'; x="${modifiers[*]:0:i}" y="${modifiers[*]:i}"; IFS="$SAVE_IFS"
  if [[ -n "$x" && -n "$y" ]]; then
    find "${dirs[@]}" -name '*.java' -type f | xargs perl -p -i -e \
      "do {} while s/^([A-Za-z@ ]*)\b($y) +($x)\b/\1\3 \2/"
  fi
done

Comments
It is verified as "Not verified" due to this is a noreg-* issue.
10-07-2017

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/f068a4ffddd2 User: lana Date: 2015-09-23 23:04:33 +0000
23-09-2015

URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/f068a4ffddd2 User: martin Date: 2015-09-16 18:32:03 +0000
16-09-2015