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
|
||||
// IGNORE_BACKEND: JVM, JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FILE: Test.java
|
||||
|
||||
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)
|
||||
@@ -122,32 +122,37 @@ public class Intrinsics {
|
||||
|
||||
public static void checkParameterIsNotNull(Object value, String paramName) {
|
||||
if (value == null) {
|
||||
throwParameterIsNullException(paramName);
|
||||
throwParameterIsNullIAE(paramName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkNotNullParameter(Object value, String paramName) {
|
||||
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();
|
||||
|
||||
// #0 Thread.getStackTrace()
|
||||
// #1 Intrinsics.throwParameterIsNullException
|
||||
// #2 Intrinsics.checkParameterIsNotNull
|
||||
// #3 our caller
|
||||
StackTraceElement caller = stackTraceElements[3];
|
||||
// #1 Intrinsics.createParameterIsNullExceptionMessage
|
||||
// #2 Intrinsics.throwParameterIsNullIAE/throwParameterIsNullNPE
|
||||
// #3 Intrinsics.checkParameterIsNotNull/checkNotNullParameter
|
||||
// #4 our caller
|
||||
StackTraceElement caller = stackTraceElements[4];
|
||||
String className = caller.getClassName();
|
||||
String methodName = caller.getMethodName();
|
||||
|
||||
IllegalArgumentException exception =
|
||||
new IllegalArgumentException("Parameter specified as non-null is null: " +
|
||||
"method " + className + "." + methodName +
|
||||
", parameter " + paramName);
|
||||
throw sanitizeStackTrace(exception);
|
||||
return "Parameter specified as non-null is null: method " + className + "." + methodName + ", parameter " + paramName;
|
||||
}
|
||||
|
||||
public static int compare(long thisVal, long anotherVal) {
|
||||
|
||||
Reference in New Issue
Block a user