kasmine 0.1.1 indexed Facilitates dynamic Java class generation and manipulation at runtime through a byte code writer. Features include customizable JVM bytecode instructions, dynamic class loading, and a DSL-like interface for class construction.
Bring this to kpkg
This library is indexed from the KMP ecosystem and already resolves through kpkg.dev's Maven Central proxy. Maintainers can verify the namespace and publish future versions to kpkg for free hosting, real download stats, and signed-provenance pages.
Publishing coming soonMetadata
Owner w8mr
Stars 0
Used by —
Health —
License —
Latest 0.1.1
Repository github.com/w8mr/kasmine
Updated 2026-06-29 Readme Changelog Kasmine — JVM Bytecode Writer for Kotlin
Kasmine is a Kotlin Multiplatform library for writing JVM bytecode dynamically at runtime. It provides a DSL for defining classes, methods, fields, and bytecode instructions directly in Kotlin, enabling advanced use cases like runtime class generation, dynamic proxies, and bytecode manipulation.
Features
Quick Start
Dependencies
Add to your build.gradle.kts:
repositories {
mavenCentral()
}
dependencies {
implementation("nl.w8mr.kasmine:core" )
}
Roadmap
Documentation
Overview — architecture and key concepts
Class Builder DSL — building classes with the DSL
ByteCodeWriter — low-level bytecode writing
Types — constant pool types, opcodes, and instructions
Platform Support — JVM and JS implementations
License
MIT License — see LICENSE .
DSL-based class construction — define classes, methods, and instructions in idiomatic Kotlin
Automatic constant pool management — deduplication and reference counting of constant pool entries
Jump target resolution — automatic calculation of forward and backward branch offsets
Configurable class file version — set any version from 45.0 (Java 1.1) to 65.0 (Java 21) via the version property
StackMapTable generation — forward dataflow analysis computes stack map frames (full_frame) for version ≥ 50; automatically skipped for older versions
Computed maxStack / maxLocals — dataflow analysis tracks operand stack and local variable usage, eliminating hardcoded values
Runtime class loading — load generated classes via DynamicClassLoader
133+ unit tests — coverage spanning common and platform-specific code, including verified class loading on JVM
Multiplatform — runs on JVM and JavaScript (JS targets generate bytecode for analysis/serialization)
Published to Maven Central — no custom repositories neededval myClass = classBuilder {
access = 33u
name = "MyDynamicClass"
version = 52
method {
access = 9u
name = "main"
signature = "([Ljava/lang/String;)V"
instructionBlock {
getstatic("java/lang/System" , "out" , "Ljava/io/PrintStream;" )
ldc("Hello from Kasmine!" )
invokevirtual("java/io/PrintStream" , "println" , "(Ljava/lang/String;)V" )
return_()
}
}
}
val bytecode = myClass.write()
val clazz = DynamicClassLoader(null ).define("MyDynamicClass" , bytecode)
val mainMethod = clazz.getMethod("main" , Array<String>::class .java)
mainMethod.invoke(null , arrayOf<String>())
Compact StackMapTable frames (SAME, APPEND, CHOP) Planned — currently always emits full_frame (tag 255) Full type tracking (Float, Double, Long) in dataflow Planned — currently only Integer and Object references are tracked Arithmetic / comparison opcodes (iadd, isub, ixor, if_icmpeq, etc.) Planned invokedynamic support Planned Exception handlers Planned Interfaces (implements) Planned Bootstrap methods Planned Instruction-level maxStack tracking on InstructionBlock Planned — fields exist but aren't updated areturn with null and Object trackingPlanned — currently treated as top-of-stack pop
Related libraries Surfaced from shared tags and platforms — no rankings paid for.
KMP-RWMutex ★ 10
MayakaApps Lightweight read-write mutex implementation inspired by Golang's `sync.RWMutex`. Utilizes extension functions for simplified read/write lock management and state checking. Shared: utility, language-extensions, kotlin-dsl alchemist ★ 176
kevincianfarini Facilitates type-safe arithmetic operations for physical quantities using SI units, enabling logical modeling of quantities and customizable unit extensions with easy extensibility for custom formulas. Shared: utility, language-extensions kotlinx-uuid ★ 128
hfhbd Introduces support for universally unique identifiers (UUIDs), offering serialization capabilities and compatibility across various platforms. Integrates seamlessly with existing serialization libraries for enhanced data handling. Shared: utility, language-extensions doistx-normalize ★ 71
Doist Adds support for Unicode normalization as per Unicode Standard Annex #15, extending the `String` class with a `normalize(Form)` method, supporting NFC, NFD, NFKC, and NFKD forms. Shared: utility, language-extensions kotlinx-datetime-ext ★ 36
RaedGhazal Enhances date and time manipulation with extensions and helper functions, bridging gaps with Java's `java.time` API. Features include date arithmetic, parsing, formatting, and locale support. Shared: utility, language-extensions HebrewNumeralsLibrary ★ 31
kdroidFilter Offers functions for converting Hebrew strings to Gematria values, integers to Hebrew numerals, and Talmudic page numbers to string representations. Includes multiplatform and export options for native and JavaScript libraries. Shared: utility, language-extensions