Bug - Fixed Exception when trying to use kmail gui to pick an item

Irrat

Member
When attempting to attach an item to a message using the mafia GUI, an exception is thrown.

This GUI to be exact.

unknown.png

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
            KoLmafia r25808, Windows 10, Java 11.0.10
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread of KoL's
 Gameplay-Discussion forum. If you would like the KoLmafia dev team
 to look at it, please write a bug report at kolmafia.us. Include
 specific information about what you were doing when you made this
 and include this log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Oct 27 09:51:50 NZDT 2021
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 User: Irrat
 Current run: 17946
 MRU Script: Unknown
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at net.sourceforge.kolmafia.swingui.listener.InvocationListener.execute(InvocationListener.java:27)
    at net.sourceforge.kolmafia.swingui.listener.ThreadedListener.run(ThreadedListener.java:162)
    at net.sourceforge.kolmafia.RequestThread$SequencedRunnable.run(RequestThread.java:313)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lnet.sourceforge.kolmafia.AdventureResult; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lnet.sourceforge.kolmafia.AdventureResult; is in unnamed module of loader 'app')
    at net.sourceforge.kolmafia.swingui.SendMessageFrame.attachItem(SendMessageFrame.java:235)
    ... 12 more

class java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lnet.sourceforge.kolmafia.AdventureResult; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lnet.sourceforge.kolmafia.AdventureResult; is in unnamed module of loader 'app')
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lnet.sourceforge.kolmafia.AdventureResult; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lnet.sourceforge.kolmafia.AdventureResult; is in unnamed module of loader 'app')
    at net.sourceforge.kolmafia.swingui.SendMessageFrame.attachItem(SendMessageFrame.java:235)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at net.sourceforge.kolmafia.swingui.listener.InvocationListener.execute(InvocationListener.java:27)
    at net.sourceforge.kolmafia.swingui.listener.ThreadedListener.run(ThreadedListener.java:162)
    at net.sourceforge.kolmafia.RequestThread$SequencedRunnable.run(RequestThread.java:313)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

From the git history of the file in question, I expect it's related to this.


To be clear, I do run a modified version of mafia. But I don't touch this area.
 
Last edited by a moderator:

heeheehee

Developer
Staff member
Yeah, you're probably right.

Caused by: java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lnet.sourceforge.kolmafia.AdventureResult; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lnet.sourceforge.kolmafia.AdventureResult; is in unnamed module of loader 'app')
at net.sourceforge.kolmafia.swingui.SendMessageFrame.attachItem(SendMessageFrame.java:235)
 

heeheehee

Developer
Staff member
It looks like the issue is with returning Object[]s as T[] which is... not valid, even if all the stored objects are of type T.

I have a PR to just change InputFieldUtilities.multiple() to return List<T>, since it's not used anywhere else.
 

heeheehee

Developer
Staff member
r25812 should fix this when it builds (at least it did for me), or you can pull and build it yourself from head.
 
Top