美文网首页
Kotlin小点

Kotlin小点

作者: 肖散 | 来源:发表于2022-10-30 22:31 被阅读0次

    针对final做了相应的优化

    源码

    public final class BuildConfig {
        public static final boolean DEBUG = false;
        public static final String LIBRARY_PACKAGE_NAME = "com.echo.utils";
        public static final String BUILD_TYPE = "release";
        public static final String VERSION_CODE = "7";
        public static final String VERSION_NAME = "echo.utils.1.0.6";
        public static final String build_branch = "compose";
        public static final String build_sha = "78de3c6cbcab554a6f181a2ebf9cd93eb9f817d8";
        public static final String build_time = "2022-10-31 20:18:22";
    
        public BuildConfig() {
        }
    }
    
            EchoLog.log(
                "echo utils init:", Build.VERSION.SDK_INT,
                "\nVERSION_CODE:", BuildConfig.VERSION_CODE,
                "\nVERSION_NAME:", BuildConfig.VERSION_NAME,
                "\nBUILD_TIME:", BuildConfig.build_time,
                "\nBRANCH:", BuildConfig.build_branch,
                "\nSHA:", BuildConfig.build_sha,
            )
    

    .class生成内容

    EchoLog.INSTANCE.log("echo utils init:", Integer.valueOf(Build.VERSION.SDK_INT), "\nVERSION_CODE:", BuildConfig.VERSION_CODE, "\nVERSION_NAME:", "echo.utils.1.0.4", "\nBUILD_TIME:", "2022-10-14 12:19:12", "\nBRANCH:", "home", "\nSHA:", "00c7b20fa18f5a1d6636208b223b83dee126a926");
    
    

    这里可以看到 Kotlin在生成的时候实际上是直接使用了final 的值.至于VERSION_CODE为什么没有被设置

    相关文章

      网友评论

          本文标题:Kotlin小点

          本文链接:https://www.haomeiwen.com/subject/zngltdtx.html