diff options
| -rw-r--r-- | runtime/verifier/method_verifier.cc | 4 | ||||
| -rw-r--r-- | test/800-smali/expected.txt | 1 | ||||
| -rw-r--r-- | test/800-smali/smali/b_25494456.smali | 14 | ||||
| -rw-r--r-- | test/800-smali/src/Main.java | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 2db79ab229..aae031798e 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -2045,6 +2045,10 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { } else if (reg_type.IsUninitializedTypes()) { Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "returning uninitialized object '" << reg_type << "'"; + } else if (!reg_type.IsReferenceTypes()) { + // We really do expect a reference here. + Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "return-object returns a non-reference type " + << reg_type; } else if (!return_type.IsAssignableFrom(reg_type)) { if (reg_type.IsUnresolvedTypes() || return_type.IsUnresolvedTypes()) { Fail(VERIFY_ERROR_NO_CLASS) << " can't resolve returned type '" << return_type diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt index 17c1f00c41..a590cf1e0b 100644 --- a/test/800-smali/expected.txt +++ b/test/800-smali/expected.txt @@ -46,4 +46,5 @@ b/23300986 b/23300986 (2) b/23502994 (if-eqz) b/23502994 (check-cast) +b/25494456 Done! diff --git a/test/800-smali/smali/b_25494456.smali b/test/800-smali/smali/b_25494456.smali new file mode 100644 index 0000000000..0675b27730 --- /dev/null +++ b/test/800-smali/smali/b_25494456.smali @@ -0,0 +1,14 @@ +.class public LB25494456; + +.super Ljava/lang/Object; + +# Ensure that a type mismatch (integral/float vs reference) overrides a soft failure (because of +# an unresolvable type) in return-object. + +.method public static run()Lwont/be/Resolvable; + .registers 1 + + const/4 v0, 1 + return-object v0 + +.end method diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java index f75747d5c5..4844848337 100644 --- a/test/800-smali/src/Main.java +++ b/test/800-smali/src/Main.java @@ -137,6 +137,8 @@ public class Main { new Object[] { new Object() }, null, null)); testCases.add(new TestCase("b/23502994 (check-cast)", "B23502994", "runCHECKCAST", new Object[] { "abc" }, null, null)); + testCases.add(new TestCase("b/25494456", "B25494456", "run", null, new VerifyError(), + null)); } public void runTests() { |