evan_tech

Previous Entry Share Next Entry
Random find:
    public String getAString() {
        //get a reference to the private field value in String class.
        java.lang.reflect.Field stringValue = String.class.getDeclaredField("value");
        //make it accessible
        stringValue.setAccessible(true);
        //unsuspecting string 
        String sittingDuck = "sittingDuck!!!!!";
        //black magic happening here
        stringValue.set(sittingDuck, "hastaLaVistaBaby".toCharArray());
        //guess the output of this!
        return "sittingDuck!!!!!";
    }