Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.5.0_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08) Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux tidore 2.6.10 #1 SMP Mon Jan 10 10:43:24 CET 2005 i686 Intel(R) Pentium(R) 4 CPU 2.60GHz GenuineIntel GNU/Linux A DESCRIPTION OF THE PROBLEM : The test case below compiles cleanly, but when run it throws an AbstractMethodError. This is because no bridge method is generated in the class Derived. It only happens if the method (see test code) is declared final, but this should not inhibit generating the bridge method, which does not override the base class method. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Save test case below as TestClass.java % javac TestClass.java % java TestClass EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - No output ACTUAL - Stack trace as reported below ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.AbstractMethodError: TestClass$Derived.method()LTestClass$Base; at TestClass.main(TestClass.java:5) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class TestClass { public static void main(String[] args) { Interface x = new Derived(); x.method(); // throws AbstractMethodError } static interface Interface { public Base method(); } static class Base { // Bug only occurs if method is declared final public final Derived method() { return null; } } static class Derived extends Base implements Interface {} } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Do not declare the method in the base class as final. ###@###.### 2005-03-24 19:36:03 GMT
|