Strange behaviour with ResourceBundle - SUN vs GCJ?

Martin Egholm Nielsen martin@egholm-nielsen.dk
Wed Mar 9 09:45:00 GMT 2005


Hi there,
I don't know if this may have been addressed before - or maybe even 
"solved" in newer GCJ releases.
I've seen it with both gcj 3.3.3 and 3.4.1. I have the class/application 
listed below. With SUNs VM I get the "expected" output:
0
1
Missing!
DONE!
Whereas when I run with GCJ (not GIJ) I get:
0
1
1
1
... continues, until the app is killed.
I know that the ResourceBundle class tries to load/find the given 
resource-bundle in the class "UserLog", but as the constructor is 
hidden, I don't see why it should be allowed for it to construct an 
instance?
I know how to work around it, but I just wondered...
// Martin
=============================
package men.log;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public final class UserLog
{
 /**
 * Hidden constructor!
 */
 private UserLog()
 {
 try
 {
 System.out.println("1");
 // Try to find (non-existing) "men.log.UserLog.properties"
 ResourceBundle.getBundle(UserLog.class.getName());
 System.out.println("2");
 } // try
 catch (MissingResourceException mre)
 {
 System.out.println("Missing!");
 } // catch
 } // constr.
 public static void main(String[] args)
 {
 System.out.println("0");
 UserLog ul = new UserLog();
 System.out.println("DONE!");
 } // main
} // UserLog
==========================


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /