docs / stdlib / reflect

Stdlib index
  1. Overview
  1. Captured-borrow migration worklist (3.3.3)
  2. Owned-bind migration worklist (8.2.7)
  3. Return-side title audit — the ride-through enumeration
  4. stdlib ownership audit
  5. stdlib ownership dispositions (plan 1.3.1 / 4.3.1)

aot

  1. Components
  2. Scope
  3. Scoped

codec

  1. Base32
  2. Base64

codec / csv

  1. Csv

codec / json

  1. Json

collection

  1. ArrayList
  2. BPlusTree
  3. Cache
  4. Collectors
  5. HashMap
  6. HashSet
  7. Heap
  8. ImmutableList
  9. ImmutableMap
  10. ImmutableSet
  11. LinkedList
  12. RedBlackTree
  13. Sort

collection / ltm

  1. LtmBPlusTree

concurrent

  1. AtomicInt32
  2. AtomicInt64
  3. Channel
  4. Fiber
  5. FiberLocal
  6. Lock
  7. Mutex
  8. RwLock
  9. Semaphore
  10. Tasks

error

  1. Exception
  2. NoOptionalValueException
  3. NotProvidedException
  4. RecoverableException
  5. ScopedBuildFailedException
  6. ScopeNotActiveException
  7. Throwable
  8. UnrecoverableException

gfx

  1. Sampler
  2. Texture2D

hash

  1. DefaultHasher
  2. Hash
  3. SipHash
  4. XXHash3

ifx

  1. BackendRegistry
  2. Window

io

  1. Buffer

io / file

  1. File
  2. FileInfo
  3. FileReader
  4. FileWriter
  5. Path
  6. Watcher

io / net

  1. BufferPool
  2. ByteBuffer
  3. IpAddress
  4. Server
  5. ServerBuilder
  6. SocketAddress
  7. TcpListener
  8. TcpStream
  9. UdpSocket

io / net / dns

  1. Dns

io / net / uri

  1. Uri
  2. UriBuilder

lang

  1. Guid
  2. Math
  3. Optional
  4. Pair
  5. Slice
  6. String
  7. StringBuilder

lang / stream

  1. ArrayStream
  2. Stream

math

  1. Camera
  2. Color
  3. DType
  4. Ray
  5. Rotation
  6. Tensor
  7. Transform

math / fft

  1. Fft

math / linalg

  1. LinAlg

math / npio

  1. Npy

math / poly

  1. Poly

math / random

  1. Generator

math / stats

  1. Stats

nucleo

  1. Columns — the Arrow-laid-out substrate
  2. Fused tensor expressions — Fuse
  3. Table — the lazy, typed dataframe
  4. Tape — define-by-run autograd
  5. Transform intrinsics — Grad, Vmap, Jit

process

  1. Command
  2. Process

reflect

  1. Class

search / distance

  1. Distance

search / fuzzy

  1. Matcher

search / ngram

  1. Index

session

  1. PackageInstallException
  2. Packages

time

  1. Clock
  2. DateTimeFormatter
  3. Duration
  4. Instant
  5. LocalDate
  6. LocalDateTime
  7. LocalTime
  8. Period
  9. ZonedDateTime
  10. ZoneId
  11. ZoneOffset

wire

  1. Compressor
  2. CompressStream
  3. DecompressionLimitException
  4. Decompressor
  5. Encoder
  6. Schema
  7. SchemaEncoder

xpu

  1. Device
  2. KernelBuffer
  3. KernelStream
  4. KernelTimer

xpu / mesh

  1. MeshSimplifier

Class<T>

cajeta.reflect.Class — runtime representation of a class, the entry point to cajeta.reflect. Obtain one via Class.of(obj) (the object’s dynamic type) or T.class (a statically-known type); each is a borrow of a process-lifetime cached instance — one Class per declared type, emitted by the compiler next to the type’s RTTI — that the caller never frees. From it you can read identity and modifiers, enumerate fields, methods, constructors, template parameters/arguments, and annotations, read and write primitive fields, construct instances reflectively, and query the process-wide class registry.

ArrayList<int32> xs = heap ArrayList<int32>();
Class<?> c = Class.of(xs);
String name #= c.getName();       // fully-qualified canonical name
int32 nFields = c.getFieldCount();
int32 nMethods = c.getMethodCount();

Methods

Signature
static Class<?> of(Object o) ⚑The runtime Class of o (its dynamic type)
static Optional<Class<?>> forName(String name) ⚑Resolve a canonical name (e.g. "cajeta.lang.String") to its cached Class; empty when unregistered — primitives never resolve
static Optional<T> heapInstance<T>(String name, Class<?> bound) ⚑Bounded by-name allocation: resolve name, verify it is a subtype of the bound, construct via the no-arg constructor; empty on unknown name or non-subtype (the bound is injected by the compiler from the <T> token)
#String getName()The fully-qualified canonical class name
int64 getInstanceSize()Heap size of an instance in bytes
int32 getModifierFlags()Raw modifier bit field for the class
boolean isPublic()Class has the public modifier
boolean isFinal()Class has the final modifier
#Modifiers getModifiers()The modifiers as a typed Modifiers value
int32 getFieldCount()Number of declared fields
#String getFieldName(int32 index)Declared field name at index (0-based); empty if out of range
int32 getFieldModifierFlags(int32 index)Raw modifier bit field for the field at index
int32 getFieldOffset(int32 index)Byte offset of the field within an instance, or -1 for a static field
int64 getFieldTypeFlags(int32 index)The field’s type-flag word (size, int-vs-float, signed, primitive-vs-reference)
#Field getField(int32 index)The declared field at index as a Field object
int32 getInt32(Object o, int32 index)Read the int32 field at index from instance o
void setInt32(Object o, int32 index, int32 value)Write the int32 field at index of instance o
int64 getInt64(Object o, int32 index)Read the int64 field at index
void setInt64(Object o, int32 index, int64 value)Write the int64 field at index
boolean getBoolean(Object o, int32 index)Read the boolean field at index
void setBoolean(Object o, int32 index, boolean value)Write the boolean field at index
float32 getFloat32(Object o, int32 index)Read the float32 field at index
void setFloat32(Object o, int32 index, float32 value)Write the float32 field at index
float64 getFloat64(Object o, int32 index)Read the float64 field at index
void setFloat64(Object o, int32 index, float64 value)Write the float64 field at index
#Object getBoxed(Object o, int32 index)Read field index of o as a uniform owned #Object, boxing a primitive into its cajeta.lang wrapper
int32 getMethodCount()Number of declared methods
int32 getMethodParamCount(int32 index)Number of declared parameters of the method at index
#String getMethodName(int32 index)Canonical signature of the method at index (e.g. "bump()")
#Method getMethod(int32 index)The declared method at index as a Method object
static int64 invokeScalar0(Object o, int32 index)Reflectively invoke the no-argument method at index on o, result widened to int64 (void yields 0)
int32 getParentCount()Number of direct superclasses (1 for most classes, 0 for Object)
int32 getConstructorCount()Number of declared constructors
int32 getConstructorParamCount(int32 index)Number of declared parameters of the constructor at index
#Constructor getConstructor(int32 index)The declared constructor at index as a Constructor object
#Object heapInstance(int32 index)Reflectively construct a new instance via the no-argument constructor at index; the result is owned
int32 getTemplateParameterCount()Number of declared template parameters (class Box<T> → 1)
#TemplateParameter getTemplateParameter(int32 index)The declared template parameter at index
int32 getTemplateArgumentCount()Number of concrete template arguments this class was instantiated with (Box<int32> → 1)
#TemplateArgument getTemplateArgument(int32 index)The concrete template argument at index
boolean isTemplateInstantiation()True when this class is a materialized template instantiation
int32 getAnnotationCount()Number of annotations declared on this class
#String getAnnotationName(int32 index)Canonical name of the class annotation at index
#Annotation getAnnotation(int32 index)The class annotation at index as an Annotation object
boolean hasAnnotation(String name)Whether this class declares an annotation named name
static #Class<?>[] allClasses()Every class the binary retains, as Class borrows
static #Class<?>[] classesInPackage(String packageName)Every retained class whose package equals packageName
static #Class<?>[] classesAnnotated(String annotationName)Every retained class declaring an annotation with that canonical name
static #Class<?>[] subtypes(Class<?> bound)Every retained class that is a subtype of (or is) the bound — the closed-world subtype closure

⚑ = @EntryPoint

See also

Source: docs/stdlib/reflect/Class.md · 4 min read · 878 words