Pass by reference: final and effectively final parameters and qualifying return types

Remi Forax forax at univ-mlv.fr
Tue Jan 5 09:12:10 UTC 2021


----- Mail original -----
> De: "Suminda Sirinath Salpitikorala Dharmasena" <sirinath1978m at gmail.com>
> À: "valhalla-dev" <valhalla-dev at openjdk.java.net>
> Envoyé: Mardi 5 Janvier 2021 08:45:55
> Objet: Pass by reference: final and effectively final parameters and qualifying return types

> Hello,
> 
> Java unlike C# does not have `ref` parameters. Reference parameters
> contribute to some of the recent speedups as highlighted in this post:
> https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-5/.
> 
> So is it possible to automatically convert qualifying parameters and return
> types in refs.
> 
> Final and effectively final parameters and also certain return types can
> also be converted into refs.
> 
> A language change is not needed as this is done by the compiler/JVM, though
> further language change can be done to accommodate this.

Hello,
reference parameters, out parameters, are hard to optimize because of pointer aliasing [1].
C# inherits them from the COM runtime model, so has to deal with them.

Java does not have them by design. Java uses a pass by value semantics which leads to better code.

regards,
Rémi

> 
> Suminda

[1] https://en.wikipedia.org/wiki/Pointer_aliasing


More information about the valhalla-dev mailing list