Skip to content

Conversation

@sgammon
Copy link
Contributor

@sgammon sgammon commented Jan 31, 2025

Summary

Applies -Xjsr305=strict support for Pkl's own annotations, org.pkl.core.util.Nullable and org.pkl.core.util.Nonnull. Java parameter names are retained in Kotlin bytecode, enabling smoother Java/Kotlin interop and debugging. Fixes deprecated/outdated use of Kotlin Gradle Plugin.

@sgammon sgammon changed the title feat: jsr305 compat for kotlinc JSR305 integration for kotlinc Jan 31, 2025
@sgammon sgammon mentioned this pull request Jan 31, 2025
3 tasks
@sgammon sgammon force-pushed the feat/kotlinc-opts branch 2 times, most recently from 417fa41 to 57d79ec Compare February 2, 2025 01:10
- feat: treat jsr305 as strict
- feat: consider pkl's annotations for jsr305 compat

Signed-off-by: Sam Gammon <sam@elide.dev>
@sgammon sgammon mentioned this pull request Feb 3, 2025
7 tasks
Copy link
Member

@bioball bioball left a comment

Choose a reason for hiding this comment

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

We already have some of these flags set, see

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xjvm-default=all")
}
}

As far as I can tell, we don't need -Xjsr305=@org.pkl.core.util.Nullable:strict nor -Xjsr305=@org.pkl.core.util.Nonnull:strict, and we already get compiler errors on the Kotlin side.

For example:

diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliEvaluator.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliEvaluator.kt
index 3ae23de..c72c201 100644
--- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliEvaluator.kt
+++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliEvaluator.kt
@@ -93,6 +93,7 @@ constructor(
    */
   override fun doRun() {
     val builder = evaluatorBuilder()
+    println(builder.securityManager.checkReadResource(URI("foo:bar")))
     try {
       if (options.multipleFileOutputPath != null) {
         writeMultipleFileOutput(builder)

Can you expand on javaParameters? How does this help debugging?

@sgammon
Copy link
Contributor Author

sgammon commented Feb 4, 2025

@bioball Good points. Let me do some testing to verify my assumptions and I'll get back to you.

@sgammon sgammon closed this Feb 4, 2025
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.

2 participants