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.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/734
**Author:** [@odenix](https://github.com/odenix)
**Created:** 10/24/2024
**Status:** ✅ Merged
**Merged:** 10/24/2024
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `stateless-classes`
---
### 📝 Commits (1)
- [`3843175`](https://github.com/apple/pkl/commit/3843175e52011c77c4a6ca8b7016b4717b7161dc) codegen-java: Make stateless classes instantiable
### 📊 Changes
**2 files changed** (+92 additions, -4 deletions)
<details>
<summary>View changed files</summary>
📝 `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)
</details>
### 📄 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.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 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.