alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (Test3.java)

This example Java source code file (Test3.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

list, serializable, util

The Test3.java Java example source code

/**
 * @test     /nodynamiccopyright/
 * @bug      7062745 7157798
 * @summary  Negative test of conflicting same-name methods inherited from multiple interfaces when return type not compatible
 * @compile/fail/ref=Test3.out -Werror -Xlint:unchecked -XDrawDiagnostics Test3.java
 */

import java.util.List;
import java.io.Serializable;

interface A { int m(); }
interface B { Integer m(); }

interface AB extends A, B {} //error

interface C { List<Integer> m(); }
interface D { List<Number> m(); }

interface CD extends C, D {} //error

interface E<T> { T m(); }
interface F<T> { T m(); }
interface G { Serializable m(); }

interface BE extends B, E<Number> {} //ok, covariant return

interface BE2<T> extends B, E {} //error

interface EF<T> extends E, F {} //ok

interface EF2<U, V extends U> extends E, F {} //ok, covariant return

interface EF3<U, V> extends E, F {} //error

interface EG<T extends Number> extends E, G {} //ok

interface EFG<U extends Serializable, V extends Serializable> extends E, F, G {} //error

Other Java examples (source code examples)

Here is a short list of links related to this Java Test3.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.