#!/usr/bin/env bash # Reads the resolution order out of Spring's own bytecode instead of trusting the reference # documentation's prose: which determine* helpers DefaultListableBeanFactory calls, in which order. set -euo pipefail cd "$(dirname "$0")/.." mkdir -p output target/bytecode JAR=$(find ~/.m2/repository/org/springframework/spring-beans -name 'spring-beans-*.jar' ! -name '*sources*' | sort | tail -1) unzip -o -q "$JAR" 'org/springframework/beans/factory/support/DefaultListableBeanFactory*' -d target/bytecode { echo "# DefaultListableBeanFactory.determineAutowireCandidate, read with javap" echo "# jar: $(basename "$JAR")" echo javap -p -c -cp target/bytecode org.springframework.beans.factory.support.DefaultListableBeanFactory 2>&1 \ | grep -v 'Picked up' \ | awk '/protected java.lang.String determineAutowireCandidate\(/{f=1} f{print} /^$/{if(f) exit}' \ | grep -E 'determineAutowireCandidate|invoke|instanceof' | sed 's/^ *[0-9]*: //' } > output/23-determine-autowire-candidate-bytecode.txt cat output/23-determine-autowire-candidate-bytecode.txt # --- the early-reference caches behind circular-reference support JAR2=$(find ~/.m2/repository/org/springframework/spring-beans -name 'spring-beans-*.jar' ! -name '*sources*' | sort | tail -1) unzip -o -q "$JAR2" 'org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.class' -d target/bytecode { echo "# DefaultSingletonBeanRegistry: the fields that hold early references, read with javap" echo "# jar: $(basename "$JAR2")" echo javap -p -cp target/bytecode org.springframework.beans.factory.support.DefaultSingletonBeanRegistry 2>&1 \ | grep -v 'Picked up' | grep -E ' (singletonObjects|earlySingletonObjects|singletonFactories|singletonsCurrentlyInCreation|allowCircularReferences)[;]?' || true echo echo "# DefaultListableBeanFactory / AbstractAutowireCapableBeanFactory: the allow-circular-references switch" unzip -o -q "$JAR2" 'org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.class' -d target/bytecode javap -p -cp target/bytecode org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory 2>&1 \ | grep -v 'Picked up' | grep -i 'allowCircularReferences' || true } > output/24-early-reference-caches.txt cat output/24-early-reference-caches.txt # --- is the old Spring-specific @Nullable deprecated in 7.0.9? JAR3=$(find ~/.m2/repository/org/springframework/spring-core -name 'spring-core-7*.jar' ! -name '*sources*' | sort | tail -1) unzip -o -q "$JAR3" 'org/springframework/lang/Nullable.class' -d target/bytecode { echo "# org.springframework.lang.Nullable in $(basename "$JAR3"), read with javap -v" echo javap -v -cp target/bytecode org.springframework.lang.Nullable 2>&1 | grep -v 'Picked up' | grep -E 'Deprecated|RuntimeVisibleAnnotations|Ljava/lang/Deprecated|forRemoval|since' || true } > output/25-spring-nullable-deprecation.txt cat output/25-spring-nullable-deprecation.txt # --- does the Boot parent compile with -parameters? PARENT=$(find ~/.m2/repository/org/springframework/boot/spring-boot-starter-parent -name '*.pom' | sort | tail -1) { echo "# $(basename "$PARENT"): the compiler flag that parameter-name matching depends on" echo grep -n -B2 -A2 '' "$PARENT" || echo "(no element found)" } > output/26-boot-parent-parameters-flag.txt cat output/26-boot-parent-parameters-flag.txt