RFR: 8341924: Improve error message with structurally malformed Code array

Chen Liang liach at openjdk.org
Fri Oct 11 05:44:19 UTC 2024


Patch a tableswitch instruction's low value to be greater than a high value, previously, javap will not print any previous instruction and report problematic address/bci to be 0. This is because the iteration of bound models require first collecting all data into a buffer list. We call the eager `forEach` instead to avoid this problem.

Before:

$ javap -c BadSwitch.class
Compiled from "BadSwitch.java"
final class BadSwitch {
  static void work(int);
    Code:
Error: error at or after byte 0
}


Now:

$ $localjdk2/bin/javap -c BadSwitch.class
Compiled from "BadSwitch.java"
final class BadSwitch {
  static void work(int);
    Code:
       0: iload_0
Error: error at or after address 1: Invalid tableswitch values low: 9 high: 5
}

-------------

Commit messages:
 - 8341924: Improve error message with structurally malformed Code array

Changes: https://git.openjdk.org/jdk/pull/21463/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21463&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8341924
  Stats: 9 lines in 1 file changed: 2 ins; 0 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/21463.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21463/head:pull/21463

PR: https://git.openjdk.org/jdk/pull/21463


More information about the compiler-dev mailing list