Runtime.currentRuntime
David Holmes
david.holmes at oracle.com
Sun Nov 29 04:02:52 UTC 2015
On 28/11/2015 9:37 PM, Doug Lea wrote:
>
> Does anyone know why the static singleton in java.lang.Runtime is
> not declared as final?
>
> public class Runtime {
> private static Runtime currentRuntime = new Runtime();
>
> I don't see a reason, so it seems likely that somehow no one
> has noticed before that this should be final (for thread safety and
> optimizability). But it would be nice if someone with access to
> full JCK etc tests made sure that adding "final" didn't break
> anything.
Given when this gets initialized thread-safety is not an issue. Seems
unlikely to play much of a role in optimization either.
No reason within the JDK for it to not be final that I can see. Also no
reason I can see for the class itself and/or all its methods to not be
final.
David
> -Doug
More information about the core-libs-dev
mailing list