Created
June 28, 2018 10:03
-
-
Save metebalci/ef92df99efc9b53278bb6f96c2240f77 to your computer and use it in GitHub Desktop.
JEP181
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.Field; | |
public class JEP181 { | |
public static class Nest1 { | |
private int varNest1; | |
public void f() throws Exception { | |
final Nest2 nest2 = new Nest2(); | |
// this is ok | |
nest2.varNest2 = 2; | |
// this is not ok | |
final Field f2 = Nest2.class.getDeclaredField("varNest2"); | |
f2.setInt(nest2, 2); | |
} | |
} | |
public static class Nest2 { | |
private int varNest2; | |
} | |
public static void main(String[] args) throws Exception { | |
new Nest1().f(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment