Bug 12809 - Unimplemented methods should not prevent class from running
Summary: Unimplemented methods should not prevent class from running
Status: RESOLVED DUPLICATE of bug 3179
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC other
: P3 normal (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-04 11:41 EST by Peter Burka CLA
Modified: 2002-04-04 12:08 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Burka CLA 2002-04-04 11:41:45 EST
Build 20020321

I have a class Foo which subclasses an abstract class Bar.  Foo doesn't 
implement all of the abstract methods in Bar, so there are some compilation 
problems.

I tried to run the class on the knowledge that the unimplemented methods 
weren't used.  I had expected that the compiler would stub in those methods 
with implementations which threw an Error with an Unresolved compilation 
problem, or to allow the VM to catch the problems (AbstractMethodError).

However, the compiler seems to throw the error in the class' constructor!  This 
prevents me from using the class at all, even though the methods are not used.

I believe that the compiler should still allow me to use this class.
Comment 1 Olivier Thomann CLA 2002-04-04 11:52:24 EST
This looks like a duplicate of 3179 which has been fixed in the build 20020326. I I tried the 
following test case:

public abstract class Bar {
	
	abstract void 
foo();

}

public class Foo extends Bar {

	public static void main(String[] args) 
{
		Foo foo = new Foo();
		System.out.println(foo);
		foo.foo();
	}
}

If I 
comment out the line foo.foo(); I can successfully run the code. If I leave the code as is, I 
got:
java.lang.Error: Unresolved compilation problem: 
	Class must implement the 
inherited abstract method Bar.foo()

	at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at 
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
	at 
Foo.foo(Foo.java:9)
	at Foo.main(Foo.java:14)
Exception in thread "main" 

So this 
seems to be fixed.
Closed.

*** This bug has been marked as a duplicate of 3179 ***