为什么Netty 4.1无法找到LongObjectHashMap和LongObjectMap

时间:2018-08-18 09:48:04

标签: netty

enter image description here

我只是从Github(branch origin/4.1)克隆Netty,但无法运行示例导致此错误

即使在netty-common中也找不到该类,甚至在github中也找不到该类,我该怎么办?

2 个答案:

答案 0 :(得分:3)

enter image description here

您可以看到,common/src/script中有一个普通脚本,内容是

String[] templateDirs = [properties["collection.template.dir"],
                         properties["collection.template.test.dir"]]
String[] outputDirs = [properties["collection.src.dir"],
                       properties["collection.testsrc.dir"]]

templateDirs.eachWithIndex { templateDir, i ->
    convertSources templateDir, outputDirs[i]
}

void convertSources(String templateDir, String outputDir) {
    String[] keyPrimitives = ["byte", "char", "short", "int", "long"]
    String[] keyObjects = ["Byte", "Character", "Short", "Integer", "Long"]
    String[] keyNumberMethod = ["byteValue", "charValue", "shortValue", "intValue", "longValue"]

    keyPrimitives.eachWithIndex { keyPrimitive, i ->
        convertTemplates templateDir, outputDir, keyPrimitive, keyObjects[i], keyNumberMethod[i]
    }
}

void convertTemplates(String templateDir,
                      String outputDir,
                      String keyPrimitive,
                      String keyObject,
                      String keyNumberMethod) {
    def keyName = keyPrimitive.capitalize()
    def replaceFrom = "(^.*)K([^.]+)\\.template\$"
    def replaceTo = "\\1" + keyName + "\\2.java"
    def hashCodeFn = keyPrimitive.equals("long") ? "(int) (key ^ (key >>> 32))" : "(int) key"
    ant.copy(todir: outputDir) {
        fileset(dir: templateDir) {
            include(name: "**/*.template")
        }
        filterset() {
            filter(token: "K", value: keyName)
            filter(token: "k", value: keyPrimitive)
            filter(token: "O", value: keyObject)
            filter(token: "KEY_NUMBER_METHOD", value: keyNumberMethod)
            filter(token: "HASH_CODE", value: hashCodeFn)
        }
        regexpmapper(from: replaceFrom, to: replaceTo)
    }
}

它表示

  

通过通过maven的build-helper-maven-plugin插件和codegen.groovy脚本读取模板目录中的脚本,可以在所需的收集包下生成特定的类。

因此,当您执行mvn clean install时,它们将以这种方式生成:

enter image description here

答案 1 :(得分:0)

这些已生成...运行./mvnw clean compile