Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324269 - "Could not find the main class. Program will exit" When an exception is thrown in a static variable
Summary: "Could not find the main class. Program will exit" When an exception is throw...
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-02 02:31 EDT by Chaiavi CLA
Modified: 2010-09-02 09:16 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chaiavi CLA 2010-09-02 02:31:43 EDT
Build Identifier: 20100617-1415

I have a simple runnable class (uses "public static void main(.....).

The class has a static variable which gets its value from using an other class in my case the line of code is as follows:

"private final static String TERM_ID = DBUtilsHS.lookupUserByName(hsSession, HS_TERM_NAME).getUserid().toString();"

The line of code above throws a null pointer exception which causes the IDE to show the following error message box:
"Could not find the main class. Program will exit"



IMHO this is just wrong! because it's misleading - the IDE can actually find the main class (it exists in the build directory as it should), it just can't instantiate it because of a prior exception thrown in a static variable.

Reproducible: Always

Steps to Reproduce:
1. Create a simple runnable java class (using (static public void main....)
2. Create a static variable which executes a method which throws a NullPointerException
3. See the misleading error message box
4. fix it

Thanks
:-)
Comment 1 Ayushman Jain CLA 2010-09-02 02:50:07 EDT
Moving to JDT/Debug

Testcase:

----------8<----------------------------------------------
package test;
public class Test {
    private static final String abc = test().toString();
    public static Object test(){
       return null;
    }
}
----------8<----------------------------------------------
Comment 2 Ayushman Jain CLA 2010-09-02 02:54:59 EDT
(In reply to comment #1)
> Moving to JDT/Debug
> 
> Testcase:

Correction 

----------8<----------------------------------------------
package test;
public class Test {
    private static final String abc = test().toString();
    public static Object test(){
       return null;
    }
    public static void main(String[] args) {
    }
}
----------8<----------------------------------------------
Comment 3 Darin Wright CLA 2010-09-02 09:16:15 EDT
The error is reported from the Java VM, not Eclipse.