Hi Andor,

To be completely honest this whole thing is a bit confusing for me. :D

I'm adding here the link to the original comment in the PR which started
all this:
https://github.com/apache/zookeeper/pull/2329#issuecomment-4014998831

I now checked JLine 3.30.4 jar and most of the classes inside has Major
Version: 52 so they should be compatible with Java 8 but there are some
classes which has Major Version 66 means those classes were compiled for
Java 22.

$ python3 -c "
import zipfile, struct

with zipfile.ZipFile('zookeeper-server/target/lib/jline-3.30.14.jar') as z:
    for name in z.namelist():
        if name.endswith('.class'):
            data = z.read(name)[:8]
            if len(data) >= 8:
                _, _, major = struct.unpack('>IHH', data)
                print(f'{name} -> Major Version: {major}')
" > report.txt

$ grep -v 52 report.txt
org/jline/terminal/impl/ffm/CLibrary$termios.class -> Major Version: 66
org/jline/terminal/impl/ffm/CLibrary$winsize.class -> Major Version: 66
org/jline/terminal/impl/ffm/CLibrary.class -> Major Version: 66
org/jline/terminal/impl/ffm/FfmNativePty$1.class -> Major Version: 66
org/jline/terminal/impl/ffm/FfmNativePty.class -> Major Version: 66
org/jline/terminal/impl/ffm/FfmTerminalProvider.class -> Major Version: 66
org/jline/terminal/impl/ffm/Kernel32$CHAR_INFO.class -> Major Version: 66
org/jline/terminal/impl/ffm/Kernel32$CONSOLE_SCREEN_BUFFER_INFO.class ->
Major Version: 66
org/jline/terminal/impl/ffm/Kernel32$COORD.class -> Major Version: 66
org/jline/terminal/impl/ffm/Kernel32$FOCUS_EVENT_RECORD.class -> Major
Version: 66
org/jline/terminal/impl/ffm/Kernel32$INPUT_RECORD.class -> Major Version: 66
org/jline/terminal/impl/ffm/Kernel32$KEY_EVENT_RECORD.class -> Major
Version: 66
org/jline/terminal/impl/ffm/Kernel32$MENU_EVENT_RECORD.class -> Major
Version: 66
org/jline/terminal/impl/ffm/Kernel32$MOUSE_EVENT_RECORD.class -> Major
Version: 66
org/jline/terminal/impl/ffm/Kernel32$SMALL_RECT.class -> Major Version: 66
org/jline/terminal/impl/ffm/Kernel32$WINDOW_BUFFER_SIZE_RECORD.class ->
Major Version: 66
org/jline/terminal/impl/ffm/Kernel32.class -> Major Version: 66
org/jline/terminal/impl/ffm/NativeWinConsoleWriter.class -> Major Version:
66
org/jline/terminal/impl/ffm/NativeWinSysTerminal$1.class -> Major Version:
66
org/jline/terminal/impl/ffm/NativeWinSysTerminal.class -> Major Version: 66
org/jline/terminal/impl/ffm/WindowsAnsiWriter.class -> Major Version: 66

I checked out branch-3.8 and branch-3.9 which had this JLine version, used
Java 8, started ZooKeeper server, checked the logs and connected with
zkCli, created some znodes, listed them - it all worked fine.
So I guess we do not use / load those JLine classes which are not
compatible with Java 8.

In the official JLine documentation only the 4.x version mentions this
classifier:
https://jline.org/versions/4.0/docs/intro#java-11-21-compatibility-jdk11-classifier

When I added the jdk8 classifier:

      <dependency>
        <groupId>org.jline</groupId>
        <artifactId>jline</artifactId>
        <version>${jline.version}</version>
        <classifier>jdk8</classifier>
      </dependency>

then Maven downloaded a different jar: jline-3.30.14-jdk8.jar

Checking it with the same commands this class only contains classes which
are Java 8 compatible.
Used Java 8, started ZooKeeper server, checked the logs and connected with
zkCli, created some znodes, listed them - it all worked fine as well.

I created PR-s for this for both branches:
- https://github.com/apache/zookeeper/pull/2450
- https://github.com/apache/zookeeper/pull/2451

Can you please check?

Many thanks,
Dávid

Andor Molnár <[email protected]> ezt írta (időpont: 2026. szept. 1., K,
17:18):

> Hi David,
>
> From GitHub:
>
> Hi @anmolnar,
> I'm not sure if you plan to backport this to older branches if yes, please
> be aware of this:
>
> Note: For older branches which support Java 8 max, we should use the jdk8
> classifier of jline. The newer versions have features that only work with
> java 22+ and this trips up the
> org.codehaus.mojo.extraenforcer.dependencies.EnforceBytecodeVersion maven
> plugin with zookeeper.
>
> See: #2329 (comment)
>
> I checked Maven, but I didn’t find the classifier that you guys are
> talking about. I made the backports anyway on branch-3.8 and branch-3.9
> branches, let’s see how builds are going.
>
>
> https://ci-hadoop.apache.org/view/ZooKeeper/job/zookeeper-multi-branch-build/
>
> Regards,
> Andor
>
>
>
>

Reply via email to