Create custom exception for lateinit
This commit is contained in:
@@ -1042,7 +1042,8 @@ public abstract class StackValue {
|
||||
v.dup();
|
||||
Label ok = new Label();
|
||||
v.ifnonnull(ok);
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "throwNpe", "()V", false);
|
||||
v.visitLdcInsn(descriptor.getName().asString());
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "throwUninitializedPropertyAccessException", "(Ljava/lang/String;)V", false);
|
||||
v.mark(ok);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ public class A {
|
||||
fun getMyStr(): String {
|
||||
try {
|
||||
val a = str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class A {
|
||||
public fun getMyStr(): String {
|
||||
try {
|
||||
val a = str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ fun box(): String {
|
||||
val a = A()
|
||||
try {
|
||||
a.str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
return "FAIL"
|
||||
|
||||
@@ -8,7 +8,7 @@ class A : Intf {
|
||||
fun getMyStr(): String {
|
||||
try {
|
||||
val a = str
|
||||
} catch (e: NullPointerException) {
|
||||
} catch (e: RuntimeException) {
|
||||
return "OK"
|
||||
}
|
||||
return "FAIL"
|
||||
|
||||
@@ -13,9 +13,15 @@ public class A {
|
||||
if (!Modifier.isProtected(clazz.getDeclaredField("protectedField").modifiers)) cond += "NOT_PROTECTED"
|
||||
if (!Modifier.isPublic(clazz.getDeclaredField("publicField").modifiers)) cond += "NOT_PUBLIC"
|
||||
|
||||
if (Modifier.isPrivate(clazz.getDeclaredField("privateField").modifiers)) cond += "FINAL"
|
||||
if (Modifier.isFinal(clazz.getDeclaredField("privateField").modifiers)) cond += "FINAL"
|
||||
|
||||
return if (cond.isEmpty()) "OK" else cond.joinToString()
|
||||
try {
|
||||
val a = privateField
|
||||
} catch (e: UninitializedPropertyAccessException) {
|
||||
return if (cond.isEmpty()) "OK" else cond.joinToString()
|
||||
}
|
||||
|
||||
return "EXCEPTION WAS NOT CATCHED"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user