Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Realm Plugin setting the bytecode target to 1.8 #1514

Merged
merged 6 commits into from
Sep 14, 2023

Conversation

cmelchior
Copy link
Contributor

From Kotlin 1.8.0 the minimum supported Java target is 1.8. This means there is no longer any reason we are setting this in our Realm Plugin. In fact, it might silently modify the behavior of people's compiled code if they are not setting the jvmTarget themselves: https://kotlinlang.org/docs/whatsnew18.html#updated-jvm-compilation-target

I tested this with various combinations of Java (11 and 17) and build.gradle settings and it doesn't seem to cause build failures.

At the same time, I also unified how we are setting the Kotlin and Java bytecode versions, so they can now all be controlled through our buildSrc Config file.

Regarding the target version, I kept it at 1.8 since we don't know what version of the JVM people are running on the desktop. On Android the minimum the 11, but it didn't seem worth it to try to differentiate the two.

Since we are running Java 11 as a minimum on our developer machines and CI, we could probably set the sourceCompatibility to 11 as well, but the confusion didn't seem worth it. Also, we don't really have any Java sources to speak of anyway.

@cmelchior cmelchior requested review from rorbech and clementetb and removed request for rorbech September 12, 2023 08:14
@cla-bot cla-bot bot added the cla: yes label Sep 12, 2023
Copy link
Contributor

@rorbech rorbech left a comment

Choose a reason for hiding this comment

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

LGTM ... if CI is green.

CHANGELOG.md Outdated Show resolved Hide resolved
Christian Melchior added 2 commits September 12, 2023 16:51
Add support for Java 17 when using ktlintFormat.
# Conflicts:
#	buildSrc/src/main/kotlin/Config.kt
CHANGELOG.md Outdated Show resolved Hide resolved
kotlinOptions.jvmTarget = Versions.jvmTarget
}
}
jvm()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it getting the correct target default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -57,6 +57,7 @@ allprojects {

description = "Check Kotlin code style."
classpath = ktlint
jvmArgs = listOf("--add-opens=java.base/java.lang=ALL-UNNAMED")
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this? for refelction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some APIs changed or modularized after Java 11, so if you are using Java 17, ktlint will crash. This will fix it.

@cmelchior cmelchior merged commit 4bafc61 into main Sep 14, 2023
1 check passed
@cmelchior cmelchior deleted the cm/unify-jvm-bytecode branch September 14, 2023 15:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants