IKVM.ByteCode
9.2.2
Prefix Reserved
dotnet add package IKVM.ByteCode --version 9.2.2
NuGet\Install-Package IKVM.ByteCode -Version 9.2.2
<PackageReference Include="IKVM.ByteCode" Version="9.2.2" />
paket add IKVM.ByteCode --version 9.2.2
#r "nuget: IKVM.ByteCode, 9.2.2"
// Install IKVM.ByteCode as a Cake Addin #addin nuget:?package=IKVM.ByteCode&version=9.2.2 // Install IKVM.ByteCode as a Cake Tool #tool nuget:?package=IKVM.ByteCode&version=9.2.2
IKVM.ByteCode
Provides a Java class file parser, reader and writer implementation used by the IKVM project.
The core of the project contains the various abstractions that are used throughout. These abstractions are loosely modeled on the System.Reflection.Metadata namespace. The design is low allocation.
Decoding
The IKVM.ByteCode.Decoding
namespace contains specialized structures for reading data from the class file specification. The main entry point of this namespace will be ClassFile
which can be used to read a Java class file from a variety of sources. ClassFile
itself holds a reference to the underlying original memory that was read from and parses the minimal amount possible depending on the operation. ClassFile
implements IDisposable
for releasing this memory.
ClassFile
's companion structures are field-only record types. This allows directly taking a ref
to a item in a collection or a field.
Constant values are left unresolved in this structure just like System.Reflection.Metadata
token handles. It is the users responsibilty to obtain a ConstantHandle
from one of the data structures and refer to the ClassFile.Constants
ConstantTable
to lookup the ConstantKind
, ConstantData
or Constant
itself.
Each of the field-only record structures can be individually used to parse or encode data. To parse each provides it's own TryMeasure
and TryRead
methods. TryMeasure
does a minimal amount of parsing to determine the size of the data from the initial position. This is helpful due to a Java class file's forward-only nature: you can't know the size of the class without reading each part of the class. TryMeasure
thus allows you to measure the given structure without committing to parsing or allocating objects.
TryRead
actually reads the data. In both of these cases, false
is returned if the end of the memory has been reached. Exceptions are thrown for parsing errors involving valid data.
Each of the field-only record structures also contains EncodeTo
and WriteTo
. EncodeTo
processes the structure, along with a IConstantHandleMap
, and reemits it to an Encoder. This allows you to copy structures read from one class file into another, either creating the necessary constants in the new class, or reencode it to an output stream using IdentityConstantMap
. EncodeTo
requires acccess to a IConstantHandleMap
to read constant data in order to navigate into dynamic components that require constant data to reason about (for instance Attribute
s). WriteTo
is much lighter weight: it simply emits the structure as is without consideration as to the constants. They must already be present in whatever constant table is used with the resulting class file.
Constants
Constants are represented in three sets of data structures: *ConstantData
, *ConstantHandle
and *Constant
*Constant
structures represent a full local constant value in native .NET types. For instance, Utf8Constant
directly contains the string value. These are used to pass around desired constant values for lookup or insertion. These types are arrainged in a hierarchy implemented through custom operators. For instance one can cast between Constant
and Utf8Constant
. Casting to Constant
encodes the original ConstantKind
on the structure, so that casting back to Utf8Constant
would fail.
*ConstantHandle
structures represent a handle to a location (slot) in a constant table. These are single-field structures, merely used for type safety. Like Constant
, casting is allowed between compatible types. These abstract the locality of a constant in a constant table.
*ConstantData
structures store the actual constant data that would be present in a constant table. Most constants are simply collections of handles to other constants. However, constants like Utf8ConstantData
contain a pointer to the original parsed memory, and is decoded to a .NET string on demand. The base ConstantData
structure maps over the original segmented constant data from a class file and parses it only on demand when cast.
Encoding
Encoding class files or parts of class files in IKVM.ByteCode
is similar to System.Reflection.Metadata.Ecma335
. A common linkable buffer, BlobBuilder
, is provided which is the target of the various builders and encoders. BlobBuilder
allows for fast append, and fast enumeration from the beginning, by linked list of segments of memory. BlobBuilder
s can be linked to the end of existing BlobBuilder
s. Assembling Java class files then is allocating a BlobBuilder
and using one of the various Encoder classes to emit output into it. That output can then be appened together with other segments before being serialized to output.
ClassFormatWriter
represents the main operations for emitting class file output data: U1, U2 and U4, as defined by the specification. Each of the encoder structures target a ClassFormatWriter
, which can be backed by a Span<byte>
which can be allocated in segments from a BlobBuilder
. Each Encoder provides a number of methods that have to be invoked in order to write the appropriate components. Encoders can be passed by ref
between methods. They maintain minimal state such as a count of emitted elements. The nested structure of a Java class file is encapsulated by passing delegates with the nested encoders.
ClassBuilder
makes it easy to encode an entire Java class file to a temporary series of blobs that are then assembled into a final format.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 is compatible. 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. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- System.Memory (>= 4.5.5)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on IKVM.ByteCode:
Package | Downloads |
---|---|
IKVM
Java SE 8 Virtual Machine for .NET |
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.2.2 | 3,123 | 10/29/2024 |
9.2.1 | 119 | 10/29/2024 |
9.2.0 | 126 | 10/28/2024 |
9.1.3 | 974 | 8/20/2024 |
9.1.2 | 179 | 8/19/2024 |
9.1.1 | 187 | 8/19/2024 |
9.1.0 | 211 | 8/17/2024 |
9.0.0 | 18,614 | 8/14/2024 |
8.12.0 | 256 | 8/12/2024 |
8.11.0 | 172 | 8/4/2024 |
8.10.0 | 320 | 7/20/2024 |
8.9.1 | 7,793 | 7/14/2024 |
8.9.0 | 692 | 7/12/2024 |
8.9.0-pre.3 | 116 | 7/10/2024 |