【发布时间】:2017-07-23 10:31:24
【问题描述】:
我想用oracle jdk 1.8编译简单代码:
class Foo {
public static void test(@NotNull String a) {}
}
但是idea看不懂这样的代码,建议补充:
import com.sun.istack.internal.NotNull;
在idea 内部编译之后,
但如果由gradle 使用build.gradle 运行构建:
version '1.0-snaphshot_03.03.2017'
apply plugin: 'java'
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
artifacts {
archives sourcesJar
}
我收到错误:
error: package com.sun.istack.internal does not exist
import com.sun.istack.internal.NotNull;
error: cannot find symbol
public static void test(@NotNull String a) {
^
symbol: class NotNull
location: class Foo
我以为NotNull是在1.8里加的?
如何在idea 和gradle 中使用NotNull?
【问题讨论】:
-
请查看stackoverflow.com/questions/4963300/…。我认为是@NonNull。
-
你的意思是
javax.annotation.Nonnull? -
尝试可选
。
标签: java