Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6245699
Votes 1
Synopsis Missing bridge for final method (gives AbstractMethodError at runtime)
Category java:compiler
Reported Against
Release Fixed mustang(b67)
State 10-Fix Delivered, Verified, bug
Priority: 2-High
Related Bugs 6248405 , 6270396 , 4633201
Submit Date 24-MAR-2005
Description
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  customer (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.
  xxxxx@xxxxx   2005-03-24 19:36:03 GMT
Work Around
N/A
Evaluation
I suspect this is a case of a missing bridge method.

  xxxxx@xxxxx   2005-03-24 20:26:50 GMT

Notice that this is not a regression since covariant returns
is a Tiger feature.

  xxxxx@xxxxx   2005-03-24 20:28:28 GMT
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang