Created
January 4, 2016 07:23
-
-
Save jsyeo/1395d0ec6119280bbf82 to your computer and use it in GitHub Desktop.
Two Inner Classes
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) { | |
a().evaluate(); | |
} | |
public static Expression a() { | |
final Expression e = SimpleExpression.builder(); | |
return new Expression() { | |
@Override | |
public Expression evaluate() { | |
return e.evaluate(); | |
} | |
}; | |
} | |
public static Expression b() { | |
final Expression e = SimpleExpression.builder(); | |
return new Expression() { | |
@Override | |
public Expression evaluate() { | |
return e.evaluate(); | |
} | |
}; | |
} | |
} | |
interface Expression { | |
Expression evaluate(); | |
} | |
class SimpleExpression implements Expression { | |
@Override | |
public Expression evaluate() { | |
Vuln.vulnerableMethod(); | |
return null; | |
} | |
static SimpleExpression builder() { | |
return new SimpleExpression(); | |
} | |
} | |
class Vuln { | |
static void vulnerableMethod() { | |
System.out.println("pwn"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment