Created
January 7, 2016 06:32
-
-
Save JakeWharton/5b3dbbc54c779a6bc6af to your computer and use it in GitHub Desktop.
Unlike synthetic accessor methods, these synthetic covariant methods are hard or impossible to kill. Generics anyone?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Thing<T> { | |
T thing(); | |
} | |
class CharSequenceThing implements Thing<CharSequence> { | |
@Override public CharSequence thing() { | |
return "CharSequence!"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ javap -p Thing CharSequenceThing | |
Compiled from "GenericCovariants.java" | |
interface Thing<T> { | |
public abstract T thing(); | |
} | |
Compiled from "GenericCovariants.java" | |
class CharSequenceThing implements Thing<java.lang.CharSequence> { | |
CharSequenceThing(); | |
public java.lang.CharSequence thing(); | |
public java.lang.Object thing(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment