Are all compile-time constants inlined?

后端 未结 6 1977
刺人心
刺人心 2020-11-29 05:39

Let\'s say I have a class like this:

class ApplicationDefs{
public static final String configOption1 = \"some option\";
public static final String configOpti         


        
6条回答
  •  鱼传尺愫
    2020-11-29 06:01

    You can inhibit inlining by making your constant non-compile time constants...

    For instance, null is not a compile time constant. Any expression involving a non-compile time constant is not a compile time constant, although javac may do constant folding within the compilation unit.

    public static final String configOption1 = null!=null?"": "some option";
    

提交回复
热议问题