title: Bad type on the operand stack in arraylength
body: <p>I am trying to test a method using powermock. i haven't written any test cases yet. Just trying to set up the class for Mocking. here is what I have so far: </p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  @PrepareForTest({ ReadRubric.class })
  public class ReadRubricTest {
      @Before
      public void setUp() throws Exception {
          PowerMockito.mock(ReadRubric.class);
      }
  
      @After
      public void tearDown() throws Exception {
      }
  
      @Test
      public void invalidFile() throws Exception {
      }
  }
  </code></pre>
  
  <p>When I try to run this test I get the following error. </p>
  
  <pre><code>java.lang.VerifyError: Bad type on operand stack in arraylength
      Exception Details:
        Location:
          com/cerner/devcenter/wag/processor/ReadRubric.readRubric()Ljava/util/List; @809: arraylength
        Reason:
          Invalid type: 'java/lang/Object' (current frame, stack[0])
        Current Frame:
          bci: @809
          flags: { }
          locals: { 'java/util/ArrayList', 'au/com/bytecode/opencsv/CSVReader', top, top, '[Ljava/lang/String;', 'com/cerner/devcenter/wag/processor/Rule', 'java/lang/Object', 'java/lang/Object', top, top, top, top, top, top, top, 'java/lang/Object' }
          stack: { 'java/lang/Object' }
  </code></pre>
  
  <p><code>java -version on cmd gives me 1.7.0_65</code></p>
  
  <p><code>java_home is set to C:\Program Files\Java\jdk1.7.0_65</code></p>
  
  <p><code>On eclipse I am using jre 7 and the compiler level is 1.7</code></p>
  
  <p>In my maven, I have added the following dependency to allow switch cases that accept Strings instead of chars:</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
           &lt;/plugin&gt;
  </code></pre>
  
  <p>can anyone help me in solving this issue?</p>
  
  <p>Here is the method that I am testing:</p>
  
  <pre><code>public static List&lt;Rule&gt; readRubric() throws WAGException, IOException {
          List&lt;Rule&gt; ruleList = new ArrayList&lt;Rule&gt;();
          CSVReader rubricReader = null;
              File file = new File(RUBRIC_FILE_NAME);
              FileReader fileReader = new FileReader(file);
              rubricReader = new CSVReader(fileReader);
              String[] ruleRecord = null;
              //rubricReader.readNext();
              while ((ruleRecord = rubricReader.readNext()) != null) {
                  Rule rule = new Rule();
                  rule.setRuleName(ruleRecord[0].trim());
                  String parameters[] = ruleRecord[1].split(",");
                  rule.addParameter(Arrays.asList(parameters));
                  rule.setPoints(Integer.parseInt(ruleRecord[2].trim()));
                  rule.setRuleEngine(ruleRecord[3].trim());
              rule.setComment(ruleRecord[4].trim());
                      ruleList.add(rule);
          }
              rubricReader.close();
          return ruleList;
      }
  </code></pre>
  
  <p>I found the solution online: it says that i need to add <code>-XX:-UseSplitVerifier</code> to my VM arguments when I run the test. The test runs when I do this. But I need it to run with maven, for that the solution says that I need to add the following plugin to maven:</p>
  
  <pre><code>&lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.14.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;argLine&gt;-XX:-UseSplitVerifier&lt;/argLine&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  </code></pre>
  
  <p>But even after adding this to my POM, this particulair test fails.
  <a href="http://blog.triona.de/development/jee/how-to-use-powermock-with-java-7.html" rel="noreferrer">Link to the solution</a></p>