Skip to content

Drops Java <16 constraint from pretty_format_kotlin#123

Merged
macisamuele merged 3 commits intomacisamuele:masterfrom
harti2006:feature/drop-ktlint-java-limitation
Dec 5, 2022
Merged

Drops Java <16 constraint from pretty_format_kotlin#123
macisamuele merged 3 commits intomacisamuele:masterfrom
harti2006:feature/drop-ktlint-java-limitation

Conversation

@harti2006
Copy link
Copy Markdown
Contributor

Fixes #122

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 2, 2022

Codecov Report

Merging #123 (52563e6) into master (d9072eb) will not change coverage.
The diff coverage is n/a.

❗ Current head 52563e6 differs from pull request most recent head cf95f11. Consider uploading reports for the commit cf95f11 to get more accurate results

@@            Coverage Diff            @@
##            master      #123   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          305       303    -2     
=========================================
- Hits           305       303    -2     
Impacted Files Coverage Δ
...ormatters_pre_commit_hooks/pretty_format_kotlin.py 100.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment thread language_formatters_pre_commit_hooks/pretty_format_kotlin.py
Copy link
Copy Markdown
Owner

@macisamuele macisamuele left a comment

Choose a reason for hiding this comment

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

Please remove test annotations such that we will know if all test passes.
Once test are green I'll be happy to merge and release this.

@harti2006 thanks for preparing the PR

Please rebase the changes on top of 07944ad as it fixes some possible pre-commit failures.

@harti2006 harti2006 force-pushed the feature/drop-ktlint-java-limitation branch 2 times, most recently from b5b3b38 to 52563e6 Compare December 5, 2022 06:22

golang_version: [1.19.3]
java_version: ['15', '16', '17']
java_version: ['15', '16', '17', '18', '19']
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since I removed the test annotations, I'd also like to show that the tool works with even more recent Java versions than 17

Comment thread tests/pretty_format_kotlin_test.py
@macisamuele macisamuele enabled auto-merge December 5, 2022 08:23
@whiskeysierra
Copy link
Copy Markdown

whiskeysierra commented Dec 5, 2022

Test fails with:

Caused by: java.lang.reflect.InaccessibleObjectException:
Unable to make field private transient java.lang.Object
java.lang.Throwable.backtrace accessible:
module java.base does not "opens java.lang" to unnamed module @28c71909

Sounds related to:

@whiskeysierra
Copy link
Copy Markdown

It's probably safe to add --add-opens ... to the java process arguments.

auto-merge was automatically disabled December 5, 2022 12:27

Head branch was pushed to by a user without write access

@harti2006 harti2006 force-pushed the feature/drop-ktlint-java-limitation branch from 52563e6 to 2afa43c Compare December 5, 2022 12:27
@harti2006
Copy link
Copy Markdown
Contributor Author

Tried it like this:

opens_java_lang = ["--add-opens", "java.base/java.lang=ALL-UNNAMED"]
# ktlint does not return exit-code!=0 if we're formatting them.
# To workaround this limitation we do run ktlint in check mode only,
# which provides the expected exit status and we run it again in format
# mode if autofix flag is enabled
check_status, check_output = run_command(
"java", "-jar", ktlint_jar, "--verbose", "--relative", *opens_java_lang, "--", *_fix_paths(args.filenames)
)

@macisamuele macisamuele enabled auto-merge December 5, 2022 13:21
auto-merge was automatically disabled December 5, 2022 14:28

Head branch was pushed to by a user without write access

@harti2006 harti2006 force-pushed the feature/drop-ktlint-java-limitation branch from 2afa43c to cf95f11 Compare December 5, 2022 14:28
@harti2006
Copy link
Copy Markdown
Contributor Author

The first attempt did not work. The args were parsed by the Ktlint application, rather than the "java" command itself. Trying to move them earlier

@macisamuele macisamuele enabled auto-merge December 5, 2022 14:35
@macisamuele
Copy link
Copy Markdown
Owner

Thanks for the effort on making new JDK available to the tool.

If tests are green this will be merged and within EOD I will release the new version of the pre-commit hooks.

@macisamuele macisamuele merged commit 7e7c0fa into macisamuele:master Dec 5, 2022
@harti2006 harti2006 deleted the feature/drop-ktlint-java-limitation branch December 5, 2022 15:12
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.

Unblock ktlint with JDK 17

3 participants