Skip to content

Render object arrays as Kotlin Array<T> in querydsl-kotlin-codegen (#1790)#1791

Merged
velo merged 1 commit into
OpenFeign:masterfrom
seonwooj0810:fix/issue-1790-kotlin-object-array
Jun 9, 2026
Merged

Render object arrays as Kotlin Array<T> in querydsl-kotlin-codegen (#1790)#1791
velo merged 1 commit into
OpenFeign:masterfrom
seonwooj0810:fix/issue-1790-kotlin-object-array

Conversation

@seonwooj0810

Copy link
Copy Markdown
Contributor

Fixes #1790

Problem

querydsl-kotlin-codegen emitted object-array properties (e.g. String[]) using Java array syntax, producing code that does not compile:

val tags: ArrayPath<String[], String> = createArray("tags", String[]::class.java)

String[] and String[]::class.java are not valid Kotlin.

Cause

In Extensions.kt, Type.asClassName() special-cases the eight primitive array types (int[]IntArray, etc.), but object arrays fall through to the generic ClassName(packageName, simpleName) branch, where the array's simpleName (String[]) leaks into the generated source. asClassNameStatement() had the same gap.

Fix

Map object arrays to the Kotlin Array<T> type and the Array<T>::class.java class literal, while leaving primitive arrays on their dedicated Kotlin array classes (IntArray, ByteArray, …). Object arrays are detected via Type.getComponentType(), excluding the primitive-array full names that asClassName() already handles. The same now generates:

val tags: ArrayPath<Array<String>, String> = createArray("tags", Array<String>::class.java)

Tests

Added EntitySerializerTest.object_array, taken from the reproducer in #1790, which asserts the generated declaration/statement and (via the existing assertCompiles helper) that the output compiles.

mvn -Pno-databases -pl querydsl-tooling/querydsl-kotlin-codegen test
Tests run: 27, Failures: 0, Errors: 0, Skipped: 2 → BUILD SUCCESS

Verification done: (1) no in-flight PR/linked branch for the array bug; (2) no active claim on the issue (only the boilerplate template checkbox); (3) fix touches .kt files only; (4) confirmed the missing object-array case in asClassName/asClassNameStatement on current master; (5) reproduced with the issue's test, which failed before and passes after; full querydsl-kotlin-codegen test suite green with no regressions.

Object array properties (e.g. String[]) were emitted with Java array
syntax (ArrayPath<String[], String> = createArray("tags", String[]::class.java)),
which is not valid Kotlin and fails to compile. Map object arrays to the
Kotlin Array<T> type and the Array<T>::class.java class literal, while
keeping primitive arrays (int[], byte[], ...) on their dedicated Kotlin
array classes (IntArray, ByteArray, ...).

Fixes OpenFeign#1790

Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the focused fix. The production change has a compiling regression test, preserves existing primitive-array behavior and public API compatibility, and introduces no security risk. Required checks are green.

@velo velo merged commit 998aad0 into OpenFeign:master Jun 9, 2026
4 checks passed
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.

Invalid handling of object Arrays in querydsl-kotlin-codegen

2 participants