Skip to content

Instantly share code, notes, and snippets.

@jsyeo
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save jsyeo/f3eaf6a92d866ea82864 to your computer and use it in GitHub Desktop.

Select an option

Save jsyeo/f3eaf6a92d866ea82864 to your computer and use it in GitHub Desktop.
Implement Parameterized Interface
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);
}
@jsyeo
Copy link
Author

jsyeo commented Aug 20, 2015

Though our code didn't call the vulnerable method at all, there will still be a call site at line 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment