[jsword-devel] Java conundrum

Martin Denham mjdenham at gmail.com
Sat May 4 02:34:43 MST 2013


Here is an interesting problem (based on VerseRangeTest.java):

    private VerseRange gen_all = ...;

    public void testKeyContainsVerse() {
        // this passes
        assertTrue(gen_all.contains(gen11));

        // this fails
        Key gen_allKey = gen_all;
        assertTrue(gen_allKey.contains(gen11));
    }

This caught me out for a while.  I think the second assert should pass but
Key is an interface with a single non-overloaded contains():
    boolean contains(Key key);

Whereas VerseRange contains overloaded methods like contains(Verse) that
are not called because the Key interface is being used.  At least that is
what I think is happening.

Is this a bug?

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20130504/d9811e2a/attachment.html>


More information about the jsword-devel mailing list