Skip to content

Commit

Permalink
Catch more specific ByteCode errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jul 5, 2024
1 parent ff6e924 commit 5d75108
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/IKVM.Tools.Importer/CompilerClassLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Jeroen Frijters
using System.Xml.Linq;

using IKVM.Attributes;
using IKVM.ByteCode;
using IKVM.ByteCode.Reading;
using IKVM.Reflection;
using IKVM.Reflection.Emit;
Expand Down Expand Up @@ -274,26 +275,37 @@ private RuntimeJavaType PeerLoad(string name)

private RuntimeJavaType GetTypeWrapperCompilerHook(string name)
{
RemapperTypeWrapper rtw;
if (remapped.TryGetValue(name, out rtw))
if (remapped.TryGetValue(name, out var rtw))
{
return rtw;
}
else
{
Jar.Item itemRef;
if (classes.TryGetValue(name, out itemRef))
if (classes.TryGetValue(name, out var itemRef))
{
classes.Remove(name);

ClassFile f;
try
{
f = new ClassFile(Context, ClassReader.Read(itemRef.GetData()), name, ClassFileParseOptions, null);
}
catch (ClassFormatError x)
catch (UnsupportedClassVersionException e)
{
Context.StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
Context.StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
Context.StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, e.Message);
return null;
}
catch (ByteCodeException e)
{
Context.StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
Context.StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, e.Message);
return null;
}
catch (ClassFormatError e)
{
Context.StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
Context.StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, e.Message);
return null;
}

Expand Down

0 comments on commit 5d75108

Please sign in to comment.