Java Topology Suite
An excelent implementation of spatial relationships (that are valid and stable).
From the JTS Website
The JTS Topology Suite is an API of 2D spatial predicates and functions. It has the following design goals:
- JTS conforms to the [GEOTOOLS:Simple Features Specification for SQL] published by the OGC
- JTS provides a complete, consistent, robust implementation of fundamental 2D spatial algorithms
- JTS is fast enough for production use
- JTS is written in 100% pure JavaTM
- JTS is open source (under the LGPL license)
Links: