Setter methods for final fields

前端 未结 3 2063
悲哀的现实
悲哀的现实 2020-12-30 22:54

Using reflection and also from the src.zip available in the installed JDK by the installer purveyed by http://docs.oracle.com, I found the following fields of java.la

3条回答
  •  清歌不尽
    2020-12-30 23:24

    in the source code, they are not reassigning for example out variable in the setOut() method

    public static void setOut(PrintStream out) {
     checkIO();
     setOut0(out);
    }
    

    they send the passed stream to native code, and that code is responsible to set that stream for current use. So final variable is not being re-set and this variable is not used in native code, whatever stream it passes to native code , it uses that

提交回复
热议问题