RFR: 8303623: Compiler should disallow non-standard UTF-8 string encodings [v5]
Archie L. Cobbs
duke at openjdk.org
Fri Mar 24 14:59:36 UTC 2023
On Thu, 23 Mar 2023 23:37:49 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> 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 seven additional commits since the last revision:
>>
>> - Merge branch 'master' into JDK-8303623
>> - In release 21, emit warning instead of error for invalid UTF-8.
>> - Use Fragments factory for creating message fragments.
>> - Fix incorrect parameter index in message fragment.
>> - Add the standard "This is NOT part of any supported API" warning.
>> - Allow longer-than-necessary UTF-8 encoding in classfiles with major < 48.
>> - Disallow non-standard UTF-8 string encodings.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolReader.java line 235:
>
>> 233: return names.fromUtf(poolbuf.elems, offset + 2, len, utf8validation);
>> 234: } catch (InvalidUtfException e) {
>> 235: if (Source.DEFAULT == Source.JDK21) {
>
> I think that a new feature should be added to `com.sun.tools.javac.code.Source.Feature`, could be named `WARN_ON_NON_STANDARD_UTF8` or so, and use it for this type of check. I would model the new feature based on `DEPRECATION_ON_IMPORT` with `MIN` as its applicable minimum version and 21 as the maximum applicable one
Thanks - that does sound like a more appropriate mechanism to use for controlling this. I'll work on an update.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/12893#discussion_r1147697360
More information about the compiler-dev
mailing list