// 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;
/*
 * Copyright 2020-2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.nativeimage.features.cloudfunctions;



/**
 * A feature which registers reflective usages of the Cloud Functions library.
 */
@AutomaticFeature
final class CloudFunctionsFeature implements Feature {

  private static final String FUNCTION_INVOKER_CLASS =
      "com.google.cloud.functions.invoker.runner.Invoker";

  private static final List<String> FUNCTIONS_CLASSES =
      Arrays.asList(
          "com.google.cloud.functions.HttpFunction",
          "com.google.cloud.functions.RawBackgroundFunction",
          "com.google.cloud.functions.BackgroundFunction");

  @Override
  public void beforeAnalysis(BeforeAnalysisAccess access) {
    Class<?> invokerClass = access.findClassByName(FUNCTION_INVOKER_CLASS);
    if (invokerClass != null) {
      // JCommander libraries
// 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;

/*
 * Copyright 2020-2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.nativeimage.features.cloudfunctions;



/**
 * A feature which registers reflective usages of the Cloud Functions library.
 */
@AutomaticFeature
final class CloudFunctionsFeature implements Feature {

  private static final String FUNCTION_INVOKER_CLASS =
      "com.google.cloud.functions.invoker.runner.Invoker";

  private static final List<String> FUNCTIONS_CLASSES =
      Arrays.asList(
          "com.google.cloud.functions.HttpFunction",
          "com.google.cloud.functions.RawBackgroundFunction",
          "com.google.cloud.functions.BackgroundFunction");

  @Override
  public void beforeAnalysis(BeforeAnalysisAccess access) {
    Class<?> invokerClass = access.findClassByName(FUNCTION_INVOKER_CLASS);
    if (invokerClass != null) {
      // JCommander libraries
      registerClassForReflection(