Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Jan 2008 21:09:57 GMT
From:      Bernhard Froehlich <decke@bluelife.at>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   java/119397: java/jdk16: Wrong locales with patchset 3
Message-ID:  <200801062109.m06L9vYt043212@www.freebsd.org>
Resent-Message-ID: <200801062120.m06LK2g4055671@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         119397
>Category:       java
>Synopsis:       java/jdk16: Wrong locales with patchset 3
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-java
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 06 21:20:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Bernhard Froehlich
>Release:        FreeBSD 7.0-RC1
>Organization:
>Environment:
FreeBSD chii.bluelife.at 7.0-RC1 FreeBSD 7.0-RC1 #1: Sat Dec 29 12:29:16 CET 2007     decke@chii.bluelife.at:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
All available locales are detected and replaced at build time in work/control/build/bsd-amd64/gensrc/sun/util/LocaleDataMetaInfo.java. With JDK 1.6 and patchset 3 the result is always "  ben sun/text/resources/ |  arn sun/text/resources/ " and is definitely wrong.


http://lists.freebsd.org/pipermail/freebsd-java/2007-December/007027.html
>How-To-Repeat:
Locale.getAvailableLocales() returns an String array with: "ben", "arn", "sun/text/resources/"


import java.util.Locale;
import sun.util.LocaleDataMetaInfo;

public class LocaleDebug
{
	public static void main(String[] args)
	{
		Locale[] locales = Locale.getAvailableLocales();

		for(int i=0; i < locales.length; i++)
			System.out.println(locales[i]);

		System.out.println("sun.text.resources.FormatData -> " +
		LocaleDataMetaInfo.getSupportedLocaleString("sun.text.resources.FormatData"));
	}
}
>Fix:
There are 2 files j2se/make/java/java/localegen.sh and j2se/make/java/java/genlocales.gmk that are responsible for detecting and generating the list of available locales.

All locales are formattet in genlocales.gmk and stored in a temporary file where one line should be one locale and seperated with newlines. I have found that this does not work because '\n' is interpreted as string and not as an escape character (newline) so the format of the file is wrong and causes the error.

@$(ECHO) $(subst .properties,'\n',$(Euro_Resources_properties)) > $@.tmp.euro;
@$(ECHO) $(subst .java,'\n',$(Euro_Resources_java)) >> $@.tmp.euro;


The second part is localegen.sh where this temporary file is read ...

localelist=`$NAWK -F$1_ '{print $2}' $2 | sort`

The second parameter of nawk contains a $ and is not escaped so it gets replaced by the shell and not passed thru to nawk as it was expected.


My attached fix is more like a workaround because it uses sed to reformat the badly formattet tempory file of locales.



Patch attached with submission follows:

--- ../../j2se/make/java/java/localegen.sh.orig	2008-01-06 16:38:14.000000000 +0100
+++ ../../j2se/make/java/java/localegen.sh	2008-01-06 16:51:26.000000000 +0100
@@ -22,7 +22,7 @@
 localelist=
 getlocalelist() {
     localelist=""
-    localelist=`$NAWK -F$1_ '{print $2}' $2 | sort`
+    localelist=`$SED -e 'y/ /\n/' -e 's/\\\n//g' $2 | $NAWK -F$1_ '{print \$2}' | sort`
 }
 
 sed_script="$SED -e \"s@^#warn .*@// -- This file was mechanically generated: Do not edit! -- //@\" " 


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801062109.m06L9vYt043212>