Skip to content

UJMP v0.3.0 changes default locale and various system properties on initial use #17

@eomanis

Description

@eomanis

Specifically, it sets the default locale to Locale.US, and also sets these system properties:
"file.encoding" = "UTF-8"
"sun.jnu.encoding" = "UTF-8"
This happens in the private no-arg constructor of UJMPSettings (UJMPSettings:59).

We were happily developing a translated Swing application using ResourceBundles and then we were like, "Hey, where'd our texts go?" Because we hadn't maintained our English texts yet.

Currently we have this workaround in our application startup/preparation:

/**
 * <p>
 * Workaround for a bug in UJMP that causes global settings to be modified, such as {@link Locale#getDefault() the default locale} and various
 * {@link System#getProperty(String) system properties}.
 * </p>
 */
public static void initializeUjmp() {
	// Back up the global settings that are trashed by UJMPSettings's initial setup code
	Locale defaultLocale = Locale.getDefault();
	String sysPropFileEncoding = System.getProperty( "file.encoding" );
	String sysPropSunJnuEncoding = System.getProperty( "sun.jnu.encoding" );

	// Initialize UJMPSettings
	UJMPSettings.getInstance();

	// Undo UJMPSettings's damage
	Locale.setDefault( defaultLocale );
	System.setProperty( "file.encoding", sysPropFileEncoding );
	System.setProperty( "sun.jnu.encoding", sysPropSunJnuEncoding );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions