IKVM.ByteCode 9.3.13

IKVM.ByteCode

A low-allocation Java class file parser, reader, and writer for .NET. Designed for use by the IKVM project, but usable as a general-purpose library for reading and writing Java .class files.

The API is modeled after System.Reflection.Metadata — constant pool entries are referenced by typed handles rather than resolved eagerly, keeping allocations minimal.

Decoding

The IKVM.ByteCode.Decoding namespace provides structures for reading Java class files. The main entry point is ClassFile, which can read from a file path, byte array, stream, or ReadOnlyMemory<byte>. ClassFile holds a reference to the underlying memory and parses lazily. It implements IDisposable.

using IKVM.ByteCode.Decoding;

using var clazz = ClassFile.Read("MyClass.class");

// Read the class name from the constant pool
string className = clazz.Constants.Get(clazz.This).Name;
Console.WriteLine($"Class: {className}");

// Enumerate methods
foreach (var method in clazz.Methods)
{
    string name = clazz.Constants.Get(method.Name).Value;
    string descriptor = clazz.Constants.Get(method.Descriptor).Value;
    Console.WriteLine($"  Method: {name}{descriptor}");
}

Constant pool entries are not resolved automatically. Obtain a *ConstantHandle from any data structure, then look it up via ClassFile.Constants.

Each decoding structure supports CopyTo (re-emits to an encoder with constant remapping via IConstantHandleMap) and WriteTo (raw emit, assuming constants are already present in the target).

Constants

Constants are represented by three families of types:

Type Description
*Constant A fully resolved .NET value (e.g. Utf8Constant holds the string). Used for lookup or insertion.
*ConstantHandle A typed handle to a slot in a constant table. Analogous to System.Reflection.Metadata tokens.
*ConstantData The raw constant data as stored in the class file. Decoded lazily on demand.

Casts between compatible handle and constant types are supported via custom operators.

Encoding

The IKVM.ByteCode.Encoding namespace provides builders and encoders for writing class files.

BlobBuilder is a linked-list buffer supporting fast append and serialization. Encoders write into a ClassFormatWriter backed by segments of a BlobBuilder.

ClassFileBuilder is the high-level entry point for constructing a complete class file:

using IKVM.ByteCode.Buffers;
using IKVM.ByteCode.Decoding;
using IKVM.ByteCode.Encoding;

// Build a simple public class
var builder = new ClassFileBuilder(
    new ClassFormatVersion(53, 0),  // Java 9
    AccessFlag.Public,
    "com/example/MyClass",
    "java/lang/Object");

builder.AddField(AccessFlag.Private, "_value", "I");
builder.AddMethod(AccessFlag.Public, "getValue", "()I");

var blob = new BlobBuilder();
builder.Serialize(blob);

// Write to file
File.WriteAllBytes("MyClass.class", blob.ToArray());

For lower-level encoding, individual encoder structures (e.g. MethodEncoder, AttributeTableEncoder) can be used directly, passed by ref between methods.

Showing the top 20 packages that depend on IKVM.ByteCode.

Packages Downloads
IKVM
Java SE 8 Virtual Machine for .NET
62
IKVM
Java SE 8 Virtual Machine for .NET
58
IKVM
Java SE 8 Virtual Machine for .NET
57
IKVM
Java SE 8 Virtual Machine for .NET
55
IKVM
Java SE 8 Virtual Machine for .NET
51
IKVM
Java SE 8 Virtual Machine for .NET
44
IKVM
Java SE 8 Virtual Machine for .NET
43
IKVM
Java SE 8 Virtual Machine for .NET
42
IKVM
Java SE 8 Virtual Machine for .NET
41
IKVM
Java SE 8 Virtual Machine for .NET
40
IKVM
Java SE 8 Virtual Machine for .NET
38
IKVM
Java SE 8 Virtual Machine for .NET
36
IKVM
Java SE 8 Virtual Machine for .NET
35
IKVM
Java SE 8 Virtual Machine for .NET
34
IKVM
Java SE 8 Virtual Machine for .NET
33

.NET 10.0

  • No dependencies.

.NET Framework 4.7.2

.NET 6.0

  • No dependencies.

.NET 8.0

  • No dependencies.

.NET Standard 2.0

Version Downloads Last updated
9.3.13 7 06/05/2026
9.3.12 31 03/12/2026
9.3.11 32 12/20/2025
9.3.10 32 12/20/2025
9.3.9 33 12/19/2025
9.3.8 41 12/20/2025
9.3.7 29 12/20/2025
9.3.6 33 12/20/2025
9.3.5 33 12/14/2025
9.3.4 28 12/14/2025
9.3.3 26 12/15/2025
9.3.2 24 12/15/2025
9.3.1 24 12/15/2025
9.3.0 31 12/15/2025
9.2.2 33 12/20/2025
9.2.1 25 12/15/2025
9.2.0 23 12/20/2025
9.1.3 25 12/21/2025
9.1.2 30 12/11/2025
9.1.1 22 12/15/2025
9.1.0 22 12/15/2025
9.0.0 26 12/15/2025
8.12.0 28 12/15/2025
8.11.0 27 12/14/2025
8.10.0 24 12/15/2025
8.9.1 28 12/14/2025
8.9.0 25 12/13/2025
8.9.0-pre.3 23 12/12/2025