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

Oliver Kopp duke at openjdk.org
Wed Jun 14 20:16:20 UTC 2023


On Mon, 12 Jun 2023 05:47:41 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 incrementally with two additional commits since the last revision:
> 
>  - Remove "final" at "enabled" - not part of the point of this PR
>  - Remove comments

@asotona At https://bugs.openjdk.org/browse/JDK-8240567?focusedCommentId=14588425&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14588425 you asked the following:
    
> Did you consider also constant pool 65k entries size limit? 
When module descriptors are split into multiple methods due to their code size, the system modules plugin may soon hit the class constant pool limit of 65k unique entries

I don't have a bugs.openjdk.org account; thus I reply here.

The constant pool is also an "interesting" limitation. We did not address it (yet) because the current patch is IMHO a major step forward: It unblocks feature development of our software: We can add new external libraries 🎉

Looking more close to that limit and the implications to the patch: I understand that this limit affects the number of methods in a class. If this is correct, let's assume that a project requires thousands of modules and would use half of the limit for the generation of the module descriptors. That would result in roughly 32,000 methods. The patch puts 50 module descriptors in one method. Assuming 32,000 methods leads to ~1.6 million modules for a Java program.

Currently, our project [JabRef](https://github.com/jabref/jabref/) has a total number of ~130 modules. We cannot move forward with our release as we cannot add new dependencies. We hope that other projects with many modules will benefit from this patch as well.

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

PR Comment: https://git.openjdk.org/jdk/pull/14408#issuecomment-1591903575


More information about the core-libs-dev mailing list