Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Implement interface w/o overridin method - eclipse don't throw compile error
Implement interface w/o overridin method - eclipse don't throw compile error [message #260600] Sun, 14 June 2009 14:36 Go to next message
Eclipse UserFriend
hi folks,

Please excuse the gibberish English used in Subject line. I had to cram
a lot in that subject line.
I m using Ganymede 3.4.1 with Java 1.6 on windows xp. Here's a set of
classes and interface which compiles differently when compiled within
eclipse and using javac command through the commandline.

/* the interface */
public interface MyInterface {
public void helpMe();
}// end

public abstract SuperClass {
public void helpMe() {
System.out.println("In SuperClass.helpMe());
}

abstract public void myMethod();
} // super class ends

public ChildClass extends SuperClass implements MyInterface {
// i won't override MyInterface.helpMe()

public myMethod() {
System.out.println("In ChildClass.myMethod()");
}
} // child ends.

these set of classes ... each in its own file (obviously :) compiles
without errors inside Eclipse Ganymede IDE. However i get a compilation
error in ChildClass.java ... if i compile these classes individually using
javac thru commandlind. The error thrown is "ChildClass must override
helpMe() ... "

Has anyone encountered such a thing ?
Re: Implement interface w/o overridin method - eclipse don't throw compile error [message #260603 is a reply to message #260600] Sun, 14 June 2009 18:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lhasadad.gmail.google.com

Chetan,

I see the nature of the issue but not sure off top of my head where the
language comes down on it.... The helpMe that is defined in SuperClass
might jot be identified as contributing the required implementation of the
MyInterface (since its not declared as part of SuperClass' hierarchy. When
the javac compiler compiles ChildClass and looks for someone supplying the
implementation of the interface's helpMe method it finds none (since super
class was no compiled with that interface defined.

Bill

Chetan Kumar wrote:
> hi folks,
>
> Please excuse the gibberish English used in Subject line. I had to
> cram a lot in that subject line.
> I m using Ganymede 3.4.1 with Java 1.6 on windows xp. Here's a set of
> classes and interface which compiles differently when compiled within
> eclipse and using javac command through the commandline.
>
> /* the interface */
> public interface MyInterface {
> public void helpMe();
> }// end
>
> public abstract SuperClass {
> public void helpMe() {
> System.out.println("In SuperClass.helpMe());
> }
> abstract public void myMethod();
> } // super class ends
>
> public ChildClass extends SuperClass implements MyInterface {
> // i won't override MyInterface.helpMe()
>
> public myMethod() {
> System.out.println("In ChildClass.myMethod()");
> }
> } // child ends.
>
> these set of classes ... each in its own file (obviously :) compiles
> without errors inside Eclipse Ganymede IDE. However i get a compilation
> error in ChildClass.java ... if i compile these classes individually
> using javac thru commandlind. The error thrown is "ChildClass must
> override helpMe() ... "
>
> Has anyone encountered such a thing ?
>
>
>
>
>
>
Re: Implement interface w/o overridin method - eclipse don't throw compile error [message #260607 is a reply to message #260600] Sun, 14 June 2009 23:13 Go to previous message
Eclipse UserFriend
Originally posted by: n.sherlock.gmail.com

Chetan Kumar wrote:
> /* the interface */
> public interface MyInterface {
> public void helpMe();
> }// end
>
> public abstract SuperClass {
> public void helpMe() {
> System.out.println("In SuperClass.helpMe());
> }
> abstract public void myMethod();
> } // super class ends
>
> public ChildClass extends SuperClass implements MyInterface {
> // i won't override MyInterface.helpMe()
>
> public myMethod() {
> System.out.println("In ChildClass.myMethod()");
> }
> } // child ends.
>
> these set of classes ... each in its own file (obviously :) compiles
> without errors inside Eclipse Ganymede IDE. However i get a compilation
> error in ChildClass.java ... if i compile these classes individually
> using javac thru commandlind. The error thrown is "ChildClass must
> override helpMe() ... "

No, this set of classes does not compile in Eclipse or elsewhere, due to
syntax errors. This set of classes:

/* the interface */
public interface MyInterface {
public void helpMe();
}// end

public abstract class SuperClass {
public void helpMe() {
System.out.println("In SuperClass.helpMe()");
}
abstract public void myMethod();
} // super class ends

public class ChildClass extends SuperClass implements MyInterface {
// i won't override MyInterface.helpMe()

public void myMethod() {
System.out.println("In ChildClass.myMethod()");
}
} // child ends.

Compiles just fine either through Eclipse or Sun's javac 1.6.0_07, it is
perfectly valid Java. If you cannot compile *this* set of classes, state
which javac you are using.

Cheers,
Nicholas Sherlock
Previous Topic:Annotation processing configuration
Next Topic:Multi quick-fix not working
Goto Forum:
  


Current Time: Fri Apr 25 18:29:01 EDT 2025

Powered by FUDForum. Page generated in 0.06679 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top