From 52f205a38bda70d5c63907ef354a1475b4237b21 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 1 Dec 2017 12:16:07 -0800 Subject: ART: Remove old aget on null workaround Use null for an aget-object of null. Ensure that other aget types on null cannot be converted to or used as a reference type. Let the verifier continue scanning after an aget on a null register, to ensure that the dead code is type-safe. Add test coverage for the new behavior. Partially reverts commit 4824c27988c8eeb302791624bb3ce1d557b0db6c Partially reverts commit 857f058d4b7bd07c5c99eda416ad91516a10b4da Bug: 22059710 Bug: 64683522 Bug: 69669661 Test: m test-art-host Change-Id: Ie0b554e8f880251d8e73ab6dfb6b41a5e63defc6 --- test/518-null-array-get/src/Main.java | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'test/518-null-array-get/src/Main.java') diff --git a/test/518-null-array-get/src/Main.java b/test/518-null-array-get/src/Main.java index 66e50aacd7..678aef1f43 100644 --- a/test/518-null-array-get/src/Main.java +++ b/test/518-null-array-get/src/Main.java @@ -22,16 +22,36 @@ public class Main { class InnerClass {} public static void main(String[] args) throws Exception { - Class c = Class.forName("NullArray"); - Method m = c.getMethod("method"); - Object[] arguments = { }; + checkLoad("NullArrayFailInt2Object", true); + checkLoad("NullArrayFailObject2Int", true); + checkLoad("NullArraySuccessInt", false); + checkLoad("NullArraySuccessInt2Float", false); + checkLoad("NullArraySuccessShort", false); + checkLoad("NullArraySuccessRef", false); + } + + private static void checkLoad(String className, boolean expectError) throws Exception { + Class c; try { - m.invoke(null, arguments); - throw new Error("Expected an InvocationTargetException"); - } catch (InvocationTargetException e) { - if (!(e.getCause() instanceof NullPointerException)) { - throw new Error("Expected a NullPointerException"); + c = Class.forName(className); + if (expectError) { + throw new RuntimeException("Expected error for " + className); + } + Method m = c.getMethod("method"); + try { + m.invoke(null); + throw new RuntimeException("Expected an InvocationTargetException"); + } catch (InvocationTargetException e) { + if (!(e.getCause() instanceof NullPointerException)) { + throw new RuntimeException("Expected a NullPointerException"); + } + System.out.println(className); + } + } catch (VerifyError e) { + if (!expectError) { + throw new RuntimeException(e); } + System.out.println(className); } } } -- cgit v1.2.3-59-g8ed1b