Args guaranteed to be non-null?

前端 未结 3 538
渐次进展
渐次进展 2020-12-10 10:47

In the following program, if this is executed (e.g. via command line), is args JVM independently guaranteed to not be null?

public class test {
    public st         


        
3条回答
  •  醉酒成梦
    2020-12-10 11:45

    Double-clickable Application Bundles on MacOS still have a non-null array passed to main, even though there is no command line per-se.

    The JVM specification does not specify if the array parameter to the main method can be null. See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-5.html#jvms-5.2

    However, the convention is that it will be non-null and it is unlikely that a JVM vendor would break that convention at this point.

提交回复
热议问题