diff options
-rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 5 | ||||
-rwxr-xr-x | test/127-secondarydex/build | 31 | ||||
-rw-r--r-- | test/127-secondarydex/expected.txt | 3 | ||||
-rw-r--r-- | test/127-secondarydex/info.txt | 3 | ||||
-rwxr-xr-x | test/127-secondarydex/run | 18 | ||||
-rw-r--r-- | test/127-secondarydex/src/Main.java | 43 | ||||
-rw-r--r-- | test/127-secondarydex/src/Super.java | 21 | ||||
-rw-r--r-- | test/127-secondarydex/src/Test.java | 25 | ||||
-rwxr-xr-x | test/etc/run-test-jar | 6 |
9 files changed, 151 insertions, 4 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index 670bf2aa8e..f76da8edaa 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -541,8 +541,7 @@ static inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, mirror::Object* this_object, mirror::ArtMethod* referrer, bool access_check, InvokeType type) { - bool is_direct = type == kStatic || type == kDirect; - if (UNLIKELY(this_object == NULL && !is_direct)) { + if (UNLIKELY(this_object == NULL && type != kStatic)) { return NULL; } mirror::ArtMethod* resolved_method = @@ -567,7 +566,7 @@ static inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, } if (type == kInterface) { // Most common form of slow path dispatch. return this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); - } else if (is_direct) { + } else if (type == kStatic || type == kDirect) { return resolved_method; } else if (type == kSuper) { return referrer->GetDeclaringClass()->GetSuperClass() diff --git a/test/127-secondarydex/build b/test/127-secondarydex/build new file mode 100755 index 0000000000..712774f7ef --- /dev/null +++ b/test/127-secondarydex/build @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Copyright (C) 2014 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. + +# Stop if something fails. +set -e + +mkdir classes +${JAVAC} -d classes `find src -name '*.java'` + +mkdir classes-ex +mv classes/Super.class classes-ex + +if [ ${NEED_DEX} = "true" ]; then + ${DX} -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex --dump-width=1000 classes + zip $TEST_NAME.jar classes.dex + ${DX} -JXmx256m --debug --dex --dump-to=classes-ex.lst --output=classes.dex --dump-width=1000 classes-ex + zip ${TEST_NAME}-ex.jar classes.dex +fi diff --git a/test/127-secondarydex/expected.txt b/test/127-secondarydex/expected.txt new file mode 100644 index 0000000000..29a1411ad3 --- /dev/null +++ b/test/127-secondarydex/expected.txt @@ -0,0 +1,3 @@ +testSlowPathDirectInvoke +Test +Got null pointer exception diff --git a/test/127-secondarydex/info.txt b/test/127-secondarydex/info.txt new file mode 100644 index 0000000000..0479d1a784 --- /dev/null +++ b/test/127-secondarydex/info.txt @@ -0,0 +1,3 @@ +Test features with a secondary dex file. + +- Regression test to ensure slow path of direct invoke does null check. diff --git a/test/127-secondarydex/run b/test/127-secondarydex/run new file mode 100755 index 0000000000..d8c3c798bf --- /dev/null +++ b/test/127-secondarydex/run @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Copyright (C) 2014 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. + +# Use secondary switch to add secondary dex file to class path. +exec ${RUN} "${@}" --secondary diff --git a/test/127-secondarydex/src/Main.java b/test/127-secondarydex/src/Main.java new file mode 100644 index 0000000000..c921c5b0c8 --- /dev/null +++ b/test/127-secondarydex/src/Main.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2014 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. + */ + +import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +/** + * Secondary dex file test. + */ +public class Main { + public static void main(String[] args) { + testSlowPathDirectInvoke(); + } + + public static void testSlowPathDirectInvoke() { + System.out.println("testSlowPathDirectInvoke"); + try { + Test t1 = new Test(); + Test t2 = new Test(); + Test t3 = null; + t1.test(t2); + t1.test(t3); + } catch (NullPointerException npe) { + System.out.println("Got null pointer exception"); + } catch (Exception e) { + System.out.println("Got unexpected exception " + e); + } + } +} diff --git a/test/127-secondarydex/src/Super.java b/test/127-secondarydex/src/Super.java new file mode 100644 index 0000000000..7608d4a7c8 --- /dev/null +++ b/test/127-secondarydex/src/Super.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2014 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 Super { + private void print() { + System.out.println("Super"); + } +} diff --git a/test/127-secondarydex/src/Test.java b/test/127-secondarydex/src/Test.java new file mode 100644 index 0000000000..82cb901374 --- /dev/null +++ b/test/127-secondarydex/src/Test.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2014 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 Test extends Super { + public void test(Test t) { + t.print(); + } + + private void print() { + System.out.println("Test"); + } +} diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar index f1044e86b7..af43de3410 100755 --- a/test/etc/run-test-jar +++ b/test/etc/run-test-jar @@ -35,6 +35,7 @@ PATCHOAT="" PREBUILD="y" QUIET="n" RELOCATE="y" +SECONDARY_DEX="" USE_GDB="n" USE_JVM="n" VERIFY="y" @@ -93,6 +94,9 @@ while true; do elif [ "x$1" = "x--no-image" ]; then HAVE_IMAGE="n" shift + elif [ "x$1" = "x--secondary" ]; then + SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar" + shift elif [ "x$1" = "x--debug" ]; then DEBUGGER="y" shift @@ -293,7 +297,7 @@ dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ROOT/bin/$DALVIKVM \ $INT_OPTS \ $DEBUGGER_OPTS \ $DALVIKVM_BOOT_OPT \ - -cp $DEX_LOCATION/$TEST_NAME.jar $MAIN" + -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN" if [ "$HOST" = "n" ]; then |