Class KotlinReflectionUtils

java.lang.Object
io.fluxzero.common.reflection.KotlinReflectionUtils

public class KotlinReflectionUtils extends Object
Provides utilities for bridging Java reflection with Kotlin reflection.

This class enables Fluxzero internals to interact with Kotlin symbols at runtime, such as retrieving KFunction or KParameter instances from Java Methods, Constructors, and Parameters.

It is used primarily to support nullability introspection and Kotlin-specific constructs in reflection-based logic.

Note: This utility is internal and should not be considered part of the public API.

  • Constructor Details

    • KotlinReflectionUtils

      public KotlinReflectionUtils()
  • Method Details

    • asKotlinParameter

      public static kotlin.reflect.KParameter asKotlinParameter(Parameter parameter)
      Maps a Java parameter to the corresponding Kotlin value parameter. Returns null if no value parameter matches, and throws IllegalStateException if the executable has no Kotlin function.
    • getKotlinParameterName

      public static String getKotlinParameterName(Parameter parameter)
      Returns the Kotlin source parameter name for a Java reflection parameter.
      Parameters:
      parameter - the Java reflection parameter to resolve
      Returns:
      the Kotlin parameter name, or null when no matching Kotlin value parameter exists
    • getPrimaryConstructor

      public static Constructor<?> getPrimaryConstructor(Class<?> type)
      Returns the Java reflection constructor that corresponds to a Kotlin class' primary constructor.
      Parameters:
      type - the Kotlin type to inspect
      Returns:
      the Java constructor for the Kotlin primary constructor, or null when none is available
    • asKotlinFunction

      public static kotlin.reflect.KFunction<?> asKotlinFunction(Executable executable)
      Maps a Java method or constructor to its Kotlin reflection function, or returns null if no mapping exists.
    • convertIfKotlinClass

      public static Class<?> convertIfKotlinClass(Object classObject)
      Returns the Java class represented by a Kotlin class literal, or null for other inputs.