Looking to modify the return value of a method that is calling from an enum type. I am able to call the method and properly display the enum value into console, but then it crashes the application complaining on a compatible implementation. Example code below with error:
Java.perform(() => {
const Class = Java.use('com.package.class');
Class.getMethod.implementation = function() {
 
var str = this.getMethod();
 
send('getMethod() value for enum is: ' + str);
 
};
});
[Pixel 5::com.package ]-> message: {'type': 'send', 'payload': 'getMethod() value for enum is: EnumContent'} data: None
Error: Implementation for getMethod expected return value compatible with [Lcom.com.package.EnumType;
    at ne (frida/node_modules/frida-java-bridge/lib/class-factory.js:674)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/class-factory.js:651)
Process terminated
My final goal is to obtain the initial enum value, change the enum return value ingested by the method and display the results in console.
I found a few reference here: https://github.com/frida/frida/issues/1256 and here: https://neo-geo2.gitbook.io/adventures-on-security/frida-scripting-guide/enums but was ultimately unsuccessful in helping.
Edit: To elaborate with an example. Say you are attempting to use JS script like below with return or console.log:
Java.perform(() => {
var enumContent = Java.use('com.some.package.Enum');
return enumContent.values();
)};
or
Java.perform(() => {
var enumContent = Java.use('com.some.package.Enum');
console.log(enumContent.A.value);
)};
Assuming your Java code looks like this:
package com.some.package;
import kotlin.Metadata;
public enum Enum {
    A,
    B,
    C,
    D
}
Edit 2:
Here is a snippet of that class.
package com.package.class;
[TRUNCATED]
...
[TRUNCATED]
    @NotNull
    public final Enum[] getMethod() {
        return this.selection;
    }
}