Fix incorrect message for new nullability assertion exception in 1.4
#KT-36026 Fixed
This commit is contained in:
-2
@@ -1,6 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND: JVM, JVM_IR
|
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FILE: Test.java
|
// FILE: Test.java
|
||||||
|
|
||||||
public class Test {
|
public class Test {
|
||||||
|
|||||||
compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.exceptions.runtime.txt
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method Foo.<init>, parameter x
|
java.lang.NullPointerException: Parameter specified as non-null is null: method Foo.<init>, parameter x
|
||||||
Foo.<init>(12.kt)
|
Foo.<init>(12.kt)
|
||||||
@@ -122,32 +122,37 @@ public class Intrinsics {
|
|||||||
|
|
||||||
public static void checkParameterIsNotNull(Object value, String paramName) {
|
public static void checkParameterIsNotNull(Object value, String paramName) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throwParameterIsNullException(paramName);
|
throwParameterIsNullIAE(paramName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkNotNullParameter(Object value, String paramName) {
|
public static void checkNotNullParameter(Object value, String paramName) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw sanitizeStackTrace(new NullPointerException(paramName));
|
throwParameterIsNullNPE(paramName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void throwParameterIsNullException(String paramName) {
|
private static void throwParameterIsNullIAE(String paramName) {
|
||||||
|
throw sanitizeStackTrace(new IllegalArgumentException(createParameterIsNullExceptionMessage(paramName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void throwParameterIsNullNPE(String paramName) {
|
||||||
|
throw sanitizeStackTrace(new NullPointerException(createParameterIsNullExceptionMessage(paramName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String createParameterIsNullExceptionMessage(String paramName) {
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||||
|
|
||||||
// #0 Thread.getStackTrace()
|
// #0 Thread.getStackTrace()
|
||||||
// #1 Intrinsics.throwParameterIsNullException
|
// #1 Intrinsics.createParameterIsNullExceptionMessage
|
||||||
// #2 Intrinsics.checkParameterIsNotNull
|
// #2 Intrinsics.throwParameterIsNullIAE/throwParameterIsNullNPE
|
||||||
// #3 our caller
|
// #3 Intrinsics.checkParameterIsNotNull/checkNotNullParameter
|
||||||
StackTraceElement caller = stackTraceElements[3];
|
// #4 our caller
|
||||||
|
StackTraceElement caller = stackTraceElements[4];
|
||||||
String className = caller.getClassName();
|
String className = caller.getClassName();
|
||||||
String methodName = caller.getMethodName();
|
String methodName = caller.getMethodName();
|
||||||
|
|
||||||
IllegalArgumentException exception =
|
return "Parameter specified as non-null is null: method " + className + "." + methodName + ", parameter " + paramName;
|
||||||
new IllegalArgumentException("Parameter specified as non-null is null: " +
|
|
||||||
"method " + className + "." + methodName +
|
|
||||||
", parameter " + paramName);
|
|
||||||
throw sanitizeStackTrace(exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int compare(long thisVal, long anotherVal) {
|
public static int compare(long thisVal, long anotherVal) {
|
||||||
|
|||||||
Reference in New Issue
Block a user