havapa / testability-explorer

Automatically exported from code.google.com/p/testability-explorer
Apache License 2.0
0 stars 0 forks source link

MethodInfo#canOverride() misses the case when the method is final #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What is the expected output? What do you see instead?

I expect the final method to be marked as NOT overridable.

Failing Test:

  public void testMediumFinalCost2() throws Exception {
    MethodInfo method =
repo.getClass(Medium.class.getName()).getMethod("finalCost2()I");
    assertFalse(method.canOverride());
    MethodCost cost = computer.compute(Medium.class.getName(),
"finalCost2()I");
    assertEquals(3l, cost.getTotalComplexityCost());
  }

* Method necessary to add to the class Medium (static class inside
MetricComputerTest)

CODE:

  /**
   * I cost 2, but I am a <em>final</em> instance method that can not be
overridden.
   * My cost is unavoidable.
   */
  public final int finalCost2() {
    int i = 0;
    return i > 0 ? i > 1 ? 1 : 2 : 2;
  }

Misko followed up on the mailing list with:
QUOTE:
Sounds like a real bug! Can you create a tests case and fix the
bug? :-) If you can't fix it send me the test case and I will patch it
in and submit a fix for you.
-- Misko

http://groups.google.com/group/testability-explorer/browse_thread/thread/49b34c6
ca1ad1209

Original issue reported on code.google.com by jawol...@gmail.com on 8 Oct 2008 at 12:26

GoogleCodeExporter commented 8 years ago
fixed in revision 142.

Original comment by jawol...@gmail.com on 9 Oct 2008 at 6:22