A bit of fun with duck typing in Java.

February 13, 2009

This is just a bit of fun I had in Java based on some of the ideas we’ve been coming up with on Chem4Word in C#.

The basic idea is to implement “kind-of” duck typing in statically typed languages. That is, you might want to define an interface, see whether object classes already implement it, and if they do, you can pretend they implemented that interface when they were written. It’s a possibly correct, certainly naiive implementation, but it illustrates generic methods and a corner of the reflection API, so it might be instructive to some.