package io.quarkus.runtime.graal;

import java.io.ObjectStreamClass;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(java.io.ObjectStreamClass.class)
@SuppressWarnings({ "unused" })
final class Target_java_io_ObjectStreamClass {

    @Substitute
    private static ObjectStreamClass lookup(Class<?> cl, boolean all) {
        throw new UnsupportedOperationException("Serialization of class definitions not supported");
    }

    private Target_java_io_ObjectStreamClass(final Class<?> cl) {
        throw new UnsupportedOperationException("Serialization of class definitions not supported");
    }

    private Target_java_io_ObjectStreamClass() {
        throw new UnsupportedOperationException("Not supported");
    }

}

@@ -61,16 +61,93 @@
 amClass;
+%0Aimport java.util.function.BooleanSupplier;%0A%0Aimport org.graalvm.home.Version;
 %0A%0Aimport
@@ -238,16 +238,102 @@
 Class;%0A%0A
+import io.quarkus.runtime.graal.Target_java_io_ObjectStreamClass.GraalVM20OrEarlier;%0A%0A
 @TargetC
@@ -337,16 +337,24 @@
 etClass(
+value = 
 java.io.
@@ -376,16 +376,53 @@
 ss.class
+, onlyWith = GraalVM20OrEarlier.class
 )%0A@Suppr
@@ -987,10 +987,209 @@
 %0A    %7D%0A%0A
+    static class GraalVM20OrEarlier implements BooleanSupplier %7B%0A%0A        @Override%0A        public boolean getAsBoolean() %7B%0A            return Version.getCurrent().compareTo(21) %3C 0;%0A        %7D%0A    %7D%0A
 %7D%0A

Enable Java serialization for GraalVM 21+