Longest Class, Method and Attribute Names in Java

Last modified on August 1st, 2014 by Joe.

Just got curious to see what is the longest class name in Java JDK bundle and extended that curiosity to method and attribute names as well.

Wrote a tiny Java program to load all classes, their methods and attributes from a Jar to print their name to a file. Then ran that on JDK 1.6 (rt.jar) and got the following results.

For class name the award goes to (92 chars) InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState

For method name the award goes to (66 chars) localizableRUNTIME_MODELER_PORTNAME_SERVICENAME_NAMESPACE_MISMATCH belonging to class ModelerMessages.

For attribute name the award goes to (60 chars) ER_INVALID_NAMESPACE_URI_VALUE_FOR_RESULT_PREFIX_FOR_DEFAULT belonging to class XSLTErrorResources.

Hope you are following naming conventions strictly in your projects. I welcome you to run this below program on your project or your favorite packages like Spring / Hibernate etc and share your interesting findings in the comments.

This Java program will print all the class, method and attribute names from the Jar file, sorted in descending order of length.