Last active
August 29, 2015 14:26
-
-
Save raphw/2155fa0f6ce222aed562 to your computer and use it in GitHub Desktop.
Visibility bridges
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
package pkg; | |
class GenericVisibilityBridge extends GenericVisibilityBridgeBase<Void> { | |
@Override | |
public void foo(Void aVoid) { | |
System.out.println("specialized"); | |
} | |
} |
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
package pkg; | |
public class GenericVisibilityBridgeBase<T> { | |
public void foo(T t) { | |
System.out.println("generalized"); | |
} | |
} |
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
package pkg; | |
public class GenericVisibilityBridgeTarget extends GenericVisibilityBridge { | |
/* empty */ | |
} |
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
import pkg.GenericVisibilityBridgeTarget; | |
public class VisibilityBridgeError { | |
public static void main(String[] args) throws Exception { | |
GenericVisibilityBridgeTarget.class.getMethod("foo", Object.class) | |
.invoke(new GenericVisibilityBridgeTarget(), new Object[]{null}); | |
} | |
} |
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
public class VisibilityBridges { | |
public static class Foo { | |
public void foo() { | |
/* empty */ | |
} | |
} | |
static class Bar extends Foo { | |
public void bar() { | |
/* empty */ | |
} | |
} | |
public static class Qux extends Bar { | |
/* empty */ | |
} | |
public static void main(String[] args) throws Exception { | |
System.out.println(Qux.class.getMethod("foo")); | |
System.out.println(Qux.class.getMethod("bar")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment