#!/usr/bin/env bash # Compiles each file in src/broken/ against Hibernate 7.4.5.Final and against 8.0.0.Beta3 and keeps the compiler's own words. # Then compiles BinaryProbe against 7 and runs it on 8 (and the reverse) to show linkage errors. set -uo pipefail cd "$(dirname "$0")/.." W=$(mktemp -d) cp_for() { mvn -B -q dependency:build-classpath -Dmdep.outputFile="$W/cp-$1.txt" -Dhibernate.version=$2 -Dpersistence.version=$3 >/dev/null 2>&1; cat "$W/cp-$1.txt"; } CP7=$(cp_for h7 7.4.5.Final 3.2.0); CP8=$(cp_for h8 8.0.0.Beta3 4.0.0-M7) { echo "# compile-errors (javac --release 25 -Xlint:removal -Xlint:deprecation; files in src/broken/)" for f in UsesTransformers UsesReplicate StatelessInsertReturnsId QueryVariable TypedQueryVariable; do for v in h7 h8; do CP=$([ $v = h7 ] && echo "$CP7" || echo "$CP8") mkdir -p "$W/out-$v" echo "--- $f on $v" javac --release 25 -Xlint:removal -Xlint:deprecation -proc:none -d "$W/out-$v" -sourcepath src/main/java -cp "$CP" src/broken/$f.java 2>&1 \ | grep -v JAVA_TOOL | sed 's#^src/broken/##' | grep -v -E '^\s*\^?$' || true done done } > output/04-compile-errors.txt { echo "# binary-compatibility (BinaryProbe compiled against one Hibernate, run on the other)" for pair in "h7 h8" "h8 h7"; do set -- $pair CPC=$([ $1 = h7 ] && echo "$CP7" || echo "$CP8"); CPR=$([ $2 = h7 ] && echo "$CP7" || echo "$CP8") rm -rf "$W/bin-$1"; mkdir -p "$W/bin-$1" javac --release 25 -proc:none -d "$W/bin-$1" -sourcepath src/main/java -cp "$CPC" src/broken/BinaryProbe.java 2>&1 | grep -v JAVA_TOOL echo "--- compiled on $1, run on $2" java -cp "$W/bin-$1:$CPR" BinaryProbe 2>&1 | grep -E '^(createQuery ran|Exception in thread|java\.lang\.)' | cut -c1-230 | head -3 done } > output/05-binary-compatibility.txt