From 8fd37569453a3889205c22f1547e0609545cab4a Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Tue, 24 Oct 2023 10:17:57 -0500 Subject: [PATCH 1/4] Recursive call on accident. --- src/IKVM.Tools.Importer/StaticCompiler.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/IKVM.Tools.Importer/StaticCompiler.cs b/src/IKVM.Tools.Importer/StaticCompiler.cs index f999c12450..5ac4b49161 100644 --- a/src/IKVM.Tools.Importer/StaticCompiler.cs +++ b/src/IKVM.Tools.Importer/StaticCompiler.cs @@ -25,12 +25,9 @@ Jeroen Frijters using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.IO.Pipelines; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; -using System.Security.Cryptography.Xml; using IKVM.Reflection; using IKVM.Runtime; @@ -223,7 +220,7 @@ internal void SuppressWarning(CompilerOptions options, Message message, string n internal void IssueMessage(Message msgId, params string[] values) { - IssueMessage(msgId, values); + IssueMessage(rootTarget, msgId, values); } internal void IssueMessage(CompilerOptions options, Message msgId, params string[] values) From 03ec8b04fb022219b08007f024a34db69820fa7e Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Mon, 30 Oct 2023 12:56:56 -0500 Subject: [PATCH 2/4] Cap assembly version components at 65535. Not a great solution, but it's good enough for now. --- src/IKVM.MSBuild.Tasks/IkvmReferenceItemPrepare.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/IKVM.MSBuild.Tasks/IkvmReferenceItemPrepare.cs b/src/IKVM.MSBuild.Tasks/IkvmReferenceItemPrepare.cs index 448dd6a617..2fedec3e22 100644 --- a/src/IKVM.MSBuild.Tasks/IkvmReferenceItemPrepare.cs +++ b/src/IKVM.MSBuild.Tasks/IkvmReferenceItemPrepare.cs @@ -442,8 +442,8 @@ static Version ToAssemblyVersion(ModuleVersion version) // only include major and minor by default var major = GetAssemblyVersionComponent(version, 0); var minor = GetAssemblyVersionComponent(version, 1); - if (minor is not null && major is not null) - return new Version(major ?? 0, minor ?? 0, 0, 0); + if (major is not null) + return new Version((int)major, minor ?? 0, 0, 0); return null; } @@ -456,7 +456,7 @@ static Version ToAssemblyVersion(ModuleVersion version) /// static int? GetAssemblyVersionComponent(ModuleVersion version, int index) { - return version.Number.Count > index && version.Number[index] is int i ? i : null; + return version.Number.Count > index && version.Number[index] is int i ? Math.Min(i, ushort.MaxValue) : null; } /// From bb52ee9f8e7676c74e16b2bdc782ff2c3eb2ecdf Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Mon, 30 Oct 2023 14:03:25 -0500 Subject: [PATCH 3/4] Incorrectly reading the TypeArgumentIndex as a U2 (short) instead of as a U1 (byte). Defined at https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.20 Fixes #438 --- .../Parsing/TypeAnnotationTypeArgumentTargetRecord.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IKVM.ByteCode/Parsing/TypeAnnotationTypeArgumentTargetRecord.cs b/src/IKVM.ByteCode/Parsing/TypeAnnotationTypeArgumentTargetRecord.cs index 69eb461987..bc0f3453b0 100644 --- a/src/IKVM.ByteCode/Parsing/TypeAnnotationTypeArgumentTargetRecord.cs +++ b/src/IKVM.ByteCode/Parsing/TypeAnnotationTypeArgumentTargetRecord.cs @@ -1,7 +1,7 @@ namespace IKVM.ByteCode.Parsing { - internal sealed record TypeAnnotationTypeArgumentTargetRecord(ushort Offset, ushort TypeArgumentIndex) : TypeAnnotationTargetRecord + internal sealed record TypeAnnotationTypeArgumentTargetRecord(ushort Offset, byte TypeArgumentIndex) : TypeAnnotationTargetRecord { public static bool TryRead(ref ClassFormatReader reader, out TypeAnnotationTargetRecord targetInfo) @@ -10,7 +10,7 @@ public static bool TryRead(ref ClassFormatReader reader, out TypeAnnotationTarge if (reader.TryReadU2(out ushort offset) == false) return false; - if (reader.TryReadU2(out ushort typeArgumentIndex) == false) + if (reader.TryReadU1(out byte typeArgumentIndex) == false) return false; targetInfo = new TypeAnnotationTypeArgumentTargetRecord(offset, typeArgumentIndex); @@ -25,7 +25,7 @@ public override int GetSize() { var length = 0; length += sizeof(ushort); - length += sizeof(ushort); + length += sizeof(byte); return length; } @@ -38,7 +38,7 @@ public override bool TryWrite(ref ClassFormatWriter writer) { if (writer.TryWriteU2(Offset) == false) return false; - if (writer.TryWriteU2(TypeArgumentIndex) == false) + if (writer.TryWriteU1(TypeArgumentIndex) == false) return false; return true; From e4ff2051f79fc0849223e953f257ca37e2a0f854 Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Mon, 30 Oct 2023 16:13:37 -0500 Subject: [PATCH 4/4] Adjust some broken links on old MD files. --- doc/legacy/tools/ikvmc.md | 18 +++++++++--------- src/ikvmc/ikvmc.csproj | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/legacy/tools/ikvmc.md b/doc/legacy/tools/ikvmc.md index 68056cd23e..15b1e29bbd 100644 --- a/doc/legacy/tools/ikvmc.md +++ b/doc/legacy/tools/ikvmc.md @@ -4,14 +4,14 @@ The `ikvmc` tool converts Java bytecode to .NET DLL and EXE files. -- [Usage](#usage) -- [Options](#options) -- [Notes](#notes) -- [Examples](#examples) - - [Single jar file](#single-jar-file) - - [jar file and class files to a single exe](#jar-file-and-class-files-to-a-single-exe) - - [jar file to dll and class files to an exe](#jar-file-to-dll-and-class-files-to-an-exe) -- [Warnings](#warnings) +- [Usage] +- [Options] +- [Notes] +- [Examples] + - [Single jar file] + - [jar file and class files to a single exe] + - [jar file to dll and class files to an exe] +- [Warnings] ## Usage @@ -146,7 +146,7 @@ When processing multiple input `.jar` files that contain duplicate classes / res - When converting a Java application with `ikvmc`, for best results, list the `.jar`s on the `ikvmc` command line in the same order that they appear in the Java application's classpath. See also the concepts of [ClassLoader](../class-loader.md). -- [ikvmc messages](ikvmc-messages.md) +- [ikvmc messages] ## Examples diff --git a/src/ikvmc/ikvmc.csproj b/src/ikvmc/ikvmc.csproj index 8ff57289d0..ad17ab129b 100644 --- a/src/ikvmc/ikvmc.csproj +++ b/src/ikvmc/ikvmc.csproj @@ -1,7 +1,7 @@  Exe - net472;net6.0 + net6.0;net472 $(_SupportedToolRuntimes) true