diff --git a/compiler/testData/cli/jvm/jsr305/A.java b/compiler/testData/cli/jvm/jsr305/A.java
new file mode 100644
index 00000000000..b48092bc933
--- /dev/null
+++ b/compiler/testData/cli/jvm/jsr305/A.java
@@ -0,0 +1,4 @@
+@javax.annotation.ParametersAreNonnullByDefault
+public class A {
+ public void foo(String x) {}
+}
diff --git a/compiler/testData/cli/jvm/jsr305/javax/annotation/ParametersAreNonnullByDefault.java b/compiler/testData/cli/jvm/jsr305/javax/annotation/ParametersAreNonnullByDefault.java
new file mode 100644
index 00000000000..a2402b5d98f
--- /dev/null
+++ b/compiler/testData/cli/jvm/jsr305/javax/annotation/ParametersAreNonnullByDefault.java
@@ -0,0 +1,28 @@
+package javax.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.annotation.meta.TypeQualifierDefault;
+
+/**
+ * This annotation can be applied to a package, class or method to indicate that
+ * the method parameters in that element are nonnull by default unless there is:
+ *
+ * - An explicit nullness annotation
+ *
- The method overrides a method in a superclass (in which case the
+ * annotation of the corresponding parameter in the superclass applies)
+ *
- There is a default parameter annotation (like {@link ParametersAreNullableByDefault})
+ * applied to a more tightly nested element.
+ *
+ *
+ * @see Nonnull
+ */
+@Documented
+@Nonnull
+@TypeQualifierDefault(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ParametersAreNonnullByDefault {
+}
diff --git a/compiler/testData/cli/jvm/jsr305NoFlag.args b/compiler/testData/cli/jvm/jsr305NoFlag.args
new file mode 100644
index 00000000000..f08788feac5
--- /dev/null
+++ b/compiler/testData/cli/jvm/jsr305NoFlag.args
@@ -0,0 +1,4 @@
+$TESTDATA_DIR$/jsr305Usage.kt
+$TESTDATA_DIR$/jsr305
+-d
+$TEMP_DIR$
diff --git a/compiler/testData/cli/jvm/jsr305NoFlag.out b/compiler/testData/cli/jvm/jsr305NoFlag.out
new file mode 100644
index 00000000000..1d7080a67e5
--- /dev/null
+++ b/compiler/testData/cli/jvm/jsr305NoFlag.out
@@ -0,0 +1,4 @@
+compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
+ a.foo(null)
+ ^
+OK
diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java
index ff1d9fb626b..7dbcec601cb 100644
--- a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java
@@ -218,6 +218,12 @@ public class CliTestGenerated extends AbstractCliTest {
doJvmTest(fileName);
}
+ @TestMetadata("jsr305NoFlag.args")
+ public void testJsr305NoFlag() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305NoFlag.args");
+ doJvmTest(fileName);
+ }
+
@TestMetadata("jvm8Target.args")
public void testJvm8Target() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jvm8Target.args");
diff --git a/compiler/util/src/org/jetbrains/kotlin/config/AnalysisFlag.kt b/compiler/util/src/org/jetbrains/kotlin/config/AnalysisFlag.kt
index 35919e44de1..31a2a714e46 100644
--- a/compiler/util/src/org/jetbrains/kotlin/config/AnalysisFlag.kt
+++ b/compiler/util/src/org/jetbrains/kotlin/config/AnalysisFlag.kt
@@ -40,7 +40,7 @@ class AnalysisFlag internal constructor(
}
object Jsr305StateWarnByDefault {
- operator fun provideDelegate(instance: Any?, property: KProperty<*>) = Flag(property.name, Jsr305State.WARN)
+ operator fun provideDelegate(instance: Any?, property: KProperty<*>) = Flag(property.name, Jsr305State.DEFAULT)
}
}
@@ -54,4 +54,4 @@ class AnalysisFlag internal constructor(
@JvmStatic
val jsr305 by Flag.Jsr305StateWarnByDefault
}
-}
\ No newline at end of file
+}
diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt
index ffa4519ea99..23314787efa 100644
--- a/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt
+++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt
@@ -26,11 +26,11 @@ enum class Jsr305State(
companion object {
@JvmField
- val DEFAULT: Jsr305State = IGNORE
+ val DEFAULT: Jsr305State = WARN
fun findByDescription(description: String?) = values().firstOrNull { it.description == description }
}
fun isIgnored(): Boolean = this == IGNORE
fun isWarning(): Boolean = this == WARN
-}
\ No newline at end of file
+}