You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/11/03 15:01:55 UTC
[GitHub] [kafka] olafurpg commented on pull request #9548: Disable inlining of Scala library methods.
olafurpg commented on pull request #9548:
URL: https://github.com/apache/kafka/pull/9548#issuecomment-721182321
Even if users can't directly reference APIs of the core Kafka jar, the bytecode of the core jar is still evaluated at runtime. With the inliner enabled, the core Kafka jar directly references private anonymous classes from scala-library:2.12.11 that are no longer present in scala-library:2.12.12. For example, assuming you have `cs` (https://get-coursier.io/) installed, observe that `scala/math/Ordering$$anon$7` is referenced here below
```
❯ javap -cp $(cs fetch org.apache.kafka:kafka_2.12:2.5.1 -p) -v kafka.api.ApiVersion$ | grep Ordering\$\$anon
#24 = Utf8 scala/math/Ordering$$anon$7
#25 = Class #24 // scala/math/Ordering$$anon$7
#84 = Methodref #25.#83 // scala/math/Ordering$$anon$7."<init>":(Lscala/math/Ordering;Lscala/Function1;)V
21: new #25 // class scala/math/Ordering$$anon$7
27: invokespecial #84 // Method scala/math/Ordering$$anon$7."<init>":(Lscala/math/Ordering;Lscala/Function1;)V
public final #25; //class scala/math/Ordering$$anon$7
```
The scala-library:2.12.11 jar defines this anonymous class but it's missing from scala-library:2.12.12
```
❯ jar tf $(cs fetch org.scala-lang:scala-library:2.12.11 -p) | grep Ordering\$\$anon
scala/math/Ordering$$anon$1.class
scala/math/Ordering$$anon$10.class
scala/math/Ordering$$anon$11.class
scala/math/Ordering$$anon$12.class
scala/math/Ordering$$anon$13.class
scala/math/Ordering$$anon$14.class
scala/math/Ordering$$anon$15.class
scala/math/Ordering$$anon$16.class
scala/math/Ordering$$anon$17.class
scala/math/Ordering$$anon$18.class
scala/math/Ordering$$anon$19.class
scala/math/Ordering$$anon$2.class
scala/math/Ordering$$anon$6.class
scala/math/Ordering$$anon$7.class
scala/math/Ordering$DoubleOrdering$$anon$9.class
scala/math/Ordering$FloatOrdering$$anon$8.class
scala/math/PartialOrdering$$anon$1.class
❯ jar tf $(cs fetch org.scala-lang:scala-library:2.12.12 -p) | grep Ordering\$\$anon
scala/math/Ordering$$anon$1.class
scala/math/Ordering$$anon$4.class
scala/math/Ordering$$anon$5.class
scala/math/Ordering$$anon$6.class
scala/math/PartialOrdering$$anon$1.class
```
The related upstream commit appears to be https://github.com/scala/scala/commit/44318c8959b3ce48a44d3c0692e87fa7dfbb8930#diff-3b590b82493a8dbfc177f6113ee07ac4772d666d99fe808c6f6da01227ad1c6d.
My understanding is that the inliner flags are only safe to enable for applications "at the end of the world", not libraries.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org