mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Flawed construction of Java objects involving polymorphic Listings #191
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?
Originally created by @elkoDev on GitHub (Jul 24, 2024).
Context
Steps to reproduce
Given the following module with a polymorphic listing:
We generate the corresponding Java classes:
We use the ValueMapper to create an object of type
AsError
@holzensp commented on GitHub (Jul 24, 2024):
This appears to be a bug. Especially
is surprising.
@bioball commented on GitHub (Jul 24, 2024):
I don't think this is a bug; at least, I can't reproduce it here: https://github.com/bioball/pkl-jvm-examples/blob/repro-issue-597/codegen-java/src/main/java/example/JavaCodeGeneratorExample.java
From that error message, it looks like It is trying to initialize
A, which probably means that you are not including the generated properties file in your classpath.The code generator will produce two directories in the output dir;
java, andresources. Are you including both of these in your classpath?@elkoDev commented on GitHub (Jul 24, 2024):
Thank you for the fast response, probably I did not include the properties file to the class path. I think this issue can be closed.
@bioball commented on GitHub (Jul 24, 2024):
By the way:
ValueMapperisn't really meant to be used like this. It's used internally byConfigEvaluatorto map values for you.The way you'd typically eval into Java is through the
asmethod. For example, something like: