RFR: 8219810: javac throws NullPointerException [v3]
Vicente Romero
vromero at openjdk.org
Tue Jan 3 21:23:53 UTC 2023
On Mon, 19 Dec 2022 15:44:57 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:
>> JVMS 4.5 states:
>>
>>> Each field of a class may have at most one of its ACC_PUBLIC, ACC_PRIVATE, and ACC_PROTECTED flags set (JLS §8.3.1), and must not have both its ACC_FINAL and ACC_VOLATILE flags set (JLS §8.3.1.4).
>>
>> and JVMS 4.6 states:
>>
>>> Each method of a class may have at most one of its ACC_PUBLIC, ACC_PRIVATE, and ACC_PROTECTED flags set (JLS §8.4.3).
>>
>> However, when reading class files these illegal combinations are not actually checked, and this can lead to compiler crashes as in the bug example.
>>
>> This patch adds checks for these illegal combinations.
>
> Archie L. Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>
> - Merge branch 'master' into JDK-8219810
> - Merge branch 'master' into JDK-8219810
> - Also disallow field access flags from having both FINAL and VOLATILE.
> - Detect invalid access flag combinations for fields and methods in classfiles.
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java line 2268:
> 2266:
> 2267: if (Integer.bitCount(rawFlags & (PUBLIC | PRIVATE | PROTECTED)) > 1)
> 2268: throw badClassFile("illegal.flag.combo", String.format("0x%04x", (int)rawFlags), "method", m);
instead of: `String.format("0x%04x", (int)rawFlags)`, you could use method `com.sun.tools.javac.code.Flags::toString` which prints a string representation of the flags passed to it
-------------
PR: https://git.openjdk.org/jdk/pull/10826
More information about the compiler-dev
mailing list