Skip to content

KAFKA-12357: Do not inline methods from the scala package by default #10174

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

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

ijuma
Copy link
Member

@ijuma ijuma commented Feb 22, 2021

As mentioned in #9548, users currently use the kafka jar (core module)
for integration testing and the current inlining behavior causes
problems when the user's classpath contains a different Scala version
than the one that was used for compilation (e.g. 2.13.4 versus 2.13.3).

An example error:

java.lang.NoClassDefFoundError: scala/math/Ordering$$anon$7

We now disable inlining of the scala package by default, but make it
easy to enable it for those who so desire (a good option if you can
ensure the scala library version matches the one used for compilation).
While at it, we make it possible to disable scala compiler optimizations
(none) or to use only method local optimizations (method). This can
be useful if optimizing for compilation time during development.

Verified behavior by running gradlew with --debug and checking the
output after [zinc] The Scala compiler is invoked with:

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

As mentioned in apache#9548, users currently use the kafka jar (`core` module)
for integration testing and the current inlining behavior causes
problems when the user's classpath contains a different Scala version
than the one that was used for compilation.

An example error:

`java.lang.NoClassDefFoundError: scala/math/Ordering$$anon$7`

We disable inlining of the `scala` package by default, but make it easy
to enable it for those who so desire (a good option if you can ensure
the scala library version matches the one used for compilation). While
at it, we make it possible to disable scala compiler optimizations
(`none`) or to use only method local optimizations (`method`). This can
be useful if optimizing for compilation time during development.

Verified behavior by running gradlew with `--debug` and checking the
output after `[zinc] The Scala compiler is invoked with:`
@ijuma ijuma requested a review from chia7712 February 22, 2021 14:33
@ijuma
Copy link
Member Author

ijuma commented Feb 22, 2021

@chia7712 I was thinking to include this in 2.8 since it's low risk and it fixes a regression when it comes to writing integration tests with Kafka.

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

overall +1.

one question:
As we don't guarantee to keep core compatibility, is it worthwhile to exclude scala inlining by default?

@ijuma
Copy link
Member Author

ijuma commented Feb 23, 2021

@chia7712 For better or worse, libraries like https://github.com/embeddedkafka/embedded-kafka are often used. And there isn't a great alternative. Getting an exception when there's a mismatch in the patch version of scala-library is pretty surprising. It seems better to aim for ease of use until there's a better way of handling this. Do you agree?

@chia7712
Copy link
Member

It seems better to aim for ease of use until there's a better way of handling this

make sense. be a friendly libraries :)

@ijuma ijuma merged commit b5265e9 into apache:trunk Feb 23, 2021
@ijuma
Copy link
Member Author

ijuma commented Feb 23, 2021

Merged to trunk and 2.8 branches.

ijuma added a commit that referenced this pull request Feb 23, 2021
…10174)

As mentioned in #9548, users currently use the kafka jar (`core` module)
for integration testing and the current inlining behavior causes
problems when the user's classpath contains a different Scala version
than the one that was used for compilation (e.g. 2.13.4 versus 2.13.3).

An example error:

`java.lang.NoClassDefFoundError: scala/math/Ordering$$anon$7`

We now disable inlining of the `scala` package by default, but make it
easy to enable it for those who so desire (a good option if you can
ensure the scala library version matches the one used for compilation).
While at it, we make it possible to disable scala compiler optimizations
(`none`) or to use only method local optimizations (`method`). This can
be useful if optimizing for compilation time during development.

Verified behavior by running gradlew with `--debug` and checking the
output after `[zinc] The Scala compiler is invoked with:`

Reviewers: Chia-Ping Tsai <[email protected]>
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