Oliver Drotbohm 1/12/2009

Subtleties on java.lang.Enum

Read Original

The article details a subtle issue in Java's java.lang.Enum where using getClass() on an enum constant behaves differently for enums with abstract methods versus simple enums, causing an IllegalArgumentException. It explains the problem, provides a test case to reproduce it, and offers the correct solution using the getDeclaringClass() method as per the Java documentation.

Subtleties on java.lang.Enum

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week