JaroslavTulach at 06:48, 11 October 2010 - 2010-10-11 06:48:44

←Older revision Revision as of 06:48, 11 October 2010
Line 1: Line 1:
-
The [[chapter 6]] discusses '''protected abstract''' methods and says that removing such method is source compatible (page 89). In fact that was true until [[Java]] 5 appeared. However the newly introduced ''@Override'' [[annotation]] changed everything.
+
 
 +
==== [[Errata 6|Page 89]] ====
 +
 
 +
The [[chapter 6]] discusses '''protected abstract''' methods and says that removing such method is source compatible. In fact that was true until [[Java]] 5 appeared. However the newly introduced ''@Override'' [[annotation]] changed everything.
<source lang="java" snippet="anagram.ui.Anagrams"/>
<source lang="java" snippet="anagram.ui.Anagrams"/>

JaroslavTulach at 06:46, 11 October 2010 - 2010-10-11 06:46:27

←Older revision Revision as of 06:46, 11 October 2010
Line 12: Line 12:
-- Rijk van Haaften, Oct 8, 2010
-- Rijk van Haaften, Oct 8, 2010
 +
 +
==== [[Errata 6|Page 90]] ====
 +
 +
In the example of defining inserting new super class into existing class hierarchy, the whole source code should have been shown. The newly created ''SimpleHelloClass'' should define no argument method. The original ''HelloClass'' shall extend it and keep definition of the more complicated ''sayHelloTo'' method with one string argument:
 +
<source lang="java" snippet="design.insert.superclass1"/>
 +
<source lang="java" snippet="design.insert.superclass2"/>
 +
 +
[[User:Cordeo|Cordeo]] 21:47, 7 October 2010 (UTC)

JaroslavTulach at 07:39, 8 October 2010 - 2010-10-08 07:39:31

←Older revision Revision as of 07:39, 8 October 2010
Line 1: Line 1:
-
The [[chapter 6]] discusses '''protected abstract''' methods and says that removing such method is source compatible (page 89). In fact that was true until [[Java]] 5 appeared. However with the newly introduced ''@Override'' annotation this is no longer true.
+
The [[chapter 6]] discusses '''protected abstract''' methods and says that removing such method is source compatible (page 89). In fact that was true until [[Java]] 5 appeared. However the newly introduced ''@Override'' [[annotation]] changed everything.
<source lang="java" snippet="anagram.ui.Anagrams"/>
<source lang="java" snippet="anagram.ui.Anagrams"/>

JaroslavTulach: New page: The chapter 6 discusses '''protected abstract''' methods and says that removing such method is source compatible (page 89). In fact that was true until Java 5 appeared. However wit... - 2010-10-08 07:38:52

New page: The chapter 6 discusses '''protected abstract''' methods and says that removing such method is source compatible (page 89). In fact that was true until Java 5 appeared. However wit...

New page

The [[chapter 6]] discusses '''protected abstract''' methods and says that removing such method is source compatible (page 89). In fact that was true until [[Java]] 5 appeared. However with the newly introduced ''@Override'' annotation this is no longer true.

<source lang="java" snippet="anagram.ui.Anagrams"/>

If you create a new version of public abstract class ''Anagrams'' dropping
either getWordLibrary or getScrambler (or both), the @Override annotation in
AnagramsWithConstructor will cause the compiler to complain:

<source lang="java" snippet="anagram.ui.init"/>

Source compatibility is gone. As an [[API]] designer of public class Anagrams you don't know whether your users (writing class ''AnagramsWithConstructor'') will use @Override. As a result don't even try to remove '''protected abstract''' methods from an [[API]]. It was never good idea anyway and since [[Java]] 5 it is not [[backward compatible]].

-- Rijk van Haaften, Oct 8, 2010