A DESCRIPTION OF THE PROBLEM :
Having an interface that elevates "clone()" to public visibility, using that interface in a Generics multiple-extension declaration does not compile, eg:
<T extends CloneInterface & Cloneable>
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation succeeds
ACTUAL -
WontCompile.java:8: error: clone() in Object cannot implement clone() in WontCompile
static <T extends WontCompile & Cloneable> T identity(T t) {
^
attempting to assign weaker access privileges; was public
---------- BEGIN SOURCE ----------
package compilethis;
public interface WontCompile {
// Force it to public
WontCompile clone();
static <T extends WontCompile & Cloneable> T identity(T t) {
return t;
}
}
---------- END SOURCE ----------
FREQUENCY : always
Having an interface that elevates "clone()" to public visibility, using that interface in a Generics multiple-extension declaration does not compile, eg:
<T extends CloneInterface & Cloneable>
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation succeeds
ACTUAL -
WontCompile.java:8: error: clone() in Object cannot implement clone() in WontCompile
static <T extends WontCompile & Cloneable> T identity(T t) {
^
attempting to assign weaker access privileges; was public
---------- BEGIN SOURCE ----------
package compilethis;
public interface WontCompile {
// Force it to public
WontCompile clone();
static <T extends WontCompile & Cloneable> T identity(T t) {
return t;
}
}
---------- END SOURCE ----------
FREQUENCY : always