【问题标题】:Checker Framework argument.type.incompatible false positive with commons-lang3Checker Framework argument.type.incompatible false positive with commons-lang3
【发布时间】:2020-12-11 03:45:49
【问题描述】:

这是我的错误(是的,commons-lang3 jira 上有一个未解决的错误)。

  found   : @Initialized @Nullable Console
  required: @Initialized @NonNull Console
/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/PebbleTemplateProcessor.java:96: error: [argument.type.incompatible] incompatible argument for parameter str of toBoolean.
        if ( BooleanUtils.toBoolean( line ) ) {

我尝试制作此src/java/main/org/apache/commons/lang3/BooleanUtils.astub,然后尝试将该文件放入src/main/resources/

package org.apache.commons.lang3;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;


public class BooleanUtils {

  @NonNull
  public static boolean toBoolean( @Nullable final String str);
}

但我将其添加到我的 gradle 配置中

  extraJavacArgs.addAll(listOf(
    "-Werror",
    "-Astubs=BooleanUtils.astub:stubs"
  ))

但我明白了

warning: Did not find stub file BooleanUtils.astub on classpath or within current directory
warning: Did not find stub file stubs on classpath or within current directory

我该如何解决这个问题?

【问题讨论】:

    标签: java gradle build.gradle gradle-kotlin-dsl checker-framework


    【解决方案1】:

    我想通了,不用感谢https://checkerframework.org/manual/#stub,gradle 插件实际上有一个有用的例子就是这个https://github.com/kelloggm/checkerframework-gradle-plugin#providing-checker-specific-options-to-the-compiler

    您需要提供从项目本身的路径,这就是我所做的。

      extraJavacArgs.addAll(listOf(
        "-Werror",
        "-Astubs=${rootDir}/config/checker/stubs/BooleanUtils.astub"
      ))
    

    我使用了${rootDir},因为./config... 正在查看.gradle

    【讨论】:

      猜你喜欢
      • 2017-09-16
      • 1970-01-01
      • 2021-05-20
      • 1970-01-01
      • 2018-04-04
      • 1970-01-01
      • 2018-12-15
      • 2016-03-30
      • 2020-12-17
      相关资源
      最近更新 更多