RFR: 8236490: Compiler bug relating to @NonNull annotation

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Wed Jan 13 12:52:05 UTC 2021

Hi all,

If the exception class index in constant pool exceeds 256, the `exception_index` in `TypeAnnotationPosition` will not work as expected. Please see the following code:

    public void setCatchInfo(final int catchType, final int startPos) {
                     "exception_index is already set");
        Assert.check(catchType >= 0, "Expected a valid catch type");
        this.exception_index = -((catchType | startPos << 8) + 1);  // <------------------------------

If `catchType` > 256, which means the 8-15 bits is useful, the ` -((catchType | startPos << 8) + 1);` would override these bits.

This patch separates the `startPos` into a new field `exceptionStartPos` to solve the bug. And a test case is added.

Thank you for taking the time to review.

Best Regards.


Commit messages:
 - 8236490: Compiler bug relating to @NonNull annotation

Changes: https://git.openjdk.java.net/jdk/pull/2060/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2060&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8236490
  Stats: 117 lines in 2 files changed: 111 ins; 0 del; 6 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2060.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2060/head:pull/2060

PR: https://git.openjdk.java.net/jdk/pull/2060

More information about the compiler-dev mailing list