Repository navigation
Explain unsupported class file versions in ikvmc diagnostics - #797
Merged
Merged
Conversation
Class files newer than Java 8 were reported once per class as a generic "class format error" carrying only the raw version number, and an input in which every class failed still produced an assembly with no types and no further explanation. - Unsupported class file versions now produce one IKVM0146 warning per input naming the Java release(s) and the supported maximum (52.0, Java 8); per-class details move to the IKVM0010 info diagnostic. - IKVM0147 warns when no classes at all could be compiled from an input. - module-info.class and META-INF/versions/ entries are no longer treated as classes; a Java 8 runtime never loads them. - The runtime's UnsupportedClassVersionError uses the same wording, and defineClass now throws UnsupportedClassVersionError rather than ClassFormatError for versions IKVM.ByteCode rejects. Fixes #127
Exceptions thrown to Java code now use HotSpot's exact text instead of the importer's wording: p/A has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 or, when no name was given (defineClass with a null name, and anonymous classes, which HotSpot parses without a name): Unsupported class file version 55.0, this version of the Java Runtime only recognizes class file versions up to 52.0 The class name is in internal form, as in HotSpot. The importer keeps its own wording for diagnostics, including loose .class files on the command line.
HotSpot accepts every 45.x class file, but IKVM rejected anything below 45.3 with UnsupportedClassVersionError. The only format difference before 45.3 is the Code attribute header (u1 max_stack, u1 max_locals, u2 code_length instead of u2, u2, u4), which IKVM.ByteCode always decodes in the modern layout, so decode the narrower header ourselves for those versions. A Code attribute whose contents do not add up to its length is a ClassFormatError, using HotSpot's wording.
wasabii
force-pushed
the
claude/clever-hawking-ziehrb
branch
from
October 17, 2026 21:48
e54361d to
0ed0136
Compare
System.Reflection.Metadata is imported for PEReader, which makes BlobBuilder ambiguous with IKVM.ByteCode.Buffers.BlobBuilder (CS0104).
main moved class file parsing into IKVM.CoreLib.Linking and replaced the runtime's UnsupportedClassVersionError with IKVM.CoreLib.Linking.UnsupportedClassVersionException, which map.xml translates to java.lang.UnsupportedClassVersionError. The supported version range, the Java release names and the message formatting from this branch now live on UnsupportedClassVersionException. It carries the version and, where known, the class name, so the message seen by Java code still matches HotSpot. The narrower pre-45.3 Code attribute decoding moves to the CoreLib Method, and the helper tests move to IKVM.CoreLib.Tests.
wasabii
force-pushed
the
claude/clever-hawking-ziehrb
branch
from
October 21, 2026 23:07
594ad4c to
20e691a
Compare
wasabii
force-pushed
the
claude/clever-hawking-ziehrb
branch
2 times, most recently
from
October 22, 2026 07:36
772f06c to
9930fcb
Compare
…alTest on Windows
actions/cache evaluates its key expression again in the post step that saves
the cache. By then the workspace holds the OpenJDK submodule and every build
output, and hashFiles('**/*.csproj', ...) over all of it regularly exceeds its
120 second limit, failing the Build IKVM job after a successful build. Hash the
tracked project files with git ls-files in a separate step instead, and use its
output as the key.
ButtonGroupLayoutTraversalTest was excluded on Linux for failing intermittently
with a component not reachable in the forward focus cycle. It now fails the
same way on windows-x64, on pull requests that don't touch AWT.
wasabii
added a commit
that referenced
this pull request
Oct 22, 2026
It was already excluded on macOS. On #797 it failed on win-x64 with "Applet thread threw exception: java.lang.RuntimeException: Test failed!" in both the net472 and net8.0 partitions, on a change that doesn't touch AWT. The .html applet test and its .java class stay in step, as the other entries do.
It was already excluded on macOS. On #797 it failed on win-x64 with "Applet thread threw exception: java.lang.RuntimeException: Test failed!" in both the net472 and net8.0 partitions, on a change that doesn't touch AWT. The .html applet test and its .java class stay in step, as the other entries do.
The Archive Test Results step failed on win-x64 after every test had passed. The runner's tar writes ustar headers, converting each file name to the system code page, and stopped at the first langtools tools/javac/unicode entry whose name has a character outside the Basic Multilingual Plane (the SupplementaryJavaID tests), exiting 1 without printing an error. pax stores file names as UTF-8, so the archive keeps every file and the step still fails when tar does.
This reverts commit 155314c. The pax format did not fix the Archive Test Results failure on win-x64. The default format archived the SupplementaryJavaID6 class files fine in other runs, and tar still exited 1 at the same point with --format=pax, so the file name encoding was not the cause.
tar has been exiting 1 on win-x64 after every test passed, without printing an error. When that step fails on Windows, list the processes still running from the work directory and the test results files whose names are not printable ASCII, with their UTF-16 code units, then run tar again with its error output shown. The step doesn't change the job's result.
wasabii
added a commit
that referenced
this pull request
Oct 23, 2026
…Windows Both were already excluded on other platforms and have now each failed twice on win-x64, in OpenJDK partition 8 (net8.0) on #805 and #797, on changes that don't touch AWT or accessibility: - JGlassPaneInternalFrameOverlapping: "The HW component did not pass pixel color check and is not drawn correctly". It was excluded on linux-all and macosx-all, so it is now generic-all. - SlowPanelIteration: "Too slow operation". It was excluded on macosx-all, so it is now macosx-all,windows-all.
wasabii
added a commit
that referenced
this pull request
Oct 23, 2026
…Windows Both were already excluded on other platforms and have now each failed twice on win-x64, in OpenJDK partition 8 (net8.0) on #805 and #797, on changes that don't touch AWT or accessibility: - JGlassPaneInternalFrameOverlapping: "The HW component did not pass pixel color check and is not drawn correctly". It was excluded on linux-all and macosx-all, so it is now generic-all. - SlowPanelIteration: "Too slow operation". It was excluded on macosx-all, so it is now macosx-all,windows-all.
…Windows Both were already excluded on other platforms and have now each failed twice on win-x64, in OpenJDK partition 8 (net8.0) on #805 and #797, on changes that don't touch AWT or accessibility: - JGlassPaneInternalFrameOverlapping: "The HW component did not pass pixel color check and is not drawn correctly". It was excluded on linux-all and macosx-all, so it is now generic-all. - SlowPanelIteration: "Too slow operation". It was excluded on macosx-all, so it is now macosx-all,windows-all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #127. Also addresses the confusion in #676, where an H2 2.x (Java 11) jar silently produced an assembly with no types.
Problem
When ikvmc hits class files newer than Java 8, it prints one
IKVM0101warning per class carrying only the raw version number (class format error "55.0"). It never says that IKVM only supports Java 8 (52.0). If every class in a jar fails this way, the build still succeeds and produces an assembly with no types, and users conclude thatIkvmReferenceis broken.Changes
Importer
IKVM0146warning, one per input jar, replaces the warning per class:4 class(es) in "java11.jar" target Java 11 (class file version 55.0), Java 17 (class file version 61.0) and were skipped; IKVM supports class files up to version 52.0 (Java 8). (first skipped class: "p.A")IKVM0010. ikvmc currently filters out info-level messages, so this is only visible through event tracing. That's why the summary names the first skipped class.IKVM0147warning when no class from an input could be compiled:No classes were compiled from "java11.jar": all 4 class(es) failed to compile, so the output assembly contains no types from it. See the preceding warnings for the reasons.It counts every compile failure, not just version failures. It only fires when the input contained class files that were attempted, so a jar with only resources, or one whose classes all come from referenced assemblies, doesn't trigger it.
module-info.classand entries underMETA-INF/versions/are no longer treated as classes. A Java 8 runtime never loads them as classes, and they caused false warnings (META-INF.versions.11.p.A,Unsupported class version 65.0) on otherwise Java 8 multi-release jars. They stay in the embedded jar as resources, as they did before..classfile passed on the command line keeps its existingIKVM0101warning, but now with the clearer IKVM wording.Warning or error for the empty-output case: I chose a warning. The importer's convention is that a class which fails to compile is a warning and the assembly is still produced. Making this one case an error would break builds that tolerate it today, such as a transitive jar that is never actually used. Anyone who wants a hard failure can pass
-warnaserror:IKVM0147. The warnings already reach MSBuild throughIkvmToolTaskDiagnosticWriter, soIkvmReferenceusers will see them in build output.Runtime: the exception now matches HotSpot exactly
The exception type and message seen by Java code now match OpenJDK 8 exactly. HotSpot's text comes from
hotspot/src/share/vm/classfile/classFileParser.cppinext/openjdk, and I checked it by running a JDK 8:p.A)p/A has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0defineClass(null, …),Unsafe.defineAnonymousClassUnsupported class file version 55.0, this version of the Java Runtime only recognizes class file versions up to 52.0HotSpot uses the same wording for versions that are too old (e.g. 44.0) and for preview versions (
61.65535), and IKVM now does too. The name is in internal form (p/A), as in HotSpot.The exception type changes too. Before, versions IKVM.ByteCode itself rejects (e.g. 255.0) reached Java as
java.lang.ClassFormatError: Unsupported class version 255.0.. They are nowjava.lang.UnsupportedClassVersionError, as on HotSpot. Versions IKVM.ByteCode could read but IKVM rejects already threwUnsupportedClassVersionError, just with the bare55.0message.UnsupportedClassVersionErrorextendsClassFormatError, so existing catches still work.ClassLoader.ReadClassnow gets the name passed todefineClass.Unsafe.defineAnonymousClasschecks the version before handing the class to the parser. Otherwise its"<Unknown>"placeholder would show up where HotSpot reports no name.IKVM.CoreLib.Linking.UnsupportedClassVersionException, whichmap.xmltranslates tojava.lang.UnsupportedClassVersionErrorusing its message. The exception carries the version and, where known, the class name.FormatJavaMessageproduces the HotSpot text for exceptions, andFormatMessageproduces the IKVM text used only in importer diagnostics.Accepted versions now match HotSpot (45.0–52.0)
HotSpot accepts every 45.x class file. IKVM rejected 45.0–45.2 with
UnsupportedClassVersionError. Before 45.3, the only format difference is the Code attribute header:u1 max_stack, u1 max_locals, u2 code_lengthinstead ofu2, u2, u4(classFileParser.cpp,parse_method). IKVM.ByteCode always decodes the modern layout, so the linkingMethodinIKVM.CoreLibnow decodes the narrower header itself for those versions, through IKVM.ByteCode's publicClassFormatReader,ExceptionHandlerTableandAttributeTablereaders. A Code attribute whose contents don't add up to its declared length is aClassFormatError, with HotSpot's wording ("Code segment has wrong length in class file …"). The importer uses the same parser, so ikvmc accepts these class files too.Diagnostics. I added the three entries to
Diagnostic.jsonand regenerated the.g.csfiles with the T4 templates. The generator reproduced the checked-in files byte for byte before I made the edit.Testing
IKVM.Tests/Runtime/UnsupportedClassVersionTests(new):ClassLoader.defineClass(named and with a null name) andUnsafe.defineAnonymousClassat versions 55.0, 61.65535, 44.0 and 255.0, and asserts the exact HotSpot type and message, captured from OpenJDK 8;p.Old(static int f() { return 42; }) at 45.0 and 45.2 with the old Code layout, and at 45.3 with the modern one, and invokesf.IKVM.CoreLib.Tests/Linking/UnsupportedClassVersionExceptionTests(new) covers the accepted range, the version-to-Java mapping and both message formats.IkvmImporterTestsbuild tiny version 52/53/55/61 class files withClassFileBuilderand import them with-log:json. They check:IKVM0146plusIKVM0147and noIKVM0101for a jar where every class is too new;IKVM0147when some classes compile;module-info.classandMETA-INF/versions/entries.IKVM.TestsorIKVM.Tools.Importer.Testslocally: buildingIKVM.Javaneeds theorg.ikvm:java-ref-pluginartifact from GitHub Packages, and the request returned 401 without CI's token. Instead I checked by hand:IKVM.Runtimefrom this branch against the 8.16.2 package'sIKVM.Java.dlland swapped it into a console app on that package.UnsupportedClassVersionError: 55.0, a version 255 class givesClassFormatError: Unsupported class version 255.0., and the 45.0/45.2 classes giveUnsupportedClassVersionError: 45.0/45.2.ikvmcfrom this branch and frommainand ran both against the 8.16.2 libraries, using realjavacoutput.java11.jar(3 classes at Java 11, 1 at Java 17) onmain:mixed.jar(a Java 8 class, a Java 9module-info, and Java 11 classes underMETA-INF/versions/11):mainwarns four times; this branch produces no output, compilesp.E, and keeps the versioned entries in the embedded jar. A jar containing the 45.0p.Oldnow compiles without warnings.main, which moved class file parsing intoIKVM.CoreLib. After the merge,IKVM.CoreLib(with itsLinkingtests),IKVM.Tools.ImporterandIKVM.Runtime(against the 8.16.3IKVM.Java.dll) build, and the CoreLib tests pass.IKVM.Tools.ExporterandIKVM.Runtime-refbuild.