RFR: 8343064: ClassFormatError: Illegal class name from InnerClassLambdaMetafactory [v3]

Chen Liang liach at openjdk.org
Tue Nov 12 18:00:01 UTC 2024


> After the ClassFile API migration, when serializable lambdas are requested for hidden class callers, illegal class name is generated for the serialization methods, which previously had legal yet unusable class names, as hidden classes cannot be described by a `CONSTANT_Class_info`.
> 
> This patch restores a similar older behavior of using legal yet unusable class names.  Previously, the invalid `.` in hidden class names was replaced by a `/` as if a package separator; this patch changes it to a `_` like that in the generated lambda's class name.
> 
> The bug report shows some unintended and erroneous usages of `LambdaMetafactory`.  To clarify and to persuade against misuse, I added a paragraph of API notes to `LambdaMetafactory`, describing the impact of this API being designed to support Java language features.  In particular, I used the scenario where people assumed LMf generates weak hidden classes, which happened in this issue report and in #12493, that misuse can lead to resource leaks.

Chen Liang 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 six additional commits since the last revision:

 - Merge branch 'master' of https://github.com/openjdk/jdk into fix/lmf-hidden-serial-class-format
 - Update docs per suggestion
 - Merge branch 'master' of https://github.com/openjdk/jdk into fix/lmf-hidden-serial-class-format
 - Add a test to ensure serializable lambda creation and basic execution in hidden classes
 - Specify consequence
 - 8343064: ClassFormatError: Illegal class name from InnerClassLambdaMetafactory

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21912/files
  - new: https://git.openjdk.org/jdk/pull/21912/files/4e3790a9..c5e15955

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21912&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21912&range=01-02

  Stats: 100936 lines in 2665 files changed: 26381 ins; 67224 del; 7331 mod
  Patch: https://git.openjdk.org/jdk/pull/21912.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21912/head:pull/21912

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


More information about the core-libs-dev mailing list