RFR: 8341966: Broken annotated module may lead to an exception in javac
Chen Liang
liach at openjdk.org
Mon Oct 14 05:49:10 UTC 2024
On Mon, 14 Oct 2024 05:35:39 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider a `module-info.class`, that both:
> - is wrong, so it will produce a bad-classfile error, for example due to an illegal `requires transitive java.base;`
> - and the module is annotated
>
> If the javac proceeds to resolve the annotations (which is not the default, but can be pushed to do it), it will crash with an `AssertionError` while trying to un-proxy the annotations. This is because there's an assert that `requestingOwner.owner.kind == MDL`, but since the module is erroneous, the kind is `ERR`, and the assert fails.
>
> The proposal is to loosen the assert a bit, and require `requestingOwner.owner instanceof ModuleSymbol`. That should still be sufficiently strong, while permitting broken modules to be handled.
test/langtools/tools/javac/modules/AnnotationsOnModules.java line 755:
> 753: byte[] newBytes = ClassFile.of().transformClass(cm1, new ClassTransform() {
> 754: @Override
> 755: public void accept(ClassBuilder builder, ClassElement element) {
Is there any restriction so that you cannot use a lambda here?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21486#discussion_r1798775877
More information about the compiler-dev
mailing list