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

Compatibility with Solr 9.7 and Lucene 9.11 (fixes #457) #461

Merged
merged 3 commits into from
Sep 13, 2024
Merged

Conversation

jbaiter
Copy link
Member

@jbaiter jbaiter commented Sep 12, 2024

This one was fun. Lucene 9.11 changed the signature for the FieldHighlighter constructor to add an 8th parameter.

This meant that we had to call different constructors for different Solr/Lucene versions. Unfortunately, Java requires that the superclass constructor invocation must be the first top-level statement in a subclass constructor, i.e. dynamic selection is not possible in Java. At least until Java 23 when JEP 482 landed.

It is however no problem at the bytecode level, and so we supply a handcrafted (via jasm) FieldHighlighterAdapter.class that does the dynamic superclass constructor invocation.

It's shipped as a precompiled .class (along with the commented .jasm source code and build instructions) since I could not for the life of me figure out how to integrate jasm into the maven build.

Maven woes also required removing the JavaDoc plugin, since that was unable to pick up the .class from the resources directory. Since the plugin is not really used as a library anyway, I think this is an acceptable tradeoff.

Turns out there was actually no need for the tight coupling through inheritance. Getting rid of the subclassing frorm FieldHighlighter was very simple and now it works with all supported Lucene versions without weird hacks.

@jbaiter jbaiter requested review from bitzl and schmika September 12, 2024 07:28
@jbaiter jbaiter force-pushed the solr-9.7 branch 2 times, most recently from 7bd2d32 to ab3a2a0 Compare September 12, 2024 07:31
This one was fun. Lucene 9.11 changed the signature for the
`FieldHighlighter` constructor to add an 8th parameter.

This meant that we had to call different constructors for different
Solr/Lucene versions. Unfortunately, Java requires that the superclass
constructor invocation must be the first top-level statement in a
subclass constructor, i.e. dynamic selection is not possible in Java.

It is however no problem at the bytecode level, and so we supply a
handcrafted (via `jasm`) `FieldHighlighterAdapter.class` that does the
dynamic superclass constructor invocation.

It's shipped as a precompiled .class (along with the commented .jasm
source code and build instructions) since I could not for the life of
me figure out how to integrate jasm into the maven build.

Maven woes also required removing the JavaDoc plugin, since that was
unable to pick up the .class from the resources directory. Since the
plugin is not really used as a library anyway, I think this is an
acceptable tradeoff.
Revert the whole bytecode approach, just remove the tight coupling
introduced by the inheritance and it's compatible with all Lucene
versions without nasty hacks.
@jbaiter jbaiter merged commit 2eb0eee into main Sep 13, 2024
6 checks passed
@jbaiter jbaiter deleted the solr-9.7 branch September 13, 2024 08:03
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