Created
August 9, 2017 22:36
-
-
Save justinjhendrick/b570fea63df6b7b00d9a1c406cb50fc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// java.lang.VerifyError when returning an array of an interface | |
// Dalvik error message | |
// W/dalvikvm( 8228): VFY: returning [Ljava/lang/Object; (cl=0x0), declared [Ltest/Empty; (cl=0x40d5f510) | |
// W/dalvikvm( 8228): VFY: rejecting opcode 0x11 at 0x000f | |
// W/dalvikvm( 8228): VFY: rejected Ltest/Counter;.two_returns ()[Ltest/Empty; | |
// W/dalvikvm( 8228): Verifier rejected class Ltest/Counter; | |
// ART error message | |
// 7149 7149 E AndroidRuntime: java.lang.VerifyError: Verifier rejected class test.Counter: test.Empty[] test.Counter.two_returns() failed to verify: test.Empty[] test.Counter.two_returns(): [0xF] returning 'Reference: java.lang.Object[]', but expected from declaration 'Reference: test.Empty[]' (declaration of 'test.Counter' appears in /data/app/test-1/base.apk) | |
package test; | |
import android.app.Activity; | |
import android.os.Bundle; | |
interface Empty { | |
} | |
class A implements Empty { | |
} | |
class B implements Empty { | |
} | |
public class Counter extends Activity { | |
// throws a VerifyError | |
public Empty[] two_returns() { | |
if (Math.random() > .5) { | |
return new A[1]; | |
} else { | |
return new B[1]; | |
} | |
} | |
// Does not throw a VerifyError | |
public Empty[] one_return_A() { | |
return new A[1]; | |
} | |
// Does not throw a VerifyError | |
public Empty[] one_return_B() { | |
return new B[1]; | |
} | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
System.out.println(two_returns()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment