Last active
August 29, 2015 14:27
-
-
Save jsyeo/f3eaf6a92d866ea82864 to your computer and use it in GitHub Desktop.
Implement Parameterized Interface
This file contains hidden or 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 Main { | |
| public static void main(String[] args) { | |
| // Our code doesn't call the vulnerable method at all | |
| } | |
| } | |
| /* | |
| * This is our vulnerable class | |
| */ | |
| class MyImplementer implements MyInterface<Integer> { | |
| /* | |
| After type erasure, the compiler will insert a bridge method that looks like this: | |
| public void vulnerableMethod(Object o) { | |
| vulnerableMethod( (Integer) o ); | |
| } | |
| This is so that the method that takes in an Integer still implements the right method | |
| after the type erasure phase. | |
| This method will be insert at the line where the MyImplementer class is declared. | |
| See https://docs.oracle.com/javase/tutorial/java/generics/bridgeMethods.html | |
| */ | |
| @Override | |
| public void vulnerableMethod(Integer i) { | |
| } | |
| } | |
| interface MyInterface<T> { | |
| void vulnerableMethod(T t); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Though our code didn't call the vulnerable method at all, there will still be a call site at line 11.