Jens Dietrich (MSc and a PhD in Mathematics from the University of Leipzig) visited melbJvm meetup at 8th of September, 2014. He explained about his research topic "Compatibility and API Evolution". It was really interesting and here are some major points which was discussed on this topic.
Programs not developing from scratch means, most of the programs using libraries , frameworks , ects and they compose using APIs which are providing by libraries. There are few points need to consider when updating APIs in libraries.
Programs not developing from scratch means, most of the programs using libraries , frameworks , ects and they compose using APIs which are providing by libraries. There are few points need to consider when updating APIs in libraries.
Will the programs work when re-compile with new library ? or is it possible to replace the new library without compile?
So compatibility is coming this place and there are three type of compatibility issues may occur when updating libraries.
- Source compatibility - Program is source compatible with library if Program can be compiled with that library(ex lib-2.0.jar)
- Binary compatibility - Program is binary compatible with library if Program can be linked with that library without recompile
- Behavioural compatibility - Behavioural compatibility includes the semantics of the code that is executed at runtime
Following are the practical definition for Source vs Binary compatibility
A program is source compatible with a library lib.jar if the program uses the library, and compilation succeeds: javac -cp ..,lib.jar,.. …
A program is binary compatible with a library lib.jar if it links and runs with this library: java -cp ..,lib.jar,..
Source compatibility is checked by the compiler and binary compatibility is checked by the JVM
Examples for Source vs Binary compatibility
- Adding a Method to an Interface
Both source and binary compatible
- Removing a Method from an Interface
Binary compatible and source incompatible. Because recompilation fails as Main.bar() does not override a method!
- Specialising Return Types
Binary incompatible but source compatible
- Generalising Parameter Types
Binary incompatible but source compatible
- Change a Method from Static to Non-Static
Both source and binary incompatible. what will be for "Change a Method from Static to Non-Static" ?
- Primitive vs Wrapper Types
Binary incompatible but source compatible
- Generics
Binary compatible but source incompatible
- Constants
Binary compatibility but binary behavioural incompatible
- Adding a Runtime Exception
Source compatible,s binary compatible and binary behavioural incompatible
- Adding a Checked Exception
Source incompatible,binary compatible and binary behavioural incompatible
You can find more scenarios in following Jens Dietrich's video lecture at meljvm
slides to download : Link 1