diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | 2ad60cfc28e14ee8f0bb038720836a4696c478ad (patch) | |
tree | 19f1bb30ab7ff96f1e3e59a60b61dcd2aeddda93 /dx/tests/073-dex-null-array-refs | |
download | android_dalvik-2ad60cfc28e14ee8f0bb038720836a4696c478ad.tar.gz android_dalvik-2ad60cfc28e14ee8f0bb038720836a4696c478ad.tar.bz2 android_dalvik-2ad60cfc28e14ee8f0bb038720836a4696c478ad.zip |
Initial Contribution
Diffstat (limited to 'dx/tests/073-dex-null-array-refs')
-rw-r--r-- | dx/tests/073-dex-null-array-refs/Blort.java | 73 | ||||
-rw-r--r-- | dx/tests/073-dex-null-array-refs/expected.txt | 86 | ||||
-rw-r--r-- | dx/tests/073-dex-null-array-refs/info.txt | 7 | ||||
-rw-r--r-- | dx/tests/073-dex-null-array-refs/run | 19 |
4 files changed, 185 insertions, 0 deletions
diff --git a/dx/tests/073-dex-null-array-refs/Blort.java b/dx/tests/073-dex-null-array-refs/Blort.java new file mode 100644 index 000000000..b6678c0b2 --- /dev/null +++ b/dx/tests/073-dex-null-array-refs/Blort.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class Blort +{ + public static Object test1() { + return ((Object[]) null)[0]; + } + + public static void test2() { + ((Object[]) null)[0] = null; + } + + public static int test3() { + return ((Object[]) null).length; + } + + public static Object test4() { + Object[] arr = null; + return arr[0]; + } + + public static void test5() { + Object[] arr = null; + arr[0] = null; + } + + public static int test6() { + Object[] arr = null; + return arr.length; + } + + public static Object test7(Object[] arr) { + if (check()) { + arr = null; + } + + return arr[0]; + } + + public static void test8(Object[] arr) { + if (check()) { + arr = null; + } + + arr[0] = null; + } + + public static int test9(Object[] arr) { + if (check()) { + arr = null; + } + + return arr.length; + } + + public static boolean check() { + return true; + } +} diff --git a/dx/tests/073-dex-null-array-refs/expected.txt b/dx/tests/073-dex-null-array-refs/expected.txt new file mode 100644 index 000000000..3acb6b265 --- /dev/null +++ b/dx/tests/073-dex-null-array-refs/expected.txt @@ -0,0 +1,86 @@ +javac 1.7.0-internal_bootstrap +Blort.test1:()Ljava/lang/Object;: +regs: 0002; ins: 0000; outs: 0000 + 0000: const/4 v0, #null // #0 + 0001: check-cast v0, java.lang.Object[] + 0003: const/4 v1, #int 0 // #0 + 0004: aget-object v0, v0, v1 + 0006: return-object v0 +Blort.test2:()V: +regs: 0003; ins: 0000; outs: 0000 + 0000: const/4 v0, #null // #0 + 0001: check-cast v0, java.lang.Object[] + 0003: const/4 v1, #int 0 // #0 + 0004: const/4 v2, #null // #0 + 0005: aput-object v2, v0, v1 + 0007: return-void +Blort.test3:()I: +regs: 0001; ins: 0000; outs: 0000 + 0000: const/4 v0, #null // #0 + 0001: check-cast v0, java.lang.Object[] + 0003: array-length v0, v0 + 0004: return v0 +Blort.test4:()Ljava/lang/Object;: +regs: 0003; ins: 0000; outs: 0000 + 0000: const/4 v1, #null // #0 + 0001: move-object v0, v1 + 0002: move-object v1, v0 + 0003: const/4 v2, #int 0 // #0 + 0004: aget-object v1, v1, v2 + 0006: move-object v0, v1 + 0007: return-object v0 +Blort.test5:()V: +regs: 0004; ins: 0000; outs: 0000 + 0000: const/4 v1, #null // #0 + 0001: move-object v0, v1 + 0002: move-object v1, v0 + 0003: const/4 v2, #int 0 // #0 + 0004: const/4 v3, #null // #0 + 0005: aput-object v3, v1, v2 + 0007: return-void +Blort.test6:()I: +regs: 0002; ins: 0000; outs: 0000 + 0000: const/4 v1, #null // #0 + 0001: move-object v0, v1 + 0002: move-object v1, v0 + 0003: array-length v1, v1 + 0004: move v0, v1 + 0005: return v0 +Blort.test7:([Ljava/lang/Object;)Ljava/lang/Object;: +regs: 0004; ins: 0001; outs: 0000 + 0000: move-object v0, v3 + 0001: invoke-static {}, Blort.check:()Z + 0004: move-result v1 + 0005: if-eqz v1, 0009 // +0004 + 0007: const/4 v1, #null // #0 + 0008: move-object v0, v1 + 0009: move-object v1, v0 + 000a: const/4 v2, #int 0 // #0 + 000b: aget-object v1, v1, v2 + 000d: move-object v0, v1 + 000e: return-object v0 +Blort.test8:([Ljava/lang/Object;)V: +regs: 0005; ins: 0001; outs: 0000 + 0000: move-object v0, v4 + 0001: invoke-static {}, Blort.check:()Z + 0004: move-result v1 + 0005: if-eqz v1, 0009 // +0004 + 0007: const/4 v1, #null // #0 + 0008: move-object v0, v1 + 0009: move-object v1, v0 + 000a: const/4 v2, #int 0 // #0 + 000b: const/4 v3, #null // #0 + 000c: aput-object v3, v1, v2 + 000e: return-void +Blort.test9:([Ljava/lang/Object;)I: +regs: 0003; ins: 0001; outs: 0000 + 0000: move-object v0, v2 + 0001: invoke-static {}, Blort.check:()Z + 0004: move-result v1 + 0005: if-eqz v1, 0009 // +0004 + 0007: const/4 v1, #null // #0 + 0008: move-object v0, v1 + 0009: move-object v1, v0 + 000a: array-length v1, v1 + 000b: move v0, v1 + 000c: return v0 diff --git a/dx/tests/073-dex-null-array-refs/info.txt b/dx/tests/073-dex-null-array-refs/info.txt new file mode 100644 index 000000000..ca3b161b7 --- /dev/null +++ b/dx/tests/073-dex-null-array-refs/info.txt @@ -0,0 +1,7 @@ +This is a smoke test of dex conversion, which checks to see that +a bunch of cases convert reasonably, where necessarily or possibly +null array references are used. + +This test compares emitted code against a known-good (via eyeballing) +version, so it is possible for this test to spuriously fail if other +aspects of conversion end up altering the output in innocuous ways. diff --git a/dx/tests/073-dex-null-array-refs/run b/dx/tests/073-dex-null-array-refs/run new file mode 100644 index 000000000..52f113167 --- /dev/null +++ b/dx/tests/073-dex-null-array-refs/run @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$JAVAC -d . Blort.java +dx --debug --dex --no-optimize --positions=none --no-locals \ + --dump-method=Blort.test'*' *.class |