Enum exeeding the 65535 bytes limit of static initializer... what's best to do?

Posted by Daniel Bleisteiner on Stack Overflow See other posts from Stack Overflow or by Daniel Bleisteiner
Published on 2010-03-30T15:28:49Z Indexed on 2010/03/30 15:43 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

I've started a rather large Enum of so called Descriptors that I've wanted to use as a reference list in my model. But now I've come across a compiler/VM limit the first time and so I'm looking for the best solution to handle this.

Here is my error : The code for the static initializer is exceeding the 65535 bytes limit

It is clear where this comes from - my Enum simply has far to much elements. But I need those elements - there is no way to reduce that set.

Initialy I've planed to use a single Enum because I want to make sure that all elements within the Enum are unique. It is used in a Hibernate persistence context where the reference to the Enum is stored as String value in the database. So this must be unique!

The content of my Enum can be devided into several groups of elements belonging together. But splitting the Enum would remove the unique safety I get during compile time. Or can this be achieved with multiple Enums in some way?

My only current idea is to define some Interface called Descriptor and code several Enums implementing it. This way I hope to be able to use the Hibernate Enum mapping as if it were a single Enum. But I'm not even sure if this will work. And I loose unique safety.

Any ideas how to handle that case?

© Stack Overflow or respective owner

Related posts about java

Related posts about enum