Locking on a String literal
synchronized("one") { /* block one A*/ }
synchronized("one") { /* block one B*/ }
Very long class names. (in the JRE)
com.sun.java.swing.plaf.nimbus.
InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Poor inheritance structure
com.sun.corba.se.internal.Interceptors.PIORB extends
com.sun.corba.se.internal.POA.POAORB extends
com.sun.corba.se.internal.iiop.ORB extends
com.sun.corba.se.impl.orb.ORBImpl extends
com.sun.corba.se.spi.orb.ORB extends
com.sun.corba.se.org.omg.CORBA.ORB extends
org.omg.CORBA_2_3.ORB extends
org.omg.CORBA.ORB
An Exception which is not.
public interface FlavorException { }
Pointless and cryptic error handling
if (properties.size() > 10000)
System.exit(0);
Unnecessary creation of objects
Class clazz = new Integer(0).getClass();
int num = new Integer(text).intValue();
Throwing an exception for other purposes
try {
Integer i = null;
Integer j = i.intValue();
} catch (NullPointerException e) {
System.out.println("Entering "+e.getStackTrace()[0]);
}
Using instance objects for static methods.
Thread.currentThread().sleep(100);
Synchronizing on a non-final field
synchronized(list) {
list = new ArrayList();
}
Pointless copy of a constant String
String s = new String("Hello world");
Pointless call to String.toString()
String s = "Hello";
String t = s.toString() + " World";
Calls to System.gc() to free some memory
Setting local variable to null to free some memory
// list is out of scope anyway.
list = null;
}
Using ++i instead of i++ for performance reasons (or any other micro-micro-optimisation)