This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes AbstractMethodError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "AbstractMethodError" Watch "AbstractMethodError" New topic
Author

AbstractMethodError

Sudarshan Sreenivasan
Ranch Hand

Joined: Jun 28, 2007
Posts: 188

Hi

Can you tell me when a AbstractMethodError occurs ?? The api says

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.


I need an example situation of when this can happen at runtime ?? , I can not think of a situation where this could happen, can anyone throw light on it

Thanks
Sudarshan
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Create an empty interface

interface I {}

Create a class that implements it:

class C implements I {}

Now compile them both.

Now modify the interface:

interface I { void m(); }

Compile interface I, if you like, but do not compile class C.

Now create a class which uses the interface.



Compile only class A and run it, and you'll get an AbstractMethodError. Class C has not been compiled since interface I changed, so it does not include an implementation of method m().


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AbstractMethodError
 
Similar Threads
java lang AbstractMethodError:
AbstractMethodError
AbstractMethodError
AbstractMethodError
AbstractMethodError