Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have typeIndex be an cp index to descriptor of the enum type in EnumAnnotationValue #15

Merged
merged 1 commit into from
May 11, 2021

Conversation

vootelerotov
Copy link

Previously, typeIndex was an index to internal name of the enum type.
This does ahdere to JVMS.

Relevant snippets from JVMS:
type_name_index
The constant_pool entry at that index must be a CONSTANT_Utf8_info
structure (§4.4.7) representing a field descriptor (§4.3.2).

https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.16.1

The issue causes IllegalArgumentException when reading generated classes with ASM 6.1.1.

Previously, typeIndex was an index to internal name of the enum type.
This does ahdere to JVMS.

Relevant snippets from JVMS:
type_name_index
The constant_pool entry at that index must be a CONSTANT_Utf8_info
structure (§4.4.7) representing a field descriptor (§4.3.2).

https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.16.1
Copy link

@Ladicek Ladicek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at both JDK 8 and JDK 11 and they have a special case in AnnotationParser.parseEnumValue:

        if (!typeName.endsWith(";")) {
            // support now-obsolete early jsr175-format class files.
            if (!enumType.getName().equals(typeName))
            return new AnnotationTypeMismatchExceptionProxy(
                typeName + "." + constName);
        } else ...

This is lost in JDK 17 with commit openjdk/jdk@8758b55

That makes this PR a must-have for JDK 17 support.

Additional references:

I have also built JBoss Class File Writer from master with this commit on top, then built Weld with the modified version of JBoss Class File Writer, and can confirm that a lot of tests in SmallRye Fault Tolerance that used to fail on JDK 17-ea now pass.

@manovotn manovotn merged commit 6fc7727 into jbossas:master May 11, 2021
@vootelerotov vootelerotov deleted the enum-annotation-value-desc branch May 12, 2021 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants