RFR: 8240567: MethodTooLargeException thrown while creating a jlink image [v5]

Alan Bateman alanb at openjdk.org
Thu Jun 29 18:10:27 UTC 2023


On Fri, 23 Jun 2023 12:10:33 GMT, Oliver Kopp <duke at openjdk.org> wrote:

>> Fix for [JDK-8240567](https://bugs.openjdk.org/browse/JDK-8240567): "MethodTooLargeException thrown while creating a jlink image".
>> 
>> Java still has a 64kb limit: A method may not be longer than 64kb. The idea of the fix is to split up the generated methods in several smaller methods
>> 
>> This is a follow-up to https://github.com/openjdk/jdk/pull/10704. GitHub did not allow me to re-open the PR, because I did a force-push to have one commit.
>
> Oliver Kopp 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 'openjdk:master' into fix-8240567
>  - Merge remote-tracking branch 'upstream/master' into fix-8240567
>  - Merge remote-tracking branch 'upstream/master' into fix-8240567
>  - Remove "final" at "enabled" - not part of the point of this PR
>  - Remove comments
>  - 8240567: MethodTooLargeException thrown while creating a jlink image
>    
>    Co-authored-by: Christoph Schwentker <siedlerkiller at gmail.com>

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java line 694:

> 692:             List<ModuleInfo> currentModuleInfos = null;
> 693:             for (int index = 0; index < moduleInfos.size(); index++) {
> 694:                 if (index % 50 == 0) {

The size of the generated moduleDescriptors is a function of the number of modules, the number of packages in the modules, number of exports, ...   I think your approach is okay for now,  meaning pick some threshold that you are confident will result in a method size < 64k. If the number of modules generate a chained methods to popular the array. It might be clearer to readers to use one threshold rather than two.

The other limit that we will need to think about is the constant pool. That may be future work.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14408#discussion_r1246940571


More information about the core-libs-dev mailing list