Skip to main content

suspicious "abstract method not implemented"

3 replies [Last post]
alexlamsl
Offline
Joined: 2004-09-02
Points: 0

Has anyone encountered a similar problem with javac complaining that "abstract method not implemented" while you have already done so in the superclass already?

And just to reassure you that it is not likely to be my silly mistake(s), the workaround for this issue that I use:
[pre]
@Override
public ReturnType problematicMethod() {
return super.problematicMethod();
}
[/pre]

And javac compiles WITHOUT complaining about the @Override bit (or the super.p...Method() bit), which is certainly contradictory to its initial complaint that such method implementation is missing... ;)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexlamsl
Offline
Joined: 2004-09-02
Points: 0

just now I wanted to compiler with all the workarounds put in the following exception is thrown:

[pre]
An exception has occurred in the compiler (1.6.0-rc). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at com.sun.tools.javac.comp.Check.checkCompatibleConcretes(Check.java:1212)
at com.sun.tools.javac.comp.Check.checkCompatibleSupertypes(Check.java:1564)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2551)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2505)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2441)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:891)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:867)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:660)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:633)
at com.sun.tools.javac.main.Main.compile(Main.java:761)
at com.sun.tools.javac.main.Main.compile(Main.java:686)
at com.sun.tools.javac.main.Main.compile(Main.java:675)
at com.sun.tools.javac.Main.compile(Main.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:589)
at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:55)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:931)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:757)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:64)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:378)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:234)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:287)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
BUILD FAILED (total time: 0 seconds)
[/pre]

So I guess the compiler is more unhappy with the Generics than the class method implementations after all ;)

tackline
Offline
Joined: 2003-06-19
Points: 0

There are valid reasons why overriding a method and calling the super is necessary. For instance in order to implement an interface the method needs to be overriden in order to be public and return the type (or a subtype of the type) specified by the interface.

However, the error message "abstract method not implemented", sounds as if it is coming from an exceptions in the javac tool. javac comes up with messages like:

B.java:1: B is not abstract and does not override abstract method fn() in B
class B {
^
1 error

Can you give a short, self-contained, compilable example that demonstrates the problem. The code below, for example compiles cleanly on b63 (and 1.5.0_06)

abstract class B {
abstract void fn();
}
class A extends B {
void fn() { }
}
class D extends A {
}

alexlamsl
Offline
Joined: 2004-09-02
Points: 0

> There are valid reasons why overriding a method and
> calling the super is necessary. For instance in order
> to implement an interface the method needs to be
> overriden in order to be public and return the type
> (or a subtype of the type) specified by the
> interface.

I shall (safely) ignore this part ;)

> However, the error message "abstract method not
> implemented", sounds as if it is coming from an
> exceptions in the javac tool. javac comes up with
> messages like:
>
> B.java:1: B is not abstract and does not override
> abstract method fn() in B
> class B {
> ^
> 1 error

And this is indeed the case - see the workaround provided above.

> Can you give a short, self-contained, compilable
> example that demonstrates the problem. The code
> below, for example compiles cleanly on b63 (and
> 1.5.0_06)
>
> abstract class B {
> abstract void fn();
> }
> class A extends B {
> void fn() { }
> }
> class D extends A {
> }

ok my example cannot be too short, but in abstract it goes on like this:
[pre]
public interface E, P extends F> {
P m();
// and some others...
}

public interface F, P extends F> {
}

public abstract class A, P extends F> {
public P m() {
return null;
}
// and some others...
}

public interface V, P extends F> extends E {
// some methods...
}

public interface U extends V {
// some methods...
}

public abstract class B extends A implements U {
// some implementations...
}

public class Z extends B implements F {
// now without this workaround, the compilation will fail
@Override
public Z m() {
return super.m();
}
// some other implementations...
}
[/pre]