evolving_java-based_apis
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| evolving_java-based_apis [2014/02/06 07:38] – yann | evolving_java-based_apis [2025/01/15 21:40] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 41: | Line 41: | ||
| * API classes (methods and constructors, | * API classes (methods and constructors, | ||
| + | The document also discusses annotations on API constituents, | ||
| + | |||
| + | Finally, the document includes several suggestions to design better API or make it easier to change them: | ||
| + | * Clients must only use published (not internal), API (even if other constituents are public); | ||
| + | * " | ||
| + | * "[A]ll gender changes involving classes, enums, interfaces, and annotation types break binary compatibility [...]"; | ||
| + | * "[A] pre-existing Client subclass of an existing implementation might still provide a pre-existing implementation [of a newly added method, by sheer luck]"; | ||
| + | * "API interfaces that Clients should implement should not include fields", | ||
| + | * " | ||
| + | * "API classes should always explicitly declare at least one constructor"; | ||
| + | * " | ||
| + | * " | ||
| + | * "Java compiler always inline the value[s] of constant fields [...] this does not meet the objective of changing the API field' | ||
| + | * "As long as the erasure looks like the corresponding declaration prior to generification, | ||
| + | * " | ||
| + | * "[T]ag all stored data with its format version number"; | ||
| + | * " | ||
| + | |||
| + | Also, the document provides the simplest, clearest explanation of Java 1.5+ type erasure mechanism, that I reproduce here for the sake of beauty: | ||
| + | |||
| + | >> A raw type is a use of a generic type without the normal type arguments. For example, " | ||
| + | >> | ||
| + | >> The term erasure is suggestive. Imagine going through your code and literally erasing the type parameters from the generic type declaration (e.g., erasing the "< | ||
evolving_java-based_apis.1391672280.txt.gz · Last modified: (external edit)
