title: PowerMock is not intercepting new Instances
body: <p>Hi I´m trying to test some legacy code that uses command patron. I couldn´t make work PowerMock propperly and I tryed to make a simple example to test if it could work.</p>
  <p>I think that the problem is that the method whenNew() or expectNew() is not intercepting when in the original code a &quot;new&quot; instance is declared.</p>
  <p>Here is the code:</p>
  <p>ClassToTest</p>
  <pre><code>public class ClassToTest {
      
      public ClassToTest() {
          
      }
      
      public ClassInstance getClassInstance() {
          ClassInstance a = new ClassInstance(1);
          return a;
      }
  }
  </code></pre>
  <p>ClassInstance</p>
  <pre><code>  public class ClassInstance {
      
          private int detector;
          
          public ClassInstance(int detector) {
              this.detector = detector;
          }
      
          public int getDetector() {
              return detector;
          }
      
          public void setDetector(int detector) {
              this.detector = detector;
          }
      }
  </code></pre>
  <p>The test</p>
  <pre><code>@RunWith(PowerMockRunner.class)
  @PrepareForTest({ClassToTestTest.class, ClassInstance.class})
  public class ClassToTestTest {
      
      
      @Test
      public void test() throws Exception {
          ClassInstance n = new ClassInstance(2);
          PowerMockito.whenNew(ClassInstance.class).withAnyArguments().thenReturn(n); 
          ClassToTest c = Mockito.spy(ClassToTest.class);
          
          System.out.println(c.getClassInstance().getDetector()); 
      }
  
  }
  </code></pre>
  <p>And here is the pom.xml.</p>
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.5&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.mockito&lt;/groupId&gt;
              &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
              &lt;version&gt;2.18.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          
          &lt;dependency&gt;
              &lt;groupId&gt;org.powermock&lt;/groupId&gt;
              &lt;artifactId&gt;powermock-core&lt;/artifactId&gt;
              &lt;version&gt;2.0.9&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          
          &lt;dependency&gt;
              &lt;groupId&gt;org.powermock&lt;/groupId&gt;
              &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
              &lt;version&gt;2.0.9&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          
          &lt;dependency&gt;
              &lt;groupId&gt;org.powermock&lt;/groupId&gt;
              &lt;artifactId&gt;powermock-api-mockito2&lt;/artifactId&gt;
              &lt;version&gt;2.0.9&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.powermock&lt;/groupId&gt;
               &lt;artifactId&gt;powermock-api-easymock&lt;/artifactId&gt;
              &lt;version&gt;2.0.9&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      
  </code></pre>
  <p>So when I run the test, the expected value if PowerMockito intercepts the new instance should be 2 but the console gives me 1...</p>