[code-reflection] RFR: Support array type constants in code model
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jan 19 17:37:57 UTC 2024
On Fri, 19 Jan 2024 08:52:08 GMT, Hannes Greule <hgreule at openjdk.org> wrote:
> Previously, expressions like `String[].class` weren't supported in the code model.
>
> As types are embedded by their fully qualified names (e.g. `java.lang.String[]`), we also have to parse that representation again. I didn't find an existing method to do so, so I wrote it myself. Please let me know if there's a better approach.
>
> I also adapted the test from `TestArrayCreation.java`, using different kinds of array types.
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java line 907:
> 905: @Override
> 906: public void visitTypeArray(JCTree.JCArrayTypeTree tree) {
> 907: result = null; // MyType[].class is handled in visitSelect just as MyType.class
Looks good - can you add a test case in `test/langtools/tools/javac/reflect/ConstantTest` (the last test case in this test has an example of class literals). Just to make sure the IR comes out ok, and that we don't have regression when we change the compiler code ;-)
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/5#discussion_r1459413553
More information about the babylon-dev
mailing list