Bug 334315 - [compiler] Problem types with missing superclass or superinterfaces should use Object for missing types
Summary: [compiler] Problem types with missing superclass or superinterfaces should us...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-13 15:20 EST by Olivier Thomann CLA
Modified: 2011-01-25 04:54 EST (History)
2 users (show)

See Also:


Attachments
Proposed fix + updated regression test (4.01 KB, patch)
2011-01-14 10:33 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.