Sometimes I look into Java platform libraries for inspiration. There are plenty of good design solutions there, see this question for example. However there are anomalies as well that should not be emulated. Some of them are given in the book Effective Java, Second Edition by Joshua Bloch, for example constant interfaces such as java.io.ObjectStreamConstants or the behaviour of the equals method in java.net.URL. What other examples of such anomalies in the Java platform libraries do you know? Please give as many as possible.
Sometimes I look into Java platform libraries for inspiration. There are plenty of good
Share
The close() method declaring to throw IOException which probably no sane implementation throws. And if ever thrown, it is very impossible to write a finally block that handle that correctly.
java.util.Enumeration and java.util.Iterator are essentially the same thing.
java.util.Vector, java.util.Hashtable and java.util.Dictionary should be deprecated.
Object.clone() and the Cloneable interface are horrible and haves a lot of problems.
javax.swing.table.DefaultTableModel is evil.
java.io.Serializable defines a strange special contract with optional private readObject() and writeObject() methods.
java.util.Observable should never be used.
The finalize() method is an anomaly and should be avoided as much as possible.
All the date/time API is very badly designed. java.util.Date ended having almost all of it’s methods deprecated. java.util.Calendar has an horrible get(int) and set(int, int) method taking an integer identifying the field, instead of proper defined getters and setters. java.sql.Date and java.sql.Timestamp extends java.util.Date in the worst manner possible: The documentation explicitly tell that it extends but should not be considered a IS-A relationship (which is really bad, since extension purpose is to define an IS-A relationship). Further, some methods of java.sql.Date overriden form java.util.Date throws exceptions breaking the superclass contract and failing Liskov Substitution Principle (which the authors probably did not cared too much, since they did not wanted an IS-A relationship).