RFR: 8294962: Convert java.base/jdk.internal.module package to use the Classfile API to modify and write module-info.class [v5]
Alan Bateman
alanb at openjdk.org
Tue Mar 14 14:50:40 UTC 2023
On Tue, 14 Mar 2023 12:55:38 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> 8294962: java.base jdk.internal.module package uses ASM to modify and write module-info.class.
>> This patch converts it to use Classfile API.
>>
>> Please review.
>> Thanks,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with five additional commits since the last revision:
>
> - fixed ModuleDescriptorTest::testReadsWithBadPackageFinder to use Classfile API directly to generate modules descriptor without ModulePackagesAttribute
> - ModuleInfoWriter converted to support invalid module names and emit ModulePackagesAttribute if packages are provided
> - fixed Classfile API tests
> - added ModuleAttribute::of(ModuleEntry, Consumer<ModuleAttributeBuilder>)
> - removed obsolete Classfile.buildModule method argument List<PackageDesc> and obsolete method overrides
Marked as reviewed by alanb (Reviewer).
src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 293:
> 291: }
> 292:
> 293: public static final int MAGIC_NUMBER = 0xCAFEBABE;
Dropping the packages parameter and the buildModuleTo overloads looks good.
src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java line 199:
> 197: clb.accept(cle);
> 198: }
> 199: }));
Updated ModuleInfoExtender looks okay.
src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java line 167:
> 165: clb.with(ModuleTargetAttribute.of(target.targetPlatform()));
> 166: }
> 167: });
The update ModuleInfoWriter looks fine.
test/jdk/java/lang/module/ModuleDescriptorTest.java line 1375:
> 1373: ModuleAttribute.of(ModuleDesc.of("foo"), mb -> mb
> 1374: .requires(ModuleDesc.of("java.base"), 0, null)
> 1375: .exports(PackageDesc.of("p"), 0))));
If you split this up into two or third steps then it would be easier to read/debug.
-------------
PR: https://git.openjdk.org/jdk/pull/11368
More information about the core-libs-dev
mailing list