mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
[PR #734] [MERGED] codegen-java: Make stateless classes instantiable #700
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/734
Author: @odenix
Created: 10/24/2024
Status: ✅ Merged
Merged: 10/24/2024
Merged by: @bioball
Base:
main← Head:stateless-classes📝 Commits (1)
3843175codegen-java: Make stateless classes instantiable📊 Changes
2 files changed (+92 additions, -4 deletions)
View changed files
📝
pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/JavaCodeGenerator.kt(+3 -2)📝
pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt(+89 -2)📄 Description
Last codegen PR for now. :-)
Motivation:
Currently, the condition for making a generated Java class instantiable is "class is neither abstract nor stateless".
(An instantiable class receives a public constructor and equals/hashCode/toString/with methods.)
This is inconsistent with Pkl and codegen-kotlin, both of which support instantiation of stateless classes.
Changes:
Widen condition for making a class instantiable to "class is neither abstract nor a stateless final module class".
This is consistent with codegen-kotlin, which generates object declarations (only) for stateless final module classes.
Result:
Stateless classes are instantiable in Pkl, codegen-java, and codegen-kotlin.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.