std.reflect Package

Function Description

The reflect package provides reflection functionality, allowing the program to obtain the type information of various instances at runtime and perform various read, write, and call operations.

This package currently does not work on macOS.

Note:

  • For global information, the reflection functionality of Cangjie can access only public global variables and global functions.
  • For the current package, the reflection functionality of Cangjie can access all globally defined types. For externally imported packages or dynamically loaded modules, it can access only the publicly defined global types within them.
  • For member information, the reflection functionality of Cangjie can access only public members (instances/static member variables/attributes/functions) within the type. Members that are decorated with non-public modifiers or default modifiers are invisible.
  • Currently, the reflection functionality of Cangjie does not support Nothing types, function types, tuple types, enum types, or generic struct types.

API

Function

NameDescription
parseParameterTypes(String)Converts a string into a function signature that contains specific type information for use by functions such as getStaticFunction.

Class

NameDescription
TypeInfoProvides a common interface for operations on all data types and allows users to perform reflection operations.
ClassTypeInfoDescribes information about the class type.
InterfaceTypeInfoDescribes information about the interface type.
PrimitiveTypeInfoDescribes information about the primitive data type.
StructTypeInfoDescribes information about the struct type.
InfoListAn information list used to store read-only reflection information.
ConstructorInfoDescribes constructor functions.
ParameterInfoDescribes function parameters.
InstanceFunctionInfoDescribes instance member functions.
StaticFunctionInfoDescribes static member functions.
InstancePropertyInfoDescribes instance member properties.
StaticPropertyInfoDescribes static member properties.
InstanceVariableInfoDescribes instance member variables.
StaticVariableInfoDescribes static member variables.
ModuleInfoDescribes module information, providing the ability for Cangjie dynamic module loading, caching, and querying package information within the module.
PackageInfoDescribes package information.
GlobalFunctionInfoDescribes global functions.
GlobalVariableInfoDescribes global variables.

Enumeration

NameDescription
ModifierInfoDescribes information about modifiers.

Exception

NameDescription
ReflectExceptionSpecifies the base exception class for the Reflect package.
InfoNotFoundExceptionIndicates that the corresponding information cannot be found.
MisMatchExceptionIndicates an exception thrown when the corresponding function is called incorrectly.
IllegalSetExceptionIndicates an exception thrown upon an attempt to modify an immutable type.
IllegalTypeExceptionIndicates a type mismatch exception.
InvocationTargetExceptionIndication an exception that wraps a function invocation exception.