AlphaOmega.ByteCodeReader 1.1.34

dotnet add package AlphaOmega.ByteCodeReader --version 1.1.34
                    
NuGet\Install-Package AlphaOmega.ByteCodeReader -Version 1.1.34
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AlphaOmega.ByteCodeReader" Version="1.1.34" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlphaOmega.ByteCodeReader" Version="1.1.34" />
                    
Directory.Packages.props
<PackageReference Include="AlphaOmega.ByteCodeReader" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AlphaOmega.ByteCodeReader --version 1.1.34
                    
#r "nuget: AlphaOmega.ByteCodeReader, 1.1.34"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AlphaOmega.ByteCodeReader@1.1.34
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AlphaOmega.ByteCodeReader&version=1.1.34
                    
Install as a Cake Addin
#tool nuget:?package=AlphaOmega.ByteCodeReader&version=1.1.34
                    
Install as a Cake Tool

Byte Code Reader

Auto build NuGet

A managed .NET library for parsing Java Virtual Machine (JVM) class (*.class) files. It provides strongly typed access to the full constant pool, fields, methods, interfaces and all attribute blocks defined in the Java Class File Format (JVM Spec §4).

Target frameworks

  • .NET Framework 2.0
  • .NET Standard 2.0 (compatible with .NET 8 and earlier)

Why use it?

  • Zero external native dependencies
  • Lazy constant pool parsing (constants are materialized as needed)
  • Full fidelity access to raw attribute data
  • Works with very old and modern class file versions

Install

Package manager:

Install-Package AlphaOmega.ByteCodeReader

dotnet CLI:

dotnet add package AlphaOmega.ByteCodeReader

Quick Start

using System;
using AlphaOmega.Debug;

using(ClassFile cls = new ClassFile(StreamLoader.FromFile(@"C:\Test\MyClass.class")))
{
    if(!cls.IsValid)
        throw new InvalidOperationException("Invalid JVM class file");

    Console.WriteLine($"Class: {cls.ThisClass.Bytes}");
    Console.WriteLine($"Super: {cls.SuperClass?.Bytes ?? "<Object>"}");
    Console.WriteLine($"Version: {cls.MajorVersion}.{cls.MinorVersion}");

    // Fields
    foreach(var f in cls.Fields)
        Console.WriteLine($"Field: {f.Name.Bytes} {f.Descriptor.Bytes}");

    // Methods
    foreach(var m in cls.Methods)
        Console.WriteLine($"Method: {m.Name.Bytes}{m.Descriptor.Bytes}");

    // Constant Pool (example: list all Utf8 entries)
    foreach(var utf8 in cls.ConstantPool.Utf8)
        Console.WriteLine($"Utf8[{utf8.Index}]: {utf8.Bytes}");
}

Core Concepts

  • ClassFile: Root parser for one JVM class / interface file.
  • ConstantTables: Provides typed access to each constant pool table (Class, Fieldref, Methodref, InterfaceMethodref, String, Integer, Float, Long, Double, NameAndType, Utf8, MethodHandle, MethodType, InvokeDynamic).
  • AttributeTables / AttributePool: Unified access to attributes from class, fields, and methods.
  • Field_Info / MethodInfo: High-level wrappers exposing metadata and per-member attributes.

Supported Structures

The reader currently handles:

  • Header (magic, versioning)
  • ConstantPool (all spec tags including invokedynamic)
  • ThisClass / SuperClass
  • Interfaces
  • Fields (field_info)
  • Methods (method_info)
  • Attributes (attribute_info) at class, field, and method level
  • Aggregated AttributePool (all attributes from all structures)

Common attribute types recognized (JVM Spec §4.7):

  • InnerClasses
  • EnclosingMethod
  • Synthetic
  • Signature
  • SourceFile
  • SourceDebugExtension
  • Deprecated
  • RuntimeVisibleAnnotations
  • RuntimeInvisibleAnnotations
  • BootstrapMethods

Unrecognized attributes are preserved (spec requires silent ignore) so tooling can still inspect raw data.


Accessing Raw Binary Data

You can access raw constant pool bytes or attribute blocks for advanced analysis or re-emission.

Byte[] rawConstants = cls.ConstantPool.GetData();

Error Handling

  • Invalid magic number throws ArgumentException.
  • Use ClassFile.IsValid for a quick check after constructing.

Performance Notes

  • Constant pool rows are wrapped in lightweight objects; repeated access reuses instances.
  • Long / Double constants advance index per JVM spec (extra unusable slot handled internally).

Limitations / Roadmap

  • Does not modify or write class files (read-only).
  • StackMapTable, Module, Record attributes (newer JVM versions) may need extension.
  • Bytecode instruction stream decoding (Code attribute body) can be added.

Planned:

  • Detailed Code attribute parser (instructions, exception table, line numbers)
  • CLI tool for quick inspection
  • Optional rewrite / emit API

Versioning

Class file version exposed via ClassFile.Version, MajorVersion, MinorVersion (e.g. 61.0 for Java 17).


Security

Only parses local byte arrays / streams. No code execution or dynamic loading.



Feedback and improvements welcome.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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 net20 is compatible.  net35 was computed.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 2.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.34 241 10/28/2025
1.1.33 234 11/18/2024
1.0.8415.27098 379 1/15/2023