Longest Java Class Name

Back in 1996 when I was writing the first edition of Java in a Nutshell, the book designers on the production team at O'Reilly need to know the longest class name so they could make sure it would fit in the title of reference entries. At the time it was StringIndexOutOfBoundsException at 31 characters. Tonight, I wondered if that record still stood...

So I used find, echo wc, grep, sed, and sort (isn't Unix great?) to process the filenames in the javadoc directory of J2SE 1.4.2 and find out what the longest class name is. I did not count the length of the package name, nor did I include inner classes in my count research. StringIndexOutOfBoundsException is still the longest class in java.lang, but it is matched in length by java.util.ConcurrentModificationException, and exceeded by 16 classes in less commonly used packages.

The longest of all, standing alone at 36 finger-fatiguing characters is javax.xml.transform.TransformerFactoryConfigurationError. The complete list of class names >= 30 characters is at the end of this post.

And what about short class names?

The shortest classnames have three characters and are mostly acronyms, such as the familiar java.net.URL. Two that are not acronyms are the simple and elegant Set and Map classes of java.util.

The longest class names are:

36 javax.xml.transform.TransformerFactoryConfigurationError     
35 javax.naming.AuthenticationNotSupportedException     
35 javax.naming.directory.InvalidAttributeIdentifierException     
34 java.awt.ContainerOrderFocusTraversalPolicy     
34 java.beans.beancontext.BeanContextServiceProviderBeanInfo     
34 java.security.InvalidAlgorithmParameterException     
34 org.omg.PortableInterceptor.ClientRequestInterceptorOperations     
34 org.omg.PortableInterceptor.ServerRequestInterceptorOperations     
34 org.omg.PortableServer.ImplicitActivationPolicyOperations     
33 java.beans.beancontext.BeanContextServiceRevokedListener     
33 java.util.prefs.InvalidPreferencesFormatException     
33 javax.swing.InternalFrameFocusTraversalPolicy     
33 javax.xml.transform.TransformerConfigurationException     
33 org.omg.PortableServer.RequestProcessingPolicyOperations     
32 java.beans.beancontext.BeanContextServiceAvailableEvent     
32 org.omg.PortableServer.ServantRetentionPolicyOperations     
31 java.awt.geom.NoninvertibleTransformException     
31 java.lang.StringIndexOutOfBoundsException     
31 java.nio.channels.UnsupportedAddressTypeException     
31 java.security.cert.CertificateNotYetValidException     
31 java.util.ConcurrentModificationException     
31 javax.naming.ldap.UnsolicitedNotificationListener     
31 javax.security.cert.CertificateNotYetValidException     
31 javax.swing.UnsupportedLookAndFeelException     
30 java.awt.IllegalComponentStateException     
30 java.awt.image.renderable.ContextualRenderedImageFactory     
30 java.beans.beancontext.BeanContextChildComponentProxy     
30 java.beans.beancontext.BeanContextServiceRevokedEvent     
30 java.lang.ArrayIndexOutOfBoundsException     
30 java.security.AlgorithmParameterGeneratorSpi     
30 java.security.spec.RSAMultiPrimePrivateCrtKeySpec     
30 javax.naming.InsufficientResourcesException     
30 javax.naming.OperationNotSupportedException     
30 javax.naming.directory.AttributeModificationException     
30 javax.naming.directory.InvalidAttributeValueException     
30 javax.naming.directory.InvalidSearchControlsException     
30 javax.transaction.TransactionRolledbackException     
30 org.omg.IOP.MultipleComponentProfileHelper     
30 org.omg.IOP.MultipleComponentProfileHolder     

And the shortest names are

3 java.net.URI      
3 java.net.URL      
3 java.rmi.dgc.DGC      
3 java.rmi.server.UID      
3 java.security.Key      
3 java.security.acl.Acl      
3 java.security.cert.CRL      
3 java.sql.Ref      
3 java.util.Map      
3 java.util.Set      
3 javax.crypto.Mac      
3 javax.print.Doc      
3 javax.rmi.CORBA.Tie      
3 javax.swing.Box      
3 javax.swing.text.html.CSS      
3 javax.swing.text.html.parser.DTD      
3 javax.transaction.xa.Xid      
3 org.ietf.jgss.Oid      
3 org.omg.CORBA.Any      
3 org.omg.CORBA.ORB      
3 org.omg.CORBA_2_3.ORB      
3 org.omg.IOP.IOR      
3 org.omg.PortableServer.POA      

Books

Comprehensive coverage of Ruby 1.8 and 1.9

"The New Most Important Ruby Book"
Peter Cooper,
rubyinside.com

Completely updated for Ajax and Web 2.0

"A must-have reference"
Brendan Eich,
creator of JavaScript

The classic Java quick-reference