RuntimeResolver class abstract interface

An interface that portrays how any code is handled in JetLeaf's reflection system.

This abstraction allows for different underlying mechanisms to resolve and execute code, such as:

  • Using dart:mirrors in JIT environments (e.g., during development)
  • Using code generation or precompiled metadata for AOT environments (e.g., production builds)

The interface provides a unified way to:

  • Create class instances
  • Invoke methods
  • Access and mutate fields

This allows JetLeaf to support reflection even when dart:mirrors is not available.

Example

class MirrorRuntimeResolver extends RuntimeResolver {
  @override
  T newInstance<T>(String name, [List<Object?> args = const [], Map<String, Object?> namedArgs = const {}]) {
    // Implementation using dart:mirrors
  }

  @override
  T? invokeMethod<T>(T instance, String method, {List<Object?> args = const [], Map<String, Object?> namedArgs = const {}}) {
    // Implementation using dart:mirrors
  }

  @override
  Object? getValue<T>(T instance, String name) {
    // Implementation using dart:mirrors
  }

  @override
  void setValue<T>(T instance, String name, Object? value) {
    // Implementation using dart:mirrors
  }
}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getValue<T>(T instance, String name) Object?
Gets the value of an instance field name on the given instance of type T.
invokeMethod<T>(T instance, String method, {List<Object?> args = const [], Map<String, Object?> namedArgs = const {}}) Object?
Invokes a method method on the given instance of type T.
newInstance<T>(String name, [Type? returnType, List<Object?> args = const [], Map<String, Object?> namedArgs = const {}]) → T
Creates a new instance of type T using the specified constructor name.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setValue<T>(T instance, String name, Object? value) → void
Sets the value of an instance field name on the given instance of type T.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited