SRO.CLSJVM.RefResolution 1.0.33
SRO.CLSJVM.RefResolution
A multi-platform .NET library that provides reference resolution for JVM-targeting compilers. It resolves class, field, and method information from two complementary sources:
- Manual registration — a compiler's front-end registers entities it has already parsed from source code so they can be looked up later during semantic analysis.
- Binary classpath scanning — compiled JVM artifacts (class directories, JAR archives, and JIMAGE module files) are inspected on demand so that external library types can participate in name resolution without requiring source code.
Target Frameworks
| Framework | Notes |
|---|---|
| .NET Framework 4.7.2 | Full desktop support |
| .NET Framework 4.8 | Full desktop support |
| .NET Standard 2.0 | Broad compatibility |
| .NET Standard 2.1 | Span / default interfaces |
| .NET 8 | LTS release |
| .NET 9 | Current release |
Dependencies
| Package | Purpose |
|---|---|
SRO.CLSJVM.LookingGlass |
Low-level JVM class-file reader used by BinaryClassManager |
SRO.CLSJVM.JAR |
JAR archive I/O utilities used by ClassLocator |
Quick Start
// 1. Configure the library – provide a JVM-style classpath.
var config = new LibraryConfiguration("/opt/java/jdk-21/lib/ct.sym:/myapp/libs/*", verbose: false);
// 2. Create and initialise the library.
var library = new CodeAssetsLibrary();
library.Initialize(config);
// 3. Register source-derived entities.
var stringClass = new ClassData("java.lang.String");
library.RegisterClass(stringClass);
var lengthMethod = new MethodData("length", stringClass);
library.RegisterMethod(lengthMethod);
// 4. Query by fully qualified name.
ClassData result = library.FindClass(new ClassCriteria("java.lang.String"));
if (result.Result == QueryResult.Success)
{
Console.WriteLine($"Found: {result.FullClassName}");
}
// 5. Query when only a simple name and a set of candidate packages are known.
var ambiguous = new AmbiguousClassCriteria(
new List<string> { "com.example.mypackage", "java.lang" },
"String");
ClassData ambiguousResult = library.FindClass(ambiguous);
Core Concepts
CodeAssetsLibrary
CodeAssetsLibrary is the central facade for the library. It maintains in-memory dictionaries of registered classes, fields, and methods and delegates binary lookups to BinaryClassManager.
| Method | Description |
|---|---|
Initialize(LibraryConfiguration) |
Prepares the library for use; initialises the binary classpath. |
Reinitialize(LibraryConfiguration) |
Replaces the active configuration without creating a new instance. |
RegisterClass(ClassData) |
Adds a class entity to the in-memory registry. |
RegisterField(FieldData) |
Adds a field entity to the in-memory registry. |
RegisterMethod(MethodData) |
Adds a method entity to the in-memory registry. |
FindClass(ClassCriteria) |
Resolves a class by its fully qualified name. Falls back to binary classpath on miss. |
FindClass(AmbiguousClassCriteria) |
Resolves a class from a simple name and an ordered candidate namespace list. |
FindField(FieldCriteria) |
Resolves a field by host class, name, and optional type. Returns MultipleMatches when more than one field is found without a type discriminator. |
FindMethod(MethodCriteria) |
Resolves a method by host class, name, and optional parameter signature. Returns MultipleMatches when more than one overload matches a name-only query. |
LibraryConfiguration
Carries the settings passed to Initialize or Reinitialize.
// Default – empty classpath, verbose off.
var cfg = new LibraryConfiguration();
// Explicit.
var cfg = new LibraryConfiguration(classpath: "/usr/lib/jvm/java-21/lib/*", verbose: true);
| Property | Type | Description |
|---|---|---|
Classpath |
string |
JVM-style classpath string. Entries are separated by the platform path separator (; on Windows, : on Linux). Entries ending with * are expanded to all .jar files in that directory (non-recursive, per JVM spec). |
Verbose |
bool |
When true, the library raises CodeLibraryMessage events for diagnostic output. |
Query Criteria
ClassCriteria
Use ClassCriteria when the fully qualified class name is known at query time.
// Top-level class.
var c = new ClassCriteria("java.util.ArrayList");
// Named inner class.
var inner = new ClassCriteria("java.util.AbstractMap") { InnerClassName = "SimpleEntry" };
// Anonymous class (JVM synthetic index).
var anon = new ClassCriteria("com.example.Outer") { AnonymousClassIndex = 1 };
AmbiguousClassCriteria
Use AmbiguousClassCriteria when only a simple name is available and the fully qualified package must be resolved by trying candidate namespaces in order.
// Regular class – tries "com.example" then "java.lang".
var a = new AmbiguousClassCriteria(
new List<string> { "com.example", "java.lang" }, "String");
// Anonymous class factory.
var anon = AmbiguousClassCriteria.ForAnonymousClass(namespaces, "Outer", anonymousIndex: 1);
// Inner named class factory.
var inner = AmbiguousClassCriteria.ForInnerClass(namespaces, "AbstractMap", "SimpleEntry");
MethodCriteria
var host = new ClassCriteria("java.util.ArrayList");
// Match all overloads of "add".
var allOverloads = new MethodCriteria(host, "add");
// Match a specific overload.
var exact = new MethodCriteria(
host,
"add",
parameters: new List<ParameterCriteria>
{
new ParameterCriteria(new TypeCriteria("java.lang.Object"))
},
returnType: new TypeCriteria("boolean"),
methodType: MethodType.Regular);
FieldCriteria
var host = new ClassCriteria("java.lang.System");
// Match by name only (returns MultipleMatches if the name is overloaded).
var byName = new FieldCriteria(host, "out");
// Match with an explicit type.
var exact = new FieldCriteria(host, "out", new TypeCriteria("java.io.PrintStream"));
Result Types
All Find* methods return a *Data object. Inspect the Result property before using any other fields.
ClassData cd = library.FindClass(new ClassCriteria("java.lang.String"));
switch (cd.Result)
{
case QueryResult.Success: /* use cd */ break;
case QueryResult.MultipleMatches: /* ambiguous – narrow the query */ break;
case QueryResult.NotFound: /* not in registry or on classpath */ break;
}
| Result | Meaning |
|---|---|
QueryResult.Success |
Exactly one match was found. |
QueryResult.MultipleMatches |
More than one match exists; the first match is returned but the query should be made more specific. |
QueryResult.NotFound |
No matching entity was found in either the registry or the binary classpath. |
Data Holders
| Class | Key Properties |
|---|---|
ClassData |
FullClassName, AnonymousClass, InnerNamedClass, Access (MemberAccess), Result |
MethodData |
MethodName, HostClass, Parameters, ReturnTypeName, IsConstructor, Access, Result |
FieldData |
FieldName, HostClass, TypeName, Access, Result |
ParameterData |
TypeName, IsVarArgs |
MemberAccess Flags
MemberAccess is a [Flags] enumeration that maps directly to the JVM access_flags bitmask defined in the class-file specification, while providing human-readable names for each bit position.
bool isPublicStatic = classData.Access.HasFlag(MemberAccess.Public)
&& classData.Access.HasFlag(MemberAccess.Static);
Context-dependent bits follow the JVM convention:
| Bit | Method context | Field context | Class context |
|---|---|---|---|
0x0020 |
Synchronized |
— | Super |
0x0040 |
Bridge |
Volatile |
— |
0x0080 |
VarArgs |
Transient |
— |
Binary Classpath Infrastructure
BinaryClassManager
BinaryClassManager is a process-scoped singleton that manages binary class loading from the configured classpath. CodeAssetsLibrary.Initialize calls it automatically; direct access is rarely needed.
// Automatically initialised by CodeAssetsLibrary.Initialize().
// Direct use (advanced):
BinaryClassManager mgr = BinaryClassManager.GetInstance();
bool exists = mgr.Exists("java.lang.String");
BinaryClassData bcd = mgr.LoadClass("java.util.ArrayList");
LoadClass caches loaded classes in memory so each .class entry in the classpath is read only once per process lifetime.
ClassLocator
ClassLocator is the low-level search engine used by BinaryClassManager. It accepts JAR files, plain class directories, and wildcard directory expansions as classpath entries and resolves dot-notation class names to the appropriate binary stream.
var locator = new ClassLocator();
locator.SetUp(); // auto-discovers JAVA_HOME
locator.LoadClassPath("/mylibs/*:/myproject/bin");
string fqn = locator.ExpandNameViaImports("ArrayList", importList);
string fqn2 = locator.ExpandNameViaUsing("String", usingList);
string fqn3 = locator.ExpandNameUsingNamespace("String", "java.lang");
ClassPathHandler
ClassPathHandler deserialises the Eclipse .classpath XML project file format and computes a JVM classpath string from its entries. This is useful when the library is hosted inside an Eclipse-layout workspace.
var handler = new ClassPathHandler();
handler.Load("/path/to/project/.classpath");
string cp = handler.Classpath; // ready to pass to LibraryConfiguration
Utility Types
FileSystemItem
A cross-platform file-system abstraction modelled after java.io.File. It wraps a path and provides directory listing, existence testing, and child-item construction, isolating the rest of the library from direct System.IO usage.
var root = new FileSystemItem("/opt/java");
var lib = new FileSystemItem(root, "lib");
FileSystemItem[] children = lib.ListFiles();
The static constants FileSystemItem.Separator and FileSystemItem.PathSeparator expose the platform-specific directory and path-list separator characters respectively.
JarFilter / FilenameFilter
FilenameFilter is an interface with a single Accept(FileSystemItem dir, string name) method. JarFilter is the built-in implementation that accepts files whose names end with .jar.
Exceptions
| Exception | When thrown |
|---|---|
ClassNotFoundException |
A required binary class cannot be located on the classpath. |
JVMIOException |
An I/O error occurs while reading a JAR or class-file stream. |
NoSuchFieldException |
A field lookup fails in a context where absence is exceptional. |
NoSuchMethodException |
A method lookup fails in a context where absence is exceptional. |
License
Copyright © 2026 Serengeti Research Organization. All rights reserved.
No packages depend on SRO.CLSJVM.RefResolution.
.NET Framework 4.7.2
- SRO.CLSJVM.JAR (>= 1.0.1)
- SRO.CLSJVM.LookingGlass (>= 1.0.31)
.NET Framework 4.8
- SRO.CLSJVM.JAR (>= 1.0.1)
- SRO.CLSJVM.LookingGlass (>= 1.0.31)
.NET 8.0
- SRO.CLSJVM.JAR (>= 1.0.1)
- SRO.CLSJVM.LookingGlass (>= 1.0.31)
.NET 9.0
- SRO.CLSJVM.JAR (>= 1.0.1)
- SRO.CLSJVM.LookingGlass (>= 1.0.31)
.NET Standard 2.0
- SRO.CLSJVM.JAR (>= 1.0.1)
- SRO.CLSJVM.LookingGlass (>= 1.0.31)
.NET Standard 2.1
- SRO.CLSJVM.JAR (>= 1.0.1)
- SRO.CLSJVM.LookingGlass (>= 1.0.31)
| Version | Downloads | Last updated |
|---|---|---|
| 1.0.46 | 4 | 10/30/2026 |
| 1.0.45 | 2 | 10/30/2026 |
| 1.0.44 | 7 | 10/16/2026 |
| 1.0.43 | 3 | 10/16/2026 |
| 1.0.42 | 4 | 10/15/2026 |
| 1.0.41 | 4 | 10/14/2026 |
| 1.0.40 | 3 | 10/13/2026 |
| 1.0.39 | 3 | 10/12/2026 |
| 1.0.38 | 3 | 10/12/2026 |
| 1.0.37 | 3 | 10/09/2026 |
| 1.0.36 | 4 | 10/08/2026 |
| 1.0.35 | 3 | 10/08/2026 |
| 1.0.34 | 3 | 10/07/2026 |
| 1.0.33 | 3 | 10/06/2026 |
| 1.0.32 | 4 | 10/03/2026 |
| 1.0.31 | 4 | 10/02/2026 |
| 1.0.30 | 3 | 10/01/2026 |
| 1.0.29 | 3 | 10/01/2026 |
| 1.0.28 | 3 | 09/30/2026 |
| 1.0.27 | 4 | 09/28/2026 |
| 1.0.26 | 4 | 09/28/2026 |
| 1.0.25 | 6 | 09/25/2026 |
| 1.0.24 | 5 | 09/24/2026 |
| 1.0.23 | 5 | 09/23/2026 |
| 1.0.22 | 5 | 09/23/2026 |
| 1.0.21 | 5 | 09/23/2026 |
| 1.0.20 | 5 | 09/23/2026 |
| 1.0.19 | 5 | 09/22/2026 |
| 1.0.18 | 4 | 09/22/2026 |
| 1.0.17 | 6 | 09/19/2026 |
| 1.0.16 | 5 | 09/17/2026 |
| 1.0.15 | 4 | 09/17/2026 |
| 1.0.14 | 5 | 09/15/2026 |
| 1.0.13 | 5 | 09/10/2026 |
| 1.0.12 | 5 | 09/09/2026 |
| 1.0.11 | 5 | 09/08/2026 |
| 1.0.10 | 6 | 09/05/2026 |
| 1.0.9 | 5 | 09/04/2026 |
| 1.0.8 | 3 | 09/02/2026 |