Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

i'm not much of a java programmer

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!!!!!";
    }
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 12 comments