Running jlink on a module with a large number of packages fails with a 'Code length outside the allowed range'.
The repro below is based on a real-world example where I was using 'jdeps --generate-module-info' to generate a module-info a a large non-modular jar, and trying to convert it to a modular jar.
I was using a recent build of JDK 22. I think this is similar toJDK-8240567 in that it could be fixed by splitting the generated code across more methods, but is a distinct issue.
# generate a jar with a large number of packages
for i in $(seq 0 3300); do mkdir -p p$i; echo "package p$i; class C$i {}" > p$i/C$i.java; done
javac */*.java
jar cvf t.jar */*.class
# generate a module-info that exports all of the packages in the jar
jdeps --generate-module-info ./ t.jar
javac --patch-module t=t.jar t/module-info.java
# update the existing jar to be modular
jar --verbose --update --file t.jar -C t module-info.class
# run jlink
jlink --module-path t.jar --add-modules t --output t-image
The final jlink command above fails with:
Error: java.lang.IllegalArgumentException: Code length 73216 is outside the allowed range in moduleDescriptors()ModuleDescriptor[]
The repro below is based on a real-world example where I was using 'jdeps --generate-module-info' to generate a module-info a a large non-modular jar, and trying to convert it to a modular jar.
I was using a recent build of JDK 22. I think this is similar to
# generate a jar with a large number of packages
for i in $(seq 0 3300); do mkdir -p p$i; echo "package p$i; class C$i {}" > p$i/C$i.java; done
javac */*.java
jar cvf t.jar */*.class
# generate a module-info that exports all of the packages in the jar
jdeps --generate-module-info ./ t.jar
javac --patch-module t=t.jar t/module-info.java
# update the existing jar to be modular
jar --verbose --update --file t.jar -C t module-info.class
# run jlink
jlink --module-path t.jar --add-modules t --output t-image
The final jlink command above fails with:
Error: java.lang.IllegalArgumentException: Code length 73216 is outside the allowed range in moduleDescriptors()ModuleDescriptor[]
- relates to
-
JDK-8347376 tools/jlink/runtimeImage/JavaSEReproducibleTest.java and PackagedModulesVsRuntimeImageLinkTest.java failed after JDK-8321413
-
- Resolved
-
-
JDK-8240567 MethodTooLargeException thrown while creating a jlink image
-
- Resolved
-
-
JDK-8347484 cmp-baseline failed because ./lib/modules diffs
-
- Closed
-
- links to
-
Commit(master) openjdk/jdk/22f70a74
-
Review(master) openjdk/jdk/21022