Bug 269535 - Unable to execute class, but no compilation issues
Summary: Unable to execute class, but no compilation issues
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-20 11:13 EDT by Christophe Elek CLA
Modified: 2009-04-28 03:56 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 Christophe Elek CLA 2009-03-20 11:13:37 EDT
in my class , if I have the following line

private static final SimpleDateFormat formatter = new SimpleDateFormat("DD HH:mm:ss SSSS'm's'");

I am getting a exception in initializer when running the main

this line allows me to run my main

private static final SimpleDateFormat formatter = new SimpleDateFormat("DD HH:mm:ss SSSS");

I believe the compiler should give me an error about the 'm's' no ?
Comment 1 Olivier Thomann CLA 2009-03-20 11:18:45 EDT
I guess:
private static final SimpleDateFormat formatter = new SimpleDateFormat("DD
HH:mm:ss SSSS'm's'");
is all on one line ?
Comment 2 Olivier Thomann CLA 2009-03-20 11:26:48 EDT
Is this the SimpleDateFormat class for icu or java.text ?
It looks like this constructor can potentially throw an exception.
So the code should rather be:
private static final SimpleDateFormat formatter = newFormatter();
private static SimpleDateFormat newFormatter() {
	SimpleDateFormat current = null;
try {
  current = new SimpleDateFormat("DDHH:mm:ss SSSS'm's'");
} catch(IllegalArgumentException e) {
  // handle exception
}
return current;
}

It is not up to the compiler to check the validity of the pattern.
Closing as INVALID.
Comment 3 Christophe Elek CLA 2009-03-20 11:32:23 EDT
Yes one line, so the String is valid 'm's' ? This is an exception at runtime ?
Comment 4 Srikanth Sankaran CLA 2009-04-28 03:56:29 EDT
Verified to be invalid.