google / clusterfuzz

Scalable fuzzing infrastructure.
https://google.github.io/clusterfuzz
Apache License 2.0
5.29k stars 554 forks source link

Updating jdk from 15 to 21 #4243

Closed vitorguidi closed 1 month ago

vitorguidi commented 1 month ago

We are getting a lot of these exceptions:

...
Exception in thread "main" java.lang.UnsupportedClassVersionError: HeaderTokenizerFuzzer has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 59.0
...

This attempts to fix issue 12496 Evidence that this does install java. Simple standalone dockerfile

from ubuntu:16.04 as xenial

RUN apt update && apt install -y wget

ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
ENV JVM_LD_LIBRARY_PATH=$JAVA_HOME/lib/server
ENV PATH=$PATH:$JAVA_HOME/bin
RUN wget https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-21.0.2_linux-x64_bin.tar.gz && \
    cd /tmp && \
    mkdir -p $JAVA_HOME && \
    tar -xzv --strip-components=1 -f openjdk-21.0.2_linux-x64_bin.tar.gz --directory $JAVA_HOME && \
    rm -rf openjdk*.tar.gz $JAVA_HOME/jmods $JAVA_HOME/lib/src.zip
docker build .
...
Successfully built 42d640a26255
vitorguidi@vitorguidi0:~/Desktop/javatest$ docker run -it 42d640a26255 /bin/bash
root@9cc12e52f918:/# java --version
openjdk 21.0.2 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-58)
OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)
root@9cc12e52f918:/# javac --version
javac 21.0.2
oliverchang commented 1 month ago

let's revisit this later -- upgrading to 17 (https://github.com/google/clusterfuzz/pull/4244) is likely a lot safer because it's a smaller bump and it matches OSS-Fuzz.