Solved: Problems accessing enums

Hey.

I’ve recently started trying to get my jme stuff to run on android and have run into a few problems.

So far i seem to have problems with enums.



Here are two exceptions:



Here i try to use an EnumMap. Replacing it with a HashMap gets me past this:

ERROR AndroidHarness SEVERE AndroidHarness 1:14:57 PM Exception thrown in Thread[GLThread 18,5,main]: at java.lang.ClassCache.callEnumValues(573)



Here i access the values() method of an enum, for parsing.

E/AndroidHarness( 1602): SEVERE AndroidHarness 1:25:39 PM Exception thrown in Thread[GLThread 17,5,main]



I’m not sure what to make of it, but i thought i’d mention it here at least.



Cheers,

Rickard

Have you tried it with just a array with size of enum amounts and index at enum.ordinal()-1?

That would most likely work, but if possible, i’d prefer to not have to replace all my enums :stuck_out_tongue:

I’ve used enums in vanilla android so i’m pretty sure it should work.

Hm ? you do not have to change the enums for this, ordinal is always from zero to amount in enum, and a standart method of the enum class…

I thought you meant replacing the enums with arrays.



I need to access values()[some_int], which is what i’m doing when i get the exception.



Edit: Found some more stuff in the log, and it seems it’s the enum that is failing to initialize due to a missing reference. It doesn’t appear in the desktop version, so i’m not sure whether it’s due to the harness or android. But it might be solvable by shuffling some code around on my end.

Ok, i have figured out what the issue is (although i don’t understand why it happens on the android build)

My enums access a static method where they retrieve strings from a resourcebundle. I think it’s the class that the static method is in that causes a ClassDefNotFound exception, but i’m not sure.



I will have to investigate further…



Edit:

Doh. That class had some unused awt imports that naturally wouldn’t work on android. Now that problems is solved, on to the next.