Enums Implementing Interface Are Rejected By Verifier (java.lang.verifyerror)
I'm using enums for units of different physical quantities, like meter and miles for the DISTANCE. To use them in a generic way there is an interface Unit which has the method conv
Solution 1:
This part seems key:
returning 'Reference: java.lang.Enum[]', but expected from declaration 'Reference: com.example.app.Unit[]
So you are returning an enum array when you should be returning a unit array. Change either the return type of the method, or simply pack the DistanceUnit values into a list to fix the problem.
I would recommend using List<Unit>
as your return type instead of Unit[]
. See this for reference. To do so, call Arrays.asList(DistanceUnit.values())
when instantiating your list.
Solution 2:
Just looked into the stacktrace a little more and it says:
returning 'Reference: Enum[]', but expected from declaration 'Reference: Unit[]'
in getAllUnits()
Casting the returned enums of getAllUnits()
to Unit[]
manually fixed the issue although there is a hint:
Casting 'DistanceUnit.values()' to 'Unit[]'is redundant
Post a Comment for "Enums Implementing Interface Are Rejected By Verifier (java.lang.verifyerror)"