fork(1) download
  1. import java.lang.reflect.Field;
  2.  
  3. class X {
  4. public static boolean fieldName = false;
  5. }
  6.  
  7. class Allocator {
  8. public static void allocate(Class c) throws Exception {
  9. Field field = c.getDeclaredField("fieldName");
  10. field.set(null, true /* новое значение */);
  11. }
  12. }
  13.  
  14. public class Main {
  15. public static void main(String[] args) throws Exception {
  16. System.out.println(X.fieldName);
  17. Allocator.allocate(X.class);
  18. System.out.println(X.fieldName);
  19. }
  20. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
false
true