// Path: native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java
// public static void registerClassForReflection(FeatureAccess access, String name) {
//   Class<?> clazz = access.findClassByName(name);
//   if (clazz != null) {
//     RuntimeReflection.register(clazz);
//     RuntimeReflection.register(clazz.getDeclaredConstructors());
//     RuntimeReflection.register(clazz.getDeclaredFields());
//     RuntimeReflection.register(clazz.getDeclaredMethods());
//   } else {
//     LOGGER.warning(
//         "Failed to find " + name + " on the classpath for reflection.");
//   }
// }
// 
// Path: native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java
// public static void registerClassHierarchyForReflection(FeatureAccess access, String className) {
//   Class<?> clazz = access.findClassByName(className);
//   if (clazz != null) {
//     registerClassForReflection(access, className);
//     for (Class<?> nestedClass : clazz.getDeclaredClasses()) {
//       if (!Modifier.isPrivate(nestedClass.getModifiers())) {
//         registerClassHierarchyForReflection(access, nestedClass.getName());
//       }
//     }
//   } else {
//     LOGGER.warning(
//         "Failed to find " + className + " on the classpath for reflection.");
//   }
// }


import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassForReflection;
import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassHierarchyForReflection;
import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.configure.ResourcesRegistry;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.function.Consumer;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeReflection;
      resourcesRegistry.addResources(
          "\\QMETA-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder\\E");
      resourcesRegistry.addResources("\\Qorg/eclipse/jetty/http/encoding.properties\\E");
      resourcesRegistry.addResources("\\Qorg/eclipse/jetty/http/mime.properties\\E");
      resourcesRegistry.addResources("\\Qorg/eclipse/jetty/version/build.properties\\E");
      resourcesRegistry.addResourceBundles("javax.servlet.LocalStrings");
      resourcesRegistry.addResourceBundles("javax.servlet.http.LocalStrings");

      // Register user-implemented Function classes
      List<Class<?>> functionClasses =
          FUNCTIONS_CLASSES.stream()
              .map(name -> access.findClassByName(name))
              .collect(Collectors.toList());

      scanJarClasspath(access, clazz -> {
        boolean isFunctionSubtype = functionClasses.stream()
            .anyMatch(function ->
                function.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers()));

        if (isFunctionSubtype) {
          RuntimeReflection.register(clazz);
          RuntimeReflection.register(clazz.getDeclaredConstructors());
          RuntimeReflection.register(clazz.getDeclaredMethods());

          // This part is to register the parameterized class of BackgroundFunctions
          // for reflection; i.e. register type T in BackgroundFunction<T>
          for (Type type : clazz.getGenericInterfaces()) {
            if (type instanceof ParameterizedType) {
              ParameterizedType paramType = (ParameterizedType) type;
              for (Type argument : paramType.getActualTypeArguments()) {
// Path: native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java
// public static void registerClassForReflection(FeatureAccess access, String name) {
//   Class<?> clazz = access.findClassByName(name);
//   if (clazz != null) {
//     RuntimeReflection.register(clazz);
//     RuntimeReflection.register(clazz.getDeclaredConstructors());
//     RuntimeReflection.register(clazz.getDeclaredFields());
//     RuntimeReflection.register(clazz.getDeclaredMethods());
//   } else {
//     LOGGER.warning(
//         "Failed to find " + name + " on the classpath for reflection.");
//   }
// }
// 
// Path: native-image-support/src/main/java/com/google/cloud/nativeimage/features/NativeImageUtils.java
// public static void registerClassHierarchyForReflection(FeatureAccess access, String className) {
//   Class<?> clazz = access.findClassByName(className);
//   if (clazz != null) {
//     registerClassForReflection(access, className);
//     for (Class<?> nestedClass : clazz.getDeclaredClasses()) {
//       if (!Modifier.isPrivate(nestedClass.getModifiers())) {
//         registerClassHierarchyForReflection(access, nestedClass.getName());
//       }
//     }
//   } else {
//     LOGGER.warning(
//         "Failed to find " + className + " on the classpath for reflection.");
//   }
// }


// Path: native-image-support/src/main/java/com/google/cloud/nativeimage/features/cloudfunctions/CloudFunctionsFeature.java
import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassForReflection;
import static com.google.cloud.nativeimage.features.NativeImageUtils.registerClassHierarchyForReflection;
import com.oracle.svm.core.annotate.AutomaticFeature;
import com.oracle.svm.core.configure.ResourcesRegistry;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.function.Consumer;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeReflection;

      resourcesRegistry.addResources(
          "\\QMETA-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder\\E");
      resourcesRegistry.addResources("\\Qorg/eclipse/jetty/http/encoding.properties\\E");
      resourcesRegistry.addResources("\\Qorg/eclipse/jetty/http/mime.properties\\E");
      resourcesRegistry.addResources("\\Qorg/eclipse/jetty/version/build.properties\\E");
      resourcesRegistry.addResourceBundles("javax.servlet.LocalStrings");
      resourcesRegistry.addResourceBundles("javax.servlet.http.LocalStrings");

      // Register user-implemented Function classes
      List<Class<?>> functionClasses =
          FUNCTIONS_CLASSES.stream()
              .map(name -> access.findClassByName(name))
              .collect(Collectors.toList());

      scanJarClasspath(access, clazz -> {
        boolean isFunctionSubtype = functionClasses.stream()
            .anyMatch(function ->
                function.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers()));

        if (isFunctionSubtype) {
          RuntimeReflection.register(clazz);
          RuntimeReflection.register(clazz.getDeclaredConstructors());
          RuntimeReflection.register(clazz.getDeclaredMethods());

          // This part is to register the parameterized class of BackgroundFunctions
          // for reflection; i.e. register type T in BackgroundFunction<T>
          for (Type type : clazz.getGenericInterfaces()) {
            if (type instanceof ParameterizedType) {
              ParameterizedType paramType = (ParameterizedType) type;
              for (Type argument : paramType.getActualTypeArguments()) {
                registerClassHierarchyForReflection(access, argument.getTypeName());