title: VerifyError on logical operations using Proguard
body: <p>I'm using <em>Proguard</em> on an android library but it seems to create a <code>VerifyError</code> on one specific class while shrinking or obfuscating the sample code. (i.e. using <code>-dontobfuscate</code> and <code>-dontshrink</code> will remove the error).</p>
  
  <p>I could isolate the error on a <a href="https://github.com/aveuiller/proguardBugReproduction" rel="nofollow noreferrer">GitHub repository</a> with a simple example (The command <code>./gradlew clean test</code> should reproduce the error)
  but I don't really understand the real problem here.</p>
  
  <p>My failing test will only try to instantiate an object:</p>
  
  <pre><code>package a.b.c;
  
  public class FailingTest {
    @org.junit.Test
    public void name() throws Exception {
      new D();
    }
  }
  </code></pre>
  
  <p>And the associated class is as simple as that:</p>
  
  <pre><code>package a.b.c;
  
  public class D {
    public void f(int g) {
      if (g &lt; 0) {
        System.out.println("test");
      }
    }
  }
  </code></pre>
  
  <p>in fact any logical operation will provoke an error (e.g. only putting <code>System.out.println(g == 2);</code> in the method body will fail as well).</p>
  
  <p>Proguard is configured as follow:</p>
  
  <pre><code>-keep public class a.b.c.D {
      public protected *;
  }
  
  # With those options, the test will be successful.
  #-dontobfuscate
  #-dontshrink
  </code></pre>
  
  <p>The stacktrace is as follow: </p>
  
  <pre><code>java.lang.VerifyError: Expecting a stackmap frame at branch target 37
  Exception Details:
    Location:
      a/b/c/D.f(I)V @17: ifeq
    Reason:
      Expected stackmap frame at this location.
    Bytecode:
      0x0000000: bb00 0559 b700 0ab6 000b 4d2c b900 0c01
      0x0000010: 0099 0014 2cb9 000d 0100 4eb2 0007 2db6
      0x0000020: 0008 a7ff e9b1                         
  
      at a.b.c.FailingTest.name(FailingTest.java:7)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
      at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
      at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
      at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
      at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
      at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
      at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
      at com.sun.proxy.$Proxy3.processTestClass(Unknown Source)
      at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
      at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
      at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
      at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>