package com.aiteacher.config; import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; /** * GraalVM native-image runtime hints for third-party libraries that use reflection * or classpath resource scanning not covered by Spring Boot's AOT processor. * * Registered via @ImportRuntimeHints on AiTeacherApplication. */ public class NativeHintsConfig implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) { // PDFBox — font and encoding resources loaded via classpath scanning at runtime hints.resources().registerPattern("org/apache/pdfbox/resources/*"); hints.resources().registerPattern("org/apache/pdfbox/resources/afm/*"); hints.resources().registerPattern("org/apache/pdfbox/resources/cmap/*"); hints.resources().registerPattern("org/apache/pdfbox/resources/glyphlist/*"); hints.resources().registerPattern("org/apache/pdfbox/resources/icc/*"); hints.resources().registerPattern("org/apache/pdfbox/resources/ttf/*"); hints.resources().registerPattern("org/apache/pdfbox/resources/version.properties"); // PDFBox — font encoding classes instantiated via reflection hints.reflection().registerType( org.apache.pdfbox.pdmodel.font.encoding.GlyphList.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS ); hints.reflection().registerType( org.apache.pdfbox.pdmodel.font.encoding.WinAnsiEncoding.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS ); hints.reflection().registerType( org.apache.pdfbox.pdmodel.font.encoding.MacRomanEncoding.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS ); hints.reflection().registerType( org.apache.pdfbox.pdmodel.font.encoding.MacExpertEncoding.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS ); hints.reflection().registerType( org.apache.pdfbox.pdmodel.font.encoding.StandardEncoding.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS ); // JPA / Hibernate — array types used in entity mappings hints.reflection().registerType(java.util.UUID[].class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS); // JBoss Logging — message logger implementations generated by annotation processor. // JBoss Logging uses reflection to look up the generated *_$logger class by name. registerJBossLogger(hints, "org.hibernate.jpa.internal.JpaLogger_$logger"); registerJBossLogger(hints, "org.hibernate.internal.CoreMessageLogger_$logger"); registerJBossLogger(hints, "org.hibernate.internal.EntityManagerMessageLogger_$logger"); // AWS SDK v2 — HTTP client and SdkPojo serialization hints.resources().registerPattern("software/amazon/awssdk/global/handlers/execution.interceptors"); hints.resources().registerPattern("software/amazon/awssdk/services/s3/execution.interceptors"); hints.resources().registerPattern("codegen-resources/s3/*"); hints.reflection().registerType( software.amazon.awssdk.services.s3.S3Client.class, MemberCategory.INVOKE_PUBLIC_METHODS ); } private void registerJBossLogger(RuntimeHints hints, String className) { hints.reflection().registerType( TypeReference.of(className), MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS ); } }