Skip to content

Commit 1187c03

Browse files
committed
checkstyle: fix broken build
The Maven build configuration of the Checkstyle project requires Java 21 or a higher version. However, the default OSS-Fuzz base image provides Java 17, resulting in a mismatch error regarding the Java version.
1 parent 583430e commit 1187c03

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

projects/checkstyle/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ RUN curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-
1818
-o maven.zip && \
1919
unzip maven.zip -d $SRC/maven && \
2020
rm maven.zip
21-
ENV MVN $SRC/maven/apache-maven-3.6.3/bin/mvn
21+
ENV MVN=$SRC/maven/apache-maven-3.6.3/bin/mvn
22+
RUN apt-get update && apt-get install -y openjdk-21-jdk \
23+
&& update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java \
24+
&& update-alternatives --set javac /usr/lib/jvm/java-21-openjdk-amd64/bin/javac
25+
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
26+
ENV PATH="$JAVA_HOME/bin:$PATH"
2227
RUN git clone --depth 1 https://github.com/checkstyle/checkstyle checkstyle
2328
COPY *.sh *Fuzzer.java $SRC/
2429
WORKDIR $SRC/checkstyle

projects/checkstyle/build.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
##########################################################################
1717
export TARGET_PACKAGE_PREFIX="com.puppycrawl.tools.checkstyle."
1818

19-
MAVEN_ARGS="-Dmaven.test.skip=true -Djavac.src.version=15 -Djavac.target.version=15 --update-snapshots"
19+
MAVEN_ARGS="-Dmaven.test.skip=true -Djavac.src.version=21 -Djavac.target.version=21 --update-snapshots"
2020
$MVN clean package $MAVEN_ARGS
2121

2222
BUILD_CLASSPATH=
@@ -50,7 +50,8 @@ do
5050
cp $SRC/$fuzzer_basename.class $OUT/
5151

5252
# Create an execution wrapper that executes Jazzer with the correct arguments.
53-
echo "#!/bin/bash
53+
cat << EOF > $OUT/$fuzzer_basename
54+
#!/bin/bash
5455
5556
# LLVMFuzzerTestOneInput for fuzzer detection.
5657
this_dir=\$(dirname "\$0")
@@ -61,12 +62,15 @@ do
6162
mem_settings='-Xmx2048m:-Xss1024k'
6263
fi
6364
64-
LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \
65+
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
66+
export PATH="\$JAVA_HOME/bin:\$PATH"
67+
LD_LIBRARY_PATH="$JVM_LD_LIBRARY_PATH":\$this_dir \
6568
\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \
66-
--cp=$RUNTIME_CLASSPATH \
67-
--target_class=$fuzzer_basename \
68-
--jvm_args=\"\$mem_settings\" \
69-
\$@" > $OUT/$fuzzer_basename
69+
--cp="$RUNTIME_CLASSPATH" \
70+
--target_class="$fuzzer_basename" \
71+
--jvm_args="\$mem_settings" \
72+
"\$@"
73+
EOF
7074

7175
chmod u+x $OUT/$fuzzer_basename
7276
done

0 commit comments

Comments
 (0)