вівторок, 24 травня 2011 р.

Evil Java

Шикарний пост, шикарний код, я счітаю:))

http://thedailywtf.com/Articles/Disgruntled-Bomb-Java-Edition.aspx Alexander Keul took advantage of Java's cached boxing conversions to come up with this concept: package dont.try_this.at_home; import java.lang.*; class ValueMunger extends Thread { public void run() { while(true) { munge(); try { sleep(1000); } catch (Throwable t) { } } } public void munge() { try { Field field = Integer.class.getDeclaredField( "value" ); field.setAccessible( true ); for(int i = -127; i<=128; i++) field.setInt( Integer.valueOf(i), // either the same (90%), +1 (10%), or 42 (1%) Math.random() < 0.9 ? i : Math.random() < 0.1 ? 42 : i+1 ); } catch (Throwable t) { ; } } }

1 коментар: