IKVM.ByteCode
9.3.13
Prefix Reserved
dotnet add package IKVM.ByteCode --version 9.3.13
NuGet\Install-Package IKVM.ByteCode -Version 9.3.13
<PackageReference Include="IKVM.ByteCode" Version="9.3.13" />
<PackageVersion Include="IKVM.ByteCode" Version="9.3.13" />
<PackageReference Include="IKVM.ByteCode" />
paket add IKVM.ByteCode --version 9.3.13
#r "nuget: IKVM.ByteCode, 9.3.13"
#:package IKVM.ByteCode@9.3.13
#addin nuget:?package=IKVM.ByteCode&version=9.3.13
#tool nuget:?package=IKVM.ByteCode&version=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.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- System.Memory (>= 4.6.3)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETStandard 2.0
- System.Memory (>= 4.6.3)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
net10.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on IKVM.ByteCode:
| Package | Downloads |
|---|---|
|
IKVM
Java SE 8 Virtual Machine for .NET |
|
|
IKVM.Java.Extensions
Various extensions for bridging the gap between .NET and Java. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on IKVM.ByteCode:
| Repository | Stars |
|---|---|
|
ikvmnet/ikvm
A Java Virtual Machine and Bytecode-to-IL Converter for .NET
|
| Version | Downloads | Last Updated |
|---|---|---|
| 9.3.13 | 178 | 6/4/2026 |
| 9.3.12 | 731 | 3/8/2026 |
| 9.3.11 | 777 | 12/19/2025 |
| 9.3.10 | 397 | 12/18/2025 |
| 9.3.9 | 397 | 12/18/2025 |
| 9.3.8 | 382 | 12/17/2025 |
| 9.3.7 | 374 | 12/16/2025 |
| 9.3.6 | 432 | 12/15/2025 |
| 9.3.5 | 297 | 12/12/2025 |
| 9.3.4 | 184,927 | 3/13/2025 |
| 9.3.3 | 545 | 3/12/2025 |
| 9.3.2 | 515 | 3/12/2025 |
| 9.3.1 | 569 | 3/12/2025 |
| 9.3.0 | 157,605 | 12/11/2024 |
| 9.2.2 | 48,600 | 10/29/2024 |
| 9.2.1 | 478 | 10/29/2024 |
| 9.2.0 | 498 | 10/28/2024 |
| 9.1.3 | 1,455 | 8/20/2024 |
| 9.1.2 | 521 | 8/19/2024 |
| 9.1.1 | 535 | 8/19/2024 |