And the longest JRE class name is…
As i was looking through the folder structure of the latest Mustang Update N, a thought occurred to me to look inside the rt.jar. There are some interesting things there, and this entry will look at the class names of Nimbus look and feel.
The Nimbus classes are located in the sun.swing.plaf.nimbus package, and as Jasper already mentioned, most of the code is generated from a designer tool. While the source code of Update N is not yet available, you can still see some quirks of the auto-generated code. Let’s run a simple utility that prints out the top ten list of JRE classes with the longest names:
92:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
91:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneIconifyButtonWindowNotFocusedState
91:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowMaximizedState
89:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneCloseButtonWindowNotFocusedState
88:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMenuButtonWindowNotFocusedState
78:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonPainter
77:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneIconifyButtonPainter
75:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneCloseButtonPainter
74:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMenuButtonPainter
61:java_beans_beancontext_BeanContextSupport_PersistenceDelegate
Restricting this list to public classes only (classes with public modifier, which can still be in internal sun packages), we get
78:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonPainter
77:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneIconifyButtonPainter
75:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneCloseButtonPainter
74:InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMenuButtonPainter
53:OptionPaneOptionPaneMessageAreaOptionPaneLabelPainter
45:MemberSubmissionAddressingWSDLParserExtension
40:ContentHandlerAlreadyRegisteredException
40:SQLIntegrityConstraintViolationException
40:SocketFactoryContactInfoListIteratorImpl
39:SpinnerSpinnerFormattedTextFieldPainter
Obviously, the class name length has nothing to do with the functionality itself. It just shows how easy it is to overlook something when you’re auto-generating code.
Going a little back to Mustang update 2, the first list looks like this:
61:java_beans_beancontext_BeanContextSupport_PersistenceDelegate
59:javax_swing_tree_DefaultMutableTreeNode_PersistenceDelegate
52:javax_swing_DefaultComboBoxModel_PersistenceDelegate
50:javax_swing_border_MatteBorder_PersistenceDelegate
48:java_util_AbstractCollection_PersistenceDelegate
48:javax_swing_DefaultListModel_PersistenceDelegate
47:UnsafeQualifiedStaticCharacterFieldAccessorImpl
47:java_awt_GridBagConstraints_PersistenceDelegate
47:java_awt_font_TextAttribute_PersistenceDelegate
46:javax_swing_ToolTipManager_PersistenceDelegate
and the second list looks like this
40:ContentHandlerAlreadyRegisteredException
40:SQLIntegrityConstraintViolationException
40:SocketFactoryContactInfoListIteratorImpl
38:DOM2DTMdefaultNamespaceDeclarationNode
38:FormatFlagsConversionMismatchException
38:TaggedProfileTemplateFactoryFinderImpl
37:Canonicalizer20010315ExclOmitComments
37:Canonicalizer20010315ExclWithComments
37:IEEE754FloatingPointEncodingAlgorithm
37:RelationServiceNotRegisteredException
So, what is your best example of the longest Java class name that you have ever seen? Can anybody beat 92 characters? .NET comes quite close with 86 characters :)
November 7th, 2007 at 12:53 pm
Hehe amazing. I never thought that I will find such long class names but I guess sometimes it’s necessary.
November 7th, 2007 at 4:57 pm
We have:
public class SQLDeletedItemsLookDifferentCellRenderer extends ShadeAlternateRowsTableCellRenderer
… talk about self documenting code :-)
November 7th, 2007 at 6:09 pm
We went for the simple readable class names but they have ended up being quite long. We might look into reducing them for beta if there are any issues.
November 7th, 2007 at 6:43 pm
Jasper – i doubt that there will be any issues. It just that the names are hardly readable – why not leave just the last portion (like InternalFrameTitlePaneMaximizeButtonWindowNotFocusedState). That’s still 57 characters, but at least more palatable when the code is finally opened to the general public.
November 7th, 2007 at 6:47 pm
For me, the first uberlong name doesn’t fit in the text column. Copying and pasting it elsewhere shows it in full.
Firefox 2.something, Windows Vista.
November 7th, 2007 at 7:30 pm
Ricky, this is the limitation of the WordPress theme that i’m using. It allocates 500 pixels for the content column.
November 7th, 2007 at 8:59 pm
Krill ,
The substance lookNFeel being so good and stable i wonder why it isin’t being included in the next version of the jdk (7) .. Maybe u have other plans to make it commercial in future.. ?
November 8th, 2007 at 1:23 am
I’m pretty sure nobody can beat that: http://worsethanfailure.com/Articles/Really-Descriptive-Names.aspx
The class name is “only” 62 chars longs but it holds the world record with 172 chars for a method name !!!
November 8th, 2007 at 10:36 am
Pavan,
Currently i do not have plans to make Substance commercial, nor change the license from BSD. And there are some big advantages in developing a separate project (not inside JDK). You can introduce incompatible API changes in major versions, you can have much quicker release cycles, you do not have to go through the “committee” to get your vision approved etc.
November 25th, 2007 at 12:10 pm
Mouah, what a long class name …but sometimes isn’t it useful to get a long descriptive name to avoid misunderstanding…
Well, I think a nice package’s name policy may be useful too…