RFR: 8320001: javac crashes while adding type annotations to constructor's return type

Werner Dietl wmdietl at openjdk.org
Tue Nov 21 23:34:08 UTC 2023


On Tue, 21 Nov 2023 22:28:11 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> Fix for [1] introduced a regression that is making some internal tests fail. Basically fix for [1] is trying to add annotations read from the class file to the corresponding symbol. Constructors are a bit special given that its return type is `void` thus type annotations can't be added to them. This fix is proposing just dropping the type annotation if it applies to the return type of a constructor.
> 
> TIA
> [1] https://bugs.openjdk.org/browse/JDK-8225377

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java line 2335:

> 2333:             }
> 2334:             mt.thrown = thrown.toList();
> 2335:             /* possible information loss if the type of the method is void then we can't add type

@vicente-romero-oracle Could we open a follow-up issue to add a standard way to retrieve these type annotations?
Type use annotations on constructors are valid Java >= 8 syntax and they are stored in the classfiles, so it would be nice to also get the annotations out of a classfile.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16774#discussion_r1401331446


More information about the compiler-dev mailing list