How can you extend Java to introduce passing by reference?

前端 未结 10 2250
天命终不由人
天命终不由人 2020-12-24 06:19

Java is pass-by-value. How could you modify the language to introduce passing by reference (or some equivalent behavior)?

Take for example something like

<         


        
10条回答
  •  别那么骄傲
    2020-12-24 07:23

    Answering you question about how to extend the language my pick would be: - Using various holders technics as several other answers describe - Use annotations to attach metadata regarding which arguments should be passed by reference and then start juggling with a byte code manipulation library, like cglib in order to fulfil your ideas in byte code itself.

    Though this whole idea seems strange.

提交回复
热议问题