Bug 334315

Summary: [compiler] Problem types with missing superclass or superinterfaces should use Object for missing types
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aniefer, jarthana
Version: 3.7   
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed fix + updated regression test none

Description Olivier Thomann CLA 2011-01-13 15:20:52 EST
When a type has a missing type binding for its superclass, it should dump java.lang.Object for the superclass, otherwise the class will never be able to load.
The user will get a java.lang.NoClassDefFoundError.
The problem occurred for Andrew who was debugging some code where the ant task superclass was missing. This prevents the problem method to be called and help the user to find out that the code didn't compile.
Comment 1 Olivier Thomann CLA 2011-01-13 15:25:59 EST
For example:
public class X extends Zork {
	public static void main(String[] args) {
	}
}

Would lead to this error at runtime:

Exception in thread "main" java.lang.NoClassDefFoundError: Zork
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Caused by: java.lang.ClassNotFoundException: Zork
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 12 more
Could not find the main class: X.  Program will exit.

instead of:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:

        at X.main(X.java:2)

This is not much helpful as is, but at least it shows that the type didn't compile properly instead of indicating a class loader/resolution issue.
Comment 2 Olivier Thomann CLA 2011-01-14 10:33:21 EST
Created attachment 186829 [details]
Proposed fix + updated regression test
Comment 3 Olivier Thomann CLA 2011-01-14 10:33:49 EST
Released for 3.7M5.
Comment 4 Jay Arthanareeswaran CLA 2011-01-25 04:54:23 EST
Verified for 3.7M5 using build I20110124-1800.