Created
September 24, 2015 15:30
-
-
Save chochos/15bef4512edc0d25f9ce to your computer and use it in GitHub Desktop.
Skip `final` in Java
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 java.lang.reflect.*; | |
public class Skip { | |
public final String s; | |
public Skip(String s) { | |
this.s=s; | |
} | |
public static void main(String... args) throws Exception { | |
Skip me = new Skip("Initial"); | |
Field f = Skip.class.getField("s"); | |
f.setAccessible(true); | |
f.set(me, "p0wned!"); | |
System.out.println(me.s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment