diff --git a/src/IKVM.ByteCode/ClassFormatVersion.cs b/src/IKVM.ByteCode/ClassFormatVersion.cs index b067fd5..c814a14 100644 --- a/src/IKVM.ByteCode/ClassFormatVersion.cs +++ b/src/IKVM.ByteCode/ClassFormatVersion.cs @@ -86,6 +86,9 @@ public record struct ClassFormatVersion(ushort Major, ushort Minor) : IComparabl /// Java 25 (class file 69.0) public static readonly ClassFormatVersion Java25 = new(69, 0); + /// The latest class file format version supported by this library. + public static readonly ClassFormatVersion Latest = Java25; + /// /// Implicitly converts a major version number to a with a minor version of 0. /// diff --git a/src/IKVM.ByteCode/Decoding/ClassFile.cs b/src/IKVM.ByteCode/Decoding/ClassFile.cs index 0588ec5..47ff2ee 100644 --- a/src/IKVM.ByteCode/Decoding/ClassFile.cs +++ b/src/IKVM.ByteCode/Decoding/ClassFile.cs @@ -40,7 +40,7 @@ public static bool TryMeasure(ref ClassFormatReader reader, ref int size) if (reader.TryReadU2(out ushort majorVersion) == false) return false; - if (majorVersion > 63) + if (majorVersion > ClassFormatVersion.Latest.Major) throw new UnsupportedClassVersionException(new ClassFormatVersion(majorVersion, minorVersion)); if (ConstantTable.TryMeasure(ref reader, ref size) == false) @@ -252,7 +252,7 @@ public static bool TryRead(ref ClassFormatReader reader, out ClassFile? clazz, I if (reader.TryReadU2(out ushort majorVersion) == false) return false; - if (majorVersion > 63) + if (majorVersion > ClassFormatVersion.Latest.Major) throw new UnsupportedClassVersionException(new ClassFormatVersion(majorVersion, minorVersion)); var version = new ClassFormatVersion(majorVersion, minorVersion);