提交 b6363f21 编写于 作者: L lana

Merge

......@@ -53,7 +53,7 @@ FILES_export = \
#
# Extra cc/linker flags.
#
LDLIBS += dsound.lib winmm.lib user32.lib
LDLIBS += dsound.lib winmm.lib user32.lib ole32.lib
CPPFLAGS += \
-DUSE_DAUDIO=TRUE \
-I$(SHARE_SRC)/native/com/sun/media/sound \
......
......@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
tzdata2010l
tzdata2010o
......@@ -569,8 +569,8 @@ Rule HK 1953 only - Nov 1 3:30 0 -
Rule HK 1954 1964 - Mar Sun>=18 3:30 1:00 S
Rule HK 1954 only - Oct 31 3:30 0 -
Rule HK 1955 1964 - Nov Sun>=1 3:30 0 -
Rule HK 1965 1977 - Apr Sun>=16 3:30 1:00 S
Rule HK 1965 1977 - Oct Sun>=16 3:30 0 -
Rule HK 1965 1976 - Apr Sun>=16 3:30 1:00 S
Rule HK 1965 1976 - Oct Sun>=16 3:30 0 -
Rule HK 1973 only - Dec 30 3:30 1:00 S
Rule HK 1979 only - May Sun>=8 3:30 1:00 S
Rule HK 1979 only - Oct Sun>=16 3:30 0 -
......
......@@ -306,13 +306,26 @@ Zone Indian/Cocos 6:27:40 - LMT 1900
# http://www.timeanddate.com/news/time/fiji-dst-ends-march-2010.html
# </a>
# From Alexander Krivenyshev (2010-10-24):
# According to Radio Fiji and Fiji Times online, Fiji will end DST 3
# weeks earlier than expected - on March 6, 2011, not March 27, 2011...
# Here is confirmation from Government of the Republic of the Fiji Islands,
# Ministry of Information (fiji.gov.fj) web site:
# <a href="http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=2608:daylight-savings&catid=71:press-releases&Itemid=155">
# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=2608:daylight-savings&catid=71:press-releases&Itemid=155
# </a>
# or
# <a href="http://www.worldtimezone.com/dst_news/dst_news_fiji04.html">
# http://www.worldtimezone.com/dst_news/dst_news_fiji04.html
# </a>
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S
Rule Fiji 1999 2000 - Feb lastSun 3:00 0 -
Rule Fiji 2009 only - Nov 29 2:00 1:00 S
Rule Fiji 2010 only - Mar lastSun 3:00 0 -
Rule Fiji 2010 only - Oct 24 2:00 1:00 S
Rule Fiji 2011 only - Mar lastSun 3:00 0 -
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Fiji 11:53:40 - LMT 1915 Oct 26 # Suva
12:00 Fiji FJ%sT # Fiji Time
......@@ -509,11 +522,21 @@ Zone Pacific/Pago_Pago 12:37:12 - LMT 1879 Jul 5
# http://www.parliament.gov.ws/documents/acts/Daylight%20Saving%20Act%20%202009%20%28English%29%20-%20Final%207-7-091.pdf
# </a>
# From Raymond Hughes (2010-10-07):
# Please see
# <a href="http://www.mcil.gov.ws">
# http://www.mcil.gov.ws
# </a>,
# the Ministry of Commerce, Industry and Labour (sideframe) "Last Sunday
# September 2010 (26/09/10) - adjust clocks forward from 12:00 midnight
# to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks
# backwards from 1:00am to 12:00am"
Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5
-11:26:56 - LMT 1911
-11:30 - SAMT 1950 # Samoa Time
-11:00 - WST 2010 Sep 26
-11:00 1:00 WSDT 2011 Apr 3
-11:00 1:00 WSDT 2011 Apr 3 1:00
-11:00 - WST
# Solomon Is
......
......@@ -63,7 +63,7 @@ AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island
AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay
AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills
AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula
AQ -7824+10654 Antarctica/Vostok Vostok Station, S Magnetic Pole
AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
AQ -5430+15857 Antarctica/Macquarie Macquarie Island Station, Macquarie Island
......
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,6 +25,8 @@
package java.awt;
import java.beans.ConstructorProperties;
/**
* The <code>BasicStroke</code> class defines a basic set of rendering
* attributes for the outlines of graphics primitives, which are rendered
......@@ -183,6 +185,7 @@ public class BasicStroke implements Stroke {
* <code>dash</code> is zero
* @throws IllegalArgumentException if dash lengths are all zero.
*/
@ConstructorProperties({ "lineWidth", "endCap", "lineJoin", "miterLimit", "dashArray", "dashPhase" })
public BasicStroke(float width, int cap, int join, float miterlimit,
float dash[], float dash_phase) {
if (width < 0.0f) {
......
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -29,6 +29,7 @@ import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.AffineTransform;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
* The <code>GradientPaint</code> class provides a way to fill
......@@ -166,6 +167,7 @@ public class GradientPaint implements Paint {
* @throws NullPointerException if either one of colors or points
* is null
*/
@ConstructorProperties({ "point1", "color1", "point2", "color2", "cyclic" })
public GradientPaint(Point2D pt1,
Color color1,
Point2D pt2,
......
/*
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -26,10 +26,10 @@
package java.awt;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
* The {@code LinearGradientPaint} class provides a way to fill
......@@ -271,6 +271,7 @@ public final class LinearGradientPaint extends MultipleGradientPaint {
* or a {@code fractions} value is less than 0.0 or greater than 1.0,
* or the {@code fractions} are not provided in strictly increasing order
*/
@ConstructorProperties({ "startPoint", "endPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" })
public LinearGradientPaint(Point2D start, Point2D end,
float[] fractions, Color[] colors,
CycleMethod cycleMethod,
......
/*
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -29,6 +29,7 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
* The {@code RadialGradientPaint} class provides a way to fill a shape with
......@@ -428,6 +429,7 @@ public final class RadialGradientPaint extends MultipleGradientPaint {
* or a {@code fractions} value is less than 0.0 or greater than 1.0,
* or the {@code fractions} are not provided in strictly increasing order
*/
@ConstructorProperties({ "centerPoint", "radius", "focusPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" })
public RadialGradientPaint(Point2D center,
float radius,
Point2D focus,
......
......@@ -1831,7 +1831,11 @@ public abstract class Toolkit {
desktopProperties.put(name, newValue);
}
desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
// Don't fire change event if old and new values are null.
// It helps to avoid recursive resending of WM_THEMECHANGED
if (oldValue != null || newValue != null) {
desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
}
}
/**
......
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -26,6 +26,7 @@
package java.awt.geom;
import java.awt.Shape;
import java.beans.ConstructorProperties;
/**
* The <code>AffineTransform</code> class represents a 2D affine transform
......@@ -508,6 +509,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
* @param m12 the Y coordinate translation element of the 3x3 matrix
* @since 1.2
*/
@ConstructorProperties({ "scaleX", "shearY", "shearX", "scaleY", "translateX", "translateY" })
public AffineTransform(float m00, float m10,
float m01, float m11,
float m02, float m12) {
......
......@@ -44,11 +44,12 @@ import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.text.spi.DateFormatSymbolsProvider;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.spi.LocaleServiceProvider;
import sun.util.LocaleServiceProviderPool;
import sun.util.TimeZoneNameUtility;
......@@ -321,20 +322,64 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @since 1.6
*/
public static final DateFormatSymbols getInstance(Locale locale) {
DateFormatSymbols dfs = getProviderInstance(locale);
if (dfs != null) {
return dfs;
}
return (DateFormatSymbols) getCachedInstance(locale).clone();
}
/**
* Returns a DateFormatSymbols provided by a provider or found in
* the cache. Note that this method returns a cached instance,
* not its clone. Therefore, the instance should never be given to
* an application.
*/
static final DateFormatSymbols getInstanceRef(Locale locale) {
DateFormatSymbols dfs = getProviderInstance(locale);
if (dfs != null) {
return dfs;
}
return getCachedInstance(locale);
}
private static DateFormatSymbols getProviderInstance(Locale locale) {
DateFormatSymbols providersInstance = null;
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
if (pool.hasProviders()) {
DateFormatSymbols providersInstance = pool.getLocalizedObject(
DateFormatSymbolsGetter.INSTANCE, locale);
if (providersInstance != null) {
return providersInstance;
providersInstance = pool.getLocalizedObject(
DateFormatSymbolsGetter.INSTANCE, locale);
}
return providersInstance;
}
/**
* Returns a cached DateFormatSymbols if it's found in the
* cache. Otherwise, this method returns a newly cached instance
* for the given locale.
*/
private static DateFormatSymbols getCachedInstance(Locale locale) {
SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
DateFormatSymbols dfs = null;
if (ref == null || (dfs = ref.get()) == null) {
dfs = new DateFormatSymbols(locale);
ref = new SoftReference<DateFormatSymbols>(dfs);
SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
if (x != null) {
DateFormatSymbols y = x.get();
if (y != null) {
dfs = y;
} else {
// Replace the empty SoftReference with ref.
cachedInstances.put(locale, ref);
}
}
}
return new DateFormatSymbols(locale);
return dfs;
}
/**
......@@ -597,56 +642,44 @@ public class DateFormatSymbols implements Serializable, Cloneable {
static final int millisPerHour = 60*60*1000;
/**
* Cache to hold the FormatData and TimeZoneNames ResourceBundles
* of a Locale.
* Cache to hold DateFormatSymbols instances per Locale.
*/
private static Hashtable cachedLocaleData = new Hashtable(3);
private static final ConcurrentMap<Locale, SoftReference<DateFormatSymbols>> cachedInstances
= new ConcurrentHashMap<Locale, SoftReference<DateFormatSymbols>>(3);
/**
* Look up resource data for the desiredLocale in the cache; update the
* cache if necessary.
*/
private static ResourceBundle cacheLookup(Locale desiredLocale) {
ResourceBundle rb;
SoftReference data
= (SoftReference)cachedLocaleData.get(desiredLocale);
if (data == null) {
rb = LocaleData.getDateFormatData(desiredLocale);
data = new SoftReference(rb);
cachedLocaleData.put(desiredLocale, data);
} else {
if ((rb = (ResourceBundle)data.get()) == null) {
rb = LocaleData.getDateFormatData(desiredLocale);
data = new SoftReference(rb);
}
private void initializeData(Locale desiredLocale) {
locale = desiredLocale;
// Copy values of a cached instance if any.
SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
DateFormatSymbols dfs;
if (ref != null && (dfs = ref.get()) != null) {
copyMembers(dfs, this);
return;
}
return rb;
}
private void initializeData(Locale desiredLocale) {
int i;
ResourceBundle resource = cacheLookup(desiredLocale);
// Initialize the fields from the ResourceBundle for locale.
ResourceBundle resource = LocaleData.getDateFormatData(locale);
// FIXME: cache only ResourceBundle. Hence every time, will do
// getObject(). This won't be necessary if the Resource itself
// is cached.
eras = (String[])resource.getObject("Eras");
eras = resource.getStringArray("Eras");
months = resource.getStringArray("MonthNames");
shortMonths = resource.getStringArray("MonthAbbreviations");
String[] lWeekdays = resource.getStringArray("DayNames");
weekdays = new String[8];
weekdays[0] = ""; // 1-based
for (i=0; i<lWeekdays.length; i++)
weekdays[i+1] = lWeekdays[i];
String[] sWeekdays = resource.getStringArray("DayAbbreviations");
shortWeekdays = new String[8];
shortWeekdays[0] = ""; // 1-based
for (i=0; i<sWeekdays.length; i++)
shortWeekdays[i+1] = sWeekdays[i];
ampms = resource.getStringArray("AmPmMarkers");
localPatternChars = resource.getString("DateTimePatternChars");
locale = desiredLocale;
// Day of week names are stored in a 1-based array.
weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));
}
private static String[] toOneBasedArray(String[] src) {
int len = src.length;
String[] dst = new String[len + 1];
dst[0] = "";
for (int i = 0; i < len; i++) {
dst[i + 1] = src[i];
}
return dst;
}
/**
......
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -46,9 +46,10 @@ import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Currency;
import java.util.Hashtable;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import sun.util.resources.LocaleData;
......@@ -394,14 +395,14 @@ public class DecimalFormat extends NumberFormat {
public DecimalFormat() {
Locale def = Locale.getDefault(Locale.Category.FORMAT);
// try to get the pattern from the cache
String pattern = (String) cachedLocaleData.get(def);
String pattern = cachedLocaleData.get(def);
if (pattern == null) { /* cache miss */
// Get the pattern for the default locale.
ResourceBundle rb = LocaleData.getNumberFormatData(def);
String[] all = rb.getStringArray("NumberPatterns");
pattern = all[0];
/* update cache */
cachedLocaleData.put(def, pattern);
cachedLocaleData.putIfAbsent(def, pattern);
}
// Always applyPattern after the symbols are set
......@@ -3272,5 +3273,6 @@ public class DecimalFormat extends NumberFormat {
/**
* Cache to hold the NumberPattern of a Locale.
*/
private static Hashtable cachedLocaleData = new Hashtable(3);
private static final ConcurrentMap<Locale, String> cachedLocaleData
= new ConcurrentHashMap<Locale, String>(3);
}
......@@ -44,13 +44,14 @@ import java.io.ObjectInputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import sun.util.calendar.CalendarUtils;
import sun.util.calendar.ZoneInfoFile;
import sun.util.resources.LocaleData;
......@@ -503,14 +504,14 @@ public class SimpleDateFormat extends DateFormat {
/**
* Cache to hold the DateTimePatterns of a Locale.
*/
private static Hashtable<String,String[]> cachedLocaleData
= new Hashtable<String,String[]>(3);
private static final ConcurrentMap<String, String[]> cachedLocaleData
= new ConcurrentHashMap<String, String[]>(3);
/**
* Cache NumberFormat instances with Locale key.
*/
private static Hashtable<Locale,NumberFormat> cachedNumberFormatData
= new Hashtable<Locale,NumberFormat>(3);
private static final ConcurrentMap<Locale, NumberFormat> cachedNumberFormatData
= new ConcurrentHashMap<Locale, NumberFormat>(3);
/**
* The Locale used to instantiate this
......@@ -579,7 +580,7 @@ public class SimpleDateFormat extends DateFormat {
initializeCalendar(locale);
this.pattern = pattern;
this.formatData = DateFormatSymbols.getInstance(locale);
this.formatData = DateFormatSymbols.getInstanceRef(locale);
this.locale = locale;
initialize(locale);
}
......@@ -632,9 +633,9 @@ public class SimpleDateFormat extends DateFormat {
dateTimePatterns = r.getStringArray("DateTimePatterns");
}
/* update cache */
cachedLocaleData.put(key, dateTimePatterns);
cachedLocaleData.putIfAbsent(key, dateTimePatterns);
}
formatData = DateFormatSymbols.getInstance(loc);
formatData = DateFormatSymbols.getInstanceRef(loc);
if ((timeStyle >= 0) && (dateStyle >= 0)) {
Object[] dateTimeArgs = {dateTimePatterns[timeStyle],
dateTimePatterns[dateStyle + 4]};
......@@ -665,7 +666,7 @@ public class SimpleDateFormat extends DateFormat {
numberFormat.setGroupingUsed(false);
/* update cache */
cachedNumberFormatData.put(loc, numberFormat);
cachedNumberFormatData.putIfAbsent(loc, numberFormat);
}
numberFormat = (NumberFormat) numberFormat.clone();
......@@ -897,7 +898,7 @@ public class SimpleDateFormat extends DateFormat {
* so we can call it from readObject().
*/
private void initializeDefaultCentury() {
calendar.setTime( new Date() );
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add( Calendar.YEAR, -80 );
parseAmbiguousDatesAsAfter(calendar.getTime());
}
......@@ -921,7 +922,7 @@ public class SimpleDateFormat extends DateFormat {
* @since 1.2
*/
public void set2DigitYearStart(Date startDate) {
parseAmbiguousDatesAsAfter(startDate);
parseAmbiguousDatesAsAfter(new Date(startDate.getTime()));
}
/**
......@@ -934,7 +935,7 @@ public class SimpleDateFormat extends DateFormat {
* @since 1.2
*/
public Date get2DigitYearStart() {
return defaultCenturyStart;
return (Date) defaultCenturyStart.clone();
}
/**
......
......@@ -51,6 +51,8 @@ import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import sun.util.BuddhistCalendar;
import sun.util.calendar.ZoneInfo;
import sun.util.resources.LocaleData;
......@@ -837,7 +839,8 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
* Cache to hold the firstDayOfWeek and minimalDaysInFirstWeek
* of a Locale.
*/
private static Hashtable<Locale, int[]> cachedLocaleData = new Hashtable<Locale, int[]>(3);
private static final ConcurrentMap<Locale, int[]> cachedLocaleData
= new ConcurrentHashMap<Locale, int[]>(3);
// Special values of stamp[]
/**
......@@ -1022,7 +1025,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
// returns a BuddhistCalendar instance.
if ("th".equals(aLocale.getLanguage())
&& ("TH".equals(aLocale.getCountry()))) {
cal = new BuddhistCalendar(zone, aLocale);
cal = new BuddhistCalendar(zone, aLocale);
} else {
cal = new GregorianCalendar(zone, aLocale);
}
......@@ -2588,7 +2591,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
data = new int[2];
data[0] = Integer.parseInt(bundle.getString("firstDayOfWeek"));
data[1] = Integer.parseInt(bundle.getString("minimalDaysInFirstWeek"));
cachedLocaleData.put(desiredLocale, data);
cachedLocaleData.putIfAbsent(desiredLocale, data);
}
firstDayOfWeek = data[0];
minimalDaysInFirstWeek = data[1];
......
......@@ -758,7 +758,7 @@ public final class Locale implements Cloneable, Serializable {
}
private static void initDefault() {
String language, region, country, variant;
String language, region, script, country, variant;
language = AccessController.doPrivileged(
new GetPropertyAction("user.language", "en"));
// for compatibility, check for old user.region property
......@@ -774,43 +774,41 @@ public final class Locale implements Cloneable, Serializable {
country = region;
variant = "";
}
script = "";
} else {
script = AccessController.doPrivileged(
new GetPropertyAction("user.script", ""));
country = AccessController.doPrivileged(
new GetPropertyAction("user.country", ""));
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
}
defaultLocale = getInstance(language, country, variant);
defaultLocale = getInstance(language, script, country, variant, null);
}
private static void initDefault(Locale.Category category) {
String language, region, country, variant;
// make sure defaultLocale is initialized
if (defaultLocale == null) {
initDefault();
}
Locale defaultCategoryLocale = getInstance(
AccessController.doPrivileged(
new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())),
AccessController.doPrivileged(
new GetPropertyAction(category.scriptKey, defaultLocale.getScript())),
AccessController.doPrivileged(
new GetPropertyAction(category.countryKey, defaultLocale.getCountry())),
AccessController.doPrivileged(
new GetPropertyAction(category.variantKey, defaultLocale.getVariant())),
null);
switch (category) {
case DISPLAY:
language = AccessController.doPrivileged(
new GetPropertyAction("user.language.display", ""));
if ("".equals(language)) {
defaultDisplayLocale = getDefault();
} else {
country = AccessController.doPrivileged(
new GetPropertyAction("user.country.display", ""));
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant.display", ""));
defaultDisplayLocale = getInstance(language, country, variant);
}
defaultDisplayLocale = defaultCategoryLocale;
break;
case FORMAT:
language = AccessController.doPrivileged(
new GetPropertyAction("user.language.format", ""));
if ("".equals(language)) {
defaultFormatLocale = getDefault();
} else {
country = AccessController.doPrivileged(
new GetPropertyAction("user.country.format", ""));
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant.format", ""));
defaultFormatLocale = getInstance(language, country, variant);
}
defaultFormatLocale = defaultCategoryLocale;
break;
}
}
......@@ -2124,13 +2122,31 @@ public final class Locale implements Cloneable, Serializable {
* Category used to represent the default locale for
* displaying user interfaces.
*/
DISPLAY,
DISPLAY("user.language.display",
"user.script.display",
"user.country.display",
"user.variant.display"),
/**
* Category used to represent the default locale for
* formatting dates, numbers, and/or currencies.
*/
FORMAT,
FORMAT("user.language.format",
"user.script.format",
"user.country.format",
"user.variant.format");
Category(String languageKey, String scriptKey, String countryKey, String variantKey) {
this.languageKey = languageKey;
this.scriptKey = scriptKey;
this.countryKey = countryKey;
this.variantKey = variantKey;
}
final String languageKey;
final String scriptKey;
final String countryKey;
final String variantKey;
}
/**
......
......@@ -160,11 +160,6 @@ abstract public class TimeZone implements Serializable, Cloneable {
private static final int ONE_HOUR = 60*ONE_MINUTE;
private static final int ONE_DAY = 24*ONE_HOUR;
/**
* Cache to hold the SimpleDateFormat objects for a Locale.
*/
private static Hashtable cachedLocaleData = new Hashtable(3);
// Proclaim serialization compatibility with JDK 1.1
static final long serialVersionUID = 3581463369166924961L;
......
......@@ -24,8 +24,10 @@
*/
package javax.swing;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import javax.swing.border.*;
/**
......@@ -636,4 +638,125 @@ public class BorderFactory
Icon tileIcon) {
return new MatteBorder(top, left, bottom, right, tileIcon);
}
//// StrokeBorder //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/**
* Creates a border of the specified {@code stroke}.
* The component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @return the {@code Border} object
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*
* @since 1.7
*/
public static Border createStrokeBorder(BasicStroke stroke) {
return new StrokeBorder(stroke);
}
/**
* Creates a border of the specified {@code stroke} and {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @param paint the {@link Paint} object used to generate a color
* @return the {@code Border} object
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*
* @since 1.7
*/
public static Border createStrokeBorder(BasicStroke stroke, Paint paint) {
return new StrokeBorder(stroke, paint);
}
//// DashedBorder //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
private static Border sharedDashedBorder;
/**
* Creates a dashed border of the specified {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
* The width of a dash line is equal to {@code 1}.
* The relative length of a dash line and
* the relative spacing between dash lines are equal to {@code 1}.
* A dash line is not rounded.
*
* @param paint the {@link Paint} object used to generate a color
* @return the {@code Border} object
*
* @since 1.7
*/
public static Border createDashedBorder(Paint paint) {
return createDashedBorder(paint, 1.0f, 1.0f, 1.0f, false);
}
/**
* Creates a dashed border of the specified {@code paint},
* relative {@code length}, and relative {@code spacing}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
* The width of a dash line is equal to {@code 1}.
* A dash line is not rounded.
*
* @param paint the {@link Paint} object used to generate a color
* @param length the relative length of a dash line
* @param spacing the relative spacing between dash lines
* @return the {@code Border} object
*
* @throws IllegalArgumentException if the specified {@code length} is less than {@code 1}, or
* if the specified {@code spacing} is less than {@code 0}
* @since 1.7
*/
public static Border createDashedBorder(Paint paint, float length, float spacing) {
return createDashedBorder(paint, 1.0f, length, spacing, false);
}
/**
* Creates a dashed border of the specified {@code paint}, {@code thickness},
* line shape, relative {@code length}, and relative {@code spacing}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param paint the {@link Paint} object used to generate a color
* @param thickness the width of a dash line
* @param length the relative length of a dash line
* @param spacing the relative spacing between dash lines
* @param rounded whether or not line ends should be round
* @return the {@code Border} object
*
* @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or
* if the specified {@code length} is less than {@code 1}, or
* if the specified {@code spacing} is less than {@code 0}
* @since 1.7
*/
public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {
boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);
if (shared && (sharedDashedBorder != null)) {
return sharedDashedBorder;
}
if (thickness < 1.0f) {
throw new IllegalArgumentException("thickness is less than 1");
}
if (length < 1.0f) {
throw new IllegalArgumentException("length is less than 1");
}
if (spacing < 0.0f) {
throw new IllegalArgumentException("spacing is less than 0");
}
int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;
int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;
float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };
Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);
if (shared) {
sharedDashedBorder = border;
}
return border;
}
}
......@@ -1322,13 +1322,11 @@ public class DebugGraphics extends Graphics {
}
String toShortString() {
StringBuffer buffer = new StringBuffer("Graphics" + (isDrawingBuffer() ? "<B>" : "") + "(" + graphicsID + "-" + debugOptions + ")");
return buffer.toString();
return "Graphics" + (isDrawingBuffer() ? "<B>" : "") + "(" + graphicsID + "-" + debugOptions + ")";
}
String pointToString(int x, int y) {
StringBuffer buffer = new StringBuffer("(" + x + ", " + y + ")");
return buffer.toString();
return "(" + x + ", " + y + ")";
}
/** Enables/disables diagnostic information about every graphics
......
......@@ -4783,21 +4783,11 @@ public abstract class JComponent extends Container implements Serializable,
* @param y the y value of the dirty region
* @param width the width of the dirty region
* @param height the height of the dirty region
* @see #isPaintingOrigin()
* @see java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
*/
public void repaint(long tm, int x, int y, int width, int height) {
Container p = this;
while ((p = p.getParent()) instanceof JComponent) {
JComponent jp = (JComponent) p;
if (jp.isPaintingOrigin()) {
Rectangle rectangle = SwingUtilities.convertRectangle(
this, new Rectangle(x, y, width, height), jp);
jp.repaint(tm,
rectangle.x, rectangle.y, rectangle.width, rectangle.height);
return;
}
}
RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height);
}
......@@ -4808,6 +4798,7 @@ public abstract class JComponent extends Container implements Serializable,
* currently pending events have been dispatched.
*
* @param r a <code>Rectangle</code> containing the dirty region
* @see #isPaintingOrigin()
* @see java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
*/
......@@ -4912,13 +4903,19 @@ public abstract class JComponent extends Container implements Serializable,
}
/**
* Returns true if a paint triggered on a child component should cause
* Returns {@code true} if a paint triggered on a child component should cause
* painting to originate from this Component, or one of its ancestors.
* <p/>
* Calling {@link JComponent#repaint} on a Swing component will be delegated to
* the first ancestor which {@code isPaintingOrigin()} returns {@true},
* if there are any.
* <p/>
* {@code JComponent} subclasses that need to be repainted when any of their
* children are repainted should override this method to return {@code true}.
*
* @return true if painting should originate from this Component or
* one of its ancestors.
* @return always returns {@code false}
*/
boolean isPaintingOrigin() {
protected boolean isPaintingOrigin() {
return false;
}
......
......@@ -303,10 +303,9 @@ public class JDialog extends Dialog implements WindowConstants,
* @param modal specifies whether dialog blocks user input to other top-level
* windows when shown. If {@code true}, the modality type property is set to
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
* @param gc the {@code GraphicsConfiguration}
* of the target screen device. If {@code gc} is
* {@code null}, the same
* {@code GraphicsConfiguration} as the owning Frame is used.
* @param gc the {@code GraphicsConfiguration} of the target screen device;
* if {@code null}, the default system {@code GraphicsConfiguration}
* is assumed
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
* returns {@code true}.
* @see java.awt.Dialog.ModalityType
......@@ -441,10 +440,9 @@ public class JDialog extends Dialog implements WindowConstants,
* @param modal specifies whether dialog blocks user input to other top-level
* windows when shown. If {@code true}, the modality type property is set to
* {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless
* @param gc the {@code GraphicsConfiguration}
* of the target screen device. If {@code gc} is
* {@code null}, the same
* {@code GraphicsConfiguration} as the owning Dialog is used.
* @param gc the {@code GraphicsConfiguration} of the target screen device;
* if {@code null}, the default system {@code GraphicsConfiguration}
* is assumed
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
* returns {@code true}.
* @see java.awt.Dialog.ModalityType
......@@ -612,10 +610,8 @@ public class JDialog extends Dialog implements WindowConstants,
* windows when shown. {@code null} value and unsupported modality
* types are equivalent to {@code MODELESS}
* @param gc the {@code GraphicsConfiguration} of the target screen device;
* if {@code null}, the {@code GraphicsConfiguration} from the owning
* window is used; if {@code owner} is also {@code null}, the
* system default {@code GraphicsConfiguration} is assumed
*
* if {@code null}, the default system {@code GraphicsConfiguration}
* is assumed
* @throws IllegalArgumentException
* if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
* or {@link java.awt.Frame Frame}
......
......@@ -384,7 +384,7 @@ public final class JLayer<V extends Component>
* @return true
* @see JComponent#isPaintingOrigin()
*/
boolean isPaintingOrigin() {
protected boolean isPaintingOrigin() {
return true;
}
......
......@@ -637,14 +637,14 @@ public class JViewport extends JComponent implements Accessible
}
/**
* Returns true if scroll mode is a BACKINGSTORE_SCROLL_MODE to cause
* painting to originate from <code>JViewport</code>, or one of its
* ancestors. Otherwise returns false.
* Returns true if scroll mode is a {@code BACKINGSTORE_SCROLL_MODE} to cause
* painting to originate from {@code JViewport}, or one of its
* ancestors. Otherwise returns {@code false}.
*
* @return true if if scroll mode is a BACKINGSTORE_SCROLL_MODE.
* @return true if if scroll mode is a {@code BACKINGSTORE_SCROLL_MODE}.
* @see JComponent#isPaintingOrigin()
*/
boolean isPaintingOrigin() {
protected boolean isPaintingOrigin() {
return scrollMode == BACKINGSTORE_SCROLL_MODE;
}
......
......@@ -438,6 +438,7 @@ public class RepaintManager
* @param y Y coordinate of the region to repaint
* @param w Width of the region to repaint
* @param h Height of the region to repaint
* @see JComponent#isPaintingOrigin()
* @see JComponent#repaint
*/
public void addDirtyRegion(JComponent c, int x, int y, int w, int h)
......@@ -447,6 +448,16 @@ public class RepaintManager
delegate.addDirtyRegion(c, x, y, w, h);
return;
}
Container p = c;
while ((p = p.getParent()) instanceof JComponent) {
JComponent jp = (JComponent) p;
if (jp.isPaintingOrigin()) {
Rectangle rectangle = SwingUtilities.convertRectangle(
c, new Rectangle(x, y, w, h), jp);
jp.repaint(0, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
return;
}
}
addDirtyRegion0(c, x, y, w, h);
}
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
import java.beans.ConstructorProperties;
/**
* A class which implements a border of an arbitrary stroke.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI
* between applications running the same version of Swing.
* As of 1.4, support for long term storage of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Sergey A. Malenkov
*
* @since 1.7
*/
public class StrokeBorder extends AbstractBorder {
private final BasicStroke stroke;
private final Paint paint;
/**
* Creates a border of the specified {@code stroke}.
* The component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*/
public StrokeBorder(BasicStroke stroke) {
this(stroke, null);
}
/**
* Creates a border of the specified {@code stroke} and {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @param paint the {@link Paint} object used to generate a color
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*/
@ConstructorProperties({ "stroke", "paint" })
public StrokeBorder(BasicStroke stroke, Paint paint) {
if (stroke == null) {
throw new NullPointerException("border's stroke");
}
this.stroke = stroke;
this.paint = paint;
}
/**
* Paints the border for the specified component
* with the specified position and size.
*
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*
* @throws NullPointerException if the specified {@code c} or {@code g} are {@code null}
*/
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
float size = this.stroke.getLineWidth();
if (size > 0.0f) {
g = g.create();
if (g instanceof Graphics2D) {
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(this.stroke);
g2d.setPaint(this.paint != null ? this.paint : c.getForeground());
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.draw(new Rectangle2D.Float(x + size / 2, y + size / 2, width - size, height - size));
}
g.dispose();
}
}
/**
* Reinitializes the {@code insets} parameter
* with this border's current insets.
* All insets are equal to the line width of the stroke.
*
* @param c the component for which this border insets value applies
* @param insets the {@code Insets} object to be reinitialized
* @return the reinitialized {@code insets} parameter
*
* @throws NullPointerException if the specified {@code insets} is {@code null}
*/
@Override
public Insets getBorderInsets(Component c, Insets insets) {
int size = (int) Math.ceil(this.stroke.getLineWidth());
insets.set(size, size, size, size);
return insets;
}
/**
* Returns the {@link BasicStroke} object used to stroke a shape
* during the border rendering.
*
* @return the {@link BasicStroke} object
*/
public BasicStroke getStroke() {
return this.stroke;
}
/**
* Returns the {@link Paint} object used to generate a color
* during the border rendering.
*
* @return the {@link Paint} object or {@code null}
* if the {@code paint} parameter is not set
*/
public Paint getPaint() {
return this.paint;
}
}
......@@ -362,6 +362,14 @@ public class BasicScrollPaneUI
* @since 1.6
*/
public int getBaseline(JComponent c, int width, int height) {
if (c == null) {
throw new NullPointerException("Component must be non-null");
}
if (width < 0 || height < 0) {
throw new IllegalArgumentException("Width and height must be >= 0");
}
JViewport viewport = scrollpane.getViewport();
Insets spInsets = scrollpane.getInsets();
int y = spInsets.top;
......
......@@ -115,10 +115,7 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
return new SynthTabbedPaneUI();
}
private SynthTabbedPaneUI() {
}
private boolean scrollableTabLayoutEnabled() {
private boolean scrollableTabLayoutEnabled() {
return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT);
}
......
......@@ -186,6 +186,9 @@ public class DefaultTableCellRenderer extends JLabel
*/
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (table == null) {
return this;
}
Color fg = null;
Color bg = null;
......
......@@ -1334,13 +1334,13 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
&& component.getClientProperty("JPasswordField.cutCopyAllowed") !=
Boolean.TRUE) {
//fix for 4793761
StringBuffer txt = null;
StringBuilder txt = null;
char echoChar = ((JPasswordField)component).getEchoChar();
int p0 = Math.min(getDot(), getMark());
int p1 = Math.max(getDot(), getMark());
for (int i = p0; i < p1; i++) {
if (txt == null) {
txt = new StringBuffer();
txt = new StringBuilder();
}
txt.append(echoChar);
}
......@@ -1675,7 +1675,6 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
}
return;
}
int adjust = 0;
int offset = e.getOffset();
int length = e.getLength();
int newDot = dot;
......@@ -1759,7 +1758,6 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
}
int offs0 = e.getOffset();
int offs1 = offs0 + e.getLength();
int adjust = 0;
int newDot = dot;
boolean adjustDotBias = false;
int newMark = mark;
......
......@@ -132,7 +132,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
// install the content
Content c = getContent();
int n = data.length;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
ElementSpec es = data[i];
if (es.getLength() > 0) {
......@@ -191,7 +191,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
// install the content
Content c = getContent();
int n = data.length;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
ElementSpec es = data[i];
if (es.getLength() > 0) {
......
......@@ -30,7 +30,6 @@ import java.text.*;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
/**
* <code>InternationalFormatter</code> extends <code>DefaultFormatter</code>,
......@@ -875,7 +874,6 @@ public class InternationalFormatter extends DefaultFormatter {
(f instanceof AttributedCharacterIterator.Attribute)) {
AttributedCharacterIterator.Attribute field =
(AttributedCharacterIterator.Attribute)f;
int index = 0;
iterator.first();
while (iterator.getIndex() < start) {
......
......@@ -35,10 +35,7 @@ import java.util.HashMap;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.*;
......@@ -4058,7 +4055,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
private static final Object KEYMAP_TABLE =
new StringBuilder("JTextComponent_KeymapTable");
private JTextComponent editor;
//
// member variables used for on-the-spot input method
// editing style support
......@@ -4748,14 +4745,14 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
processKeyEvent(ke);
}
} else {
StringBuffer strBuf = new StringBuffer();
StringBuilder strBuf = new StringBuilder();
for (char c = text.current(); commitCount > 0;
c = text.next(), commitCount--) {
strBuf.append(c);
}
// map it to an ActionEvent
mapCommittedTextToAction(new String(strBuf));
mapCommittedTextToAction(strBuf.toString());
}
// Remember latest committed text end index
......@@ -4801,7 +4798,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
private void createComposedTextAttribute(int composedIndex,
AttributedCharacterIterator text) {
Document doc = getDocument();
StringBuffer strBuf = new StringBuffer();
StringBuilder strBuf = new StringBuilder();
// create attributed string with no attributes
for (char c = text.setIndex(composedIndex);
......@@ -4809,7 +4806,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
strBuf.append(c);
}
composedTextContent = new String(strBuf);
composedTextContent = strBuf.toString();
composedTextAttribute = new SimpleAttributeSet();
composedTextAttribute.addAttribute(StyleConstants.ComposedTextAttribute,
new AttributedString(text, composedIndex, text.getEndIndex()));
......
......@@ -29,7 +29,6 @@ import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
/**
* <code>MaskFormatter</code> is used to format and edit strings. The behavior
......@@ -385,7 +384,7 @@ public class MaskFormatter extends DefaultFormatter {
*/
public String valueToString(Object value) throws ParseException {
String sValue = (value == null) ? "" : value.toString();
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
String placeholder = getPlaceholder();
int[] valueCounter = { 0 };
......@@ -484,7 +483,7 @@ public class MaskFormatter extends DefaultFormatter {
* Invokes <code>append</code> on the mask characters in
* <code>mask</code>.
*/
private void append(StringBuffer result, String value, int[] index,
private void append(StringBuilder result, String value, int[] index,
String placeholder, MaskCharacter[] mask)
throws ParseException {
for (int counter = 0, maxCounter = mask.length;
......@@ -611,13 +610,13 @@ public class MaskFormatter extends DefaultFormatter {
* Removes the literal characters from the passed in string.
*/
private String stripLiteralChars(String string) {
StringBuffer sb = null;
StringBuilder sb = null;
int last = 0;
for (int counter = 0, max = string.length(); counter < max; counter++){
if (isLiteral(counter)) {
if (sb == null) {
sb = new StringBuffer();
sb = new StringBuilder();
if (counter > 0) {
sb.append(string.substring(0, counter));
}
......@@ -715,10 +714,10 @@ public class MaskFormatter extends DefaultFormatter {
*/
boolean canReplace(ReplaceHolder rh) {
// This method is rather long, but much of the burden is in
// maintaining a String and swapping to a StringBuffer only if
// maintaining a String and swapping to a StringBuilder only if
// absolutely necessary.
if (!getAllowsInvalid()) {
StringBuffer replace = null;
StringBuilder replace = null;
String text = rh.text;
int tl = (text != null) ? text.length() : 0;
......@@ -737,7 +736,7 @@ public class MaskFormatter extends DefaultFormatter {
char aChar = text.charAt(textIndex);
if (aChar != getCharacter(rh.offset + counter, aChar)) {
if (replace == null) {
replace = new StringBuffer();
replace = new StringBuilder();
if (textIndex > 0) {
replace.append(text.substring(0, textIndex));
}
......@@ -758,7 +757,7 @@ public class MaskFormatter extends DefaultFormatter {
}
}
else if (textIndex > 0) {
replace = new StringBuffer(max);
replace = new StringBuilder(max);
replace.append(text.substring(0, textIndex));
replace.append(getLiteral(rh.offset + counter));
if (textIndex < tl) {
......@@ -780,7 +779,7 @@ public class MaskFormatter extends DefaultFormatter {
else if (textIndex >= tl) {
// placeholder
if (replace == null) {
replace = new StringBuffer();
replace = new StringBuilder();
if (text != null) {
replace.append(text);
}
......@@ -863,7 +862,7 @@ public class MaskFormatter extends DefaultFormatter {
* Appends the necessary character in <code>formatting</code> at
* <code>index</code> to <code>buff</code>.
*/
public void append(StringBuffer buff, String formatting, int[] index,
public void append(StringBuilder buff, String formatting, int[] index,
String placeholder)
throws ParseException {
boolean inString = index[0] < formatting.length();
......
......@@ -27,7 +27,6 @@ package javax.swing.text;
import java.lang.reflect.*;
import java.text.*;
import java.util.*;
import javax.swing.text.*;
/**
* <code>NumberFormatter</code> subclasses <code>InternationalFormatter</code>
......@@ -132,7 +131,7 @@ public class NumberFormatter extends InternationalFormatter {
DecimalFormatSymbols dfs = getDecimalFormatSymbols();
if (dfs != null) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(dfs.getCurrencySymbol());
sb.append(dfs.getDecimalSeparator());
......@@ -239,13 +238,6 @@ public class NumberFormatter extends InternationalFormatter {
return null;
}
/**
*/
private boolean isValidInsertionCharacter(char aChar) {
return (Character.isDigit(aChar) || specialChars.indexOf(aChar) != -1);
}
/**
* Subclassed to return false if <code>text</code> contains in an invalid
* character to insert, that is, it is not a digit
......@@ -402,28 +394,6 @@ public class NumberFormatter extends InternationalFormatter {
return false;
}
/**
* Returns true if the range offset to length identifies the only
* integer field.
*/
private boolean isOnlyIntegerField(int offset, int length) {
if (isValidMask()) {
int start = getAttributeStart(NumberFormat.Field.INTEGER);
if (start != -1) {
AttributedCharacterIterator iterator = getIterator();
iterator.setIndex(start);
if (offset > start || iterator.getRunLimit(
NumberFormat.Field.INTEGER) > (offset + length)) {
return false;
}
return true;
}
}
return false;
}
/**
* Invoked to toggle the sign. For this to work the value class
* must have a single arg constructor that takes a String.
......
......@@ -25,7 +25,6 @@
package javax.swing.text;
import java.util.Vector;
import javax.swing.event.*;
/**
* A plain document that maintains no character attributes. The
......@@ -118,7 +117,7 @@ public class PlainDocument extends AbstractDocument {
Object filterNewlines = getProperty("filterNewlines");
if ((filterNewlines instanceof Boolean) && filterNewlines.equals(Boolean.TRUE)) {
if ((str != null) && (str.indexOf('\n') >= 0)) {
StringBuffer filtered = new StringBuffer(str);
StringBuilder filtered = new StringBuilder(str);
int n = filtered.length();
for (int i = 0; i < n; i++) {
if (filtered.charAt(i) == '\n') {
......@@ -204,11 +203,9 @@ public class PlainDocument extends AbstractDocument {
}
}
if (hasBreaks) {
int rmCount = 1;
removed.addElement(rmCandidate);
if ((offset + length == rmOffs1) && (lastOffset != rmOffs1) &&
((index+1) < lineMap.getElementCount())) {
rmCount += 1;
Element e = lineMap.getElement(index+1);
removed.addElement(e);
rmOffs1 = e.getEndOffset();
......
......@@ -199,7 +199,7 @@ public class TabSet implements Serializable
*/
public String toString() {
int tabCount = getTabCount();
StringBuffer buffer = new StringBuffer("[ ");
StringBuilder buffer = new StringBuilder("[ ");
for(int counter = 0; counter < tabCount; counter++) {
if(counter > 0)
......
......@@ -362,7 +362,7 @@ public class FormView extends ComponentView implements ActionListener {
*/
public void actionPerformed(ActionEvent evt) {
Element element = getElement();
StringBuffer dataBuffer = new StringBuffer();
StringBuilder dataBuffer = new StringBuilder();
HTMLDocument doc = (HTMLDocument)getDocument();
AttributeSet attr = element.getAttributes();
......@@ -508,7 +508,7 @@ public class FormView extends ComponentView implements ActionListener {
*/
protected void imageSubmit(String imageData) {
StringBuffer dataBuffer = new StringBuffer();
StringBuilder dataBuffer = new StringBuilder();
Element elem = getElement();
HTMLDocument hdoc = (HTMLDocument)elem.getDocument();
getFormData(dataBuffer);
......@@ -589,7 +589,7 @@ public class FormView extends ComponentView implements ActionListener {
* @param targetElement the element that triggered the
* form submission
*/
void getFormData(StringBuffer buffer) {
private void getFormData(StringBuilder buffer) {
Element formE = getFormElement();
if (formE != null) {
ElementIterator it = new ElementIterator(formE);
......@@ -623,7 +623,7 @@ public class FormView extends ComponentView implements ActionListener {
* data is loaded in name/value pairs.
*
*/
private void loadElementDataIntoBuffer(Element elem, StringBuffer buffer) {
private void loadElementDataIntoBuffer(Element elem, StringBuilder buffer) {
AttributeSet attr = elem.getAttributes();
String name = (String)attr.getAttribute(HTML.Attribute.NAME);
......@@ -692,29 +692,6 @@ public class FormView extends ComponentView implements ActionListener {
}
if (path != null && path.length() > 0) {
value = path;
/*
try {
Reader reader = new BufferedReader(new FileReader(path));
StringBuffer buffer = new StringBuffer();
char[] cBuff = new char[1024];
int read;
try {
while ((read = reader.read(cBuff)) != -1) {
buffer.append(cBuff, 0, read);
}
} catch (IOException ioe) {
buffer = null;
}
try {
reader.close();
} catch (IOException ioe) {}
if (buffer != null) {
value = buffer.toString();
}
} catch (IOException ioe) {}
*/
}
}
return value;
......@@ -740,7 +717,7 @@ public class FormView extends ComponentView implements ActionListener {
* form element. Basically, only items that are selected
* and have their name attribute set are added to the buffer.
*/
private void loadSelectData(AttributeSet attr, StringBuffer buffer) {
private void loadSelectData(AttributeSet attr, StringBuilder buffer) {
String name = (String)attr.getAttribute(HTML.Attribute.NAME);
if (name == null) {
......@@ -771,7 +748,7 @@ public class FormView extends ComponentView implements ActionListener {
* URLEncoder.encode() method before being added to the
* buffer.
*/
private void appendBuffer(StringBuffer buffer, String name, String value) {
private void appendBuffer(StringBuilder buffer, String name, String value) {
if (buffer.length() > 0) {
buffer.append('&');
}
......
......@@ -691,11 +691,11 @@ public class MinimalHTMLWriter extends AbstractWriter {
if (styleNameMapping == null) {
return style;
}
StringBuffer sb = null;
StringBuilder sb = null;
for (int counter = style.length() - 1; counter >= 0; counter--) {
if (!isValidCharacter(style.charAt(counter))) {
if (sb == null) {
sb = new StringBuffer(style);
sb = new StringBuilder(style);
}
sb.setCharAt(counter, 'a');
}
......
......@@ -998,7 +998,7 @@ public class StyleSheet extends StyleContext {
void addRule(String[] selector, AttributeSet declaration,
boolean isLinked) {
int n = selector.length;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(selector[0]);
for (int counter = 1; counter < n; counter++) {
sb.append(' ');
......
......@@ -1470,7 +1470,7 @@ class Parser implements DTDConstants {
*/
public String parseDTDMarkup() throws IOException {
StringBuffer strBuff = new StringBuffer();
StringBuilder strBuff = new StringBuilder();
ch = readCh();
while(true) {
switch (ch) {
......
......@@ -160,7 +160,7 @@ abstract class AbstractFilter extends OutputStream
public void write(byte[] buf, int off, int len)
throws IOException
{
StringBuffer accumulator = null;
StringBuilder accumulator = null;
while (len > 0) {
short b = (short)buf[off];
......@@ -178,7 +178,7 @@ abstract class AbstractFilter extends OutputStream
char ch = translationTable[b];
if (ch != (char)0) {
if (accumulator == null)
accumulator = new StringBuffer();
accumulator = new StringBuilder();
accumulator.append(ch);
}
}
......
#
#
# Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
......@@ -21,7 +21,7 @@
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
......@@ -228,6 +228,492 @@ za=Zhuang
zh=Chinese
zu=Zulu
# key is ISO 639.2 language code
aar=Afar
abk=Abkhazian
ace=Achinese
ach=Acoli
ada=Adangme
ady=Adyghe
afa=Afro-Asiatic
afh=Afrihili
afr=Afrikaans
ain=Ainu
aka=Akan
akk=Akkadian
alb=Albanian
ale=Aleut
alg=Algonquian
alt=Southern Altai
amh=Amharic
ang=English, Old (ca.450-1100)
anp=Angika
apa=Apache
ara=Arabic
arc=Official Aramaic (700-300 BCE)
arg=Aragonese
arm=Armenian
arn=Mapudungun
arp=Arapaho
art=Artificial
arw=Arawak
asm=Assamese
ast=Asturian
ath=Athapascan
aus=Australian
ava=Avaric
ave=Avestan
awa=Awadhi
aym=Aymara
aze=Azerbaijani
bad=Banda
bai=Bamileke
bak=Bashkir
bal=Baluchi
bam=Bambara
ban=Balinese
baq=Basque
bas=Basa
bat=Baltic
bej=Beja
bel=Belarusian
bem=Bemba
ben=Bengali
ber=Berber
bho=Bhojpuri
bih=Bihari
bik=Bikol
bin=Bini
bis=Bislama
bla=Siksika
bnt=Bantu
bos=Bosnian
bra=Braj
bre=Breton
btk=Batak
bua=Buriat
bug=Buginese
bul=Bulgarian
bur=Burmese
byn=Blin
cad=Caddo
cai=Central American Indian
car=Galibi Carib
cat=Catalan
cau=Caucasian
ceb=Cebuano
cel=Celtic
cha=Chamorro
chb=Chibcha
che=Chechen
chg=Chagatai
chi=Chinese
chk=Chuukese
chm=Mari
chn=Chinook jargon
cho=Choctaw
chp=Chipewyan
chr=Cherokee
chu=Church Slavic
chv=Chuvash
chy=Cheyenne
cmc=Chamic
cop=Coptic
cor=Cornish
cos=Corsican
cpe=Creoles and pidgins, English based
cpf=Creoles and pidgins, French-based
cpp=Creoles and pidgins, Portuguese-based
cre=Cree
crh=Crimean Tatar
crp=Creoles and pidgins
csb=Kashubian
cus=Cushitic
cze=Czech
dak=Dakota
dan=Danish
dar=Dargwa
day=Land Dayak
del=Delaware
den=Slave (Athapascan)
dgr=Dogrib
din=Dinka
div=Divehi
doi=Dogri
dra=Dravidian
dsb=Lower Sorbian
dua=Duala
dum=Dutch, Middle (ca.1050-1350)
dut=Dutch
dyu=Dyula
dzo=Dzongkha
efi=Efik
egy=Egyptian (Ancient)
eka=Ekajuk
elx=Elamite
eng=English
enm=English, Middle (1100-1500)
epo=Esperanto
est=Estonian
ewe=Ewe
ewo=Ewondo
fan=Fang
fao=Faroese
fat=Fanti
fij=Fijian
fil=Filipino
fin=Finnish
fiu=Finno-Ugrian
fon=Fon
fre=French
frm=French, Middle (ca.1400-1600)
fro=French, Old (842-ca.1400)
frr=Northern Frisian
frs=Eastern Frisian
fry=Western Frisian
ful=Fulah
fur=Friulian
gaa=Ga
gay=Gayo
gba=Gbaya
gem=Germanic
geo=Georgian
ger=German
gez=Geez
gil=Gilbertese
gla=Gaelic
gle=Irish
glg=Galician
glv=Manx
gmh=German, Middle High (ca.1050-1500)
goh=German, Old High (ca.750-1050)
gon=Gondi
gor=Gorontalo
got=Gothic
grb=Grebo
grc=Greek, Ancient (to 1453)
gre=Greek, Modern (1453-)
grn=Guarani
gsw=Swiss German
guj=Gujarati
gwi=Gwich'in
hai=Haida
hat=Haitian
hau=Hausa
haw=Hawaiian
heb=Hebrew
her=Herero
hil=Hiligaynon
him=Himachali
hin=Hindi
hit=Hittite
hmn=Hmong
hmo=Hiri Motu
hrv=Croatian
hsb=Upper Sorbian
hun=Hungarian
hup=Hupa
iba=Iban
ibo=Igbo
ice=Icelandic
ido=Ido
iii=Sichuan Yi
ijo=Ijo
iku=Inuktitut
ile=Interlingue
ilo=Iloko
ina=Interlingua (International Auxiliary Language Association)
inc=Indic
ind=Indonesian
ine=Indo-European
inh=Ingush
ipk=Inupiaq
ira=Iranian
iro=Iroquoian
ita=Italian
jav=Javanese
jbo=Lojban
jpn=Japanese
jpr=Judeo-Persian
jrb=Judeo-Arabic
kaa=Kara-Kalpak
kab=Kabyle
kac=Kachin
kal=Kalaallisut
kam=Kamba
kan=Kannada
kar=Karen
kas=Kashmiri
kau=Kanuri
kaw=Kawi
kaz=Kazakh
kbd=Kabardian
kha=Khasi
khi=Khoisan
khm=Central Khmer
kho=Khotanese
kik=Kikuyu
kin=Kinyarwanda
kir=Kirghiz
kmb=Kimbundu
kok=Konkani
kom=Komi
kon=Kongo
kor=Korean
kos=Kosraean
kpe=Kpelle
krc=Karachay-Balkar
krl=Karelian
kro=Kru
kru=Kurukh
kua=Kuanyama
kum=Kumyk
kur=Kurdish
kut=Kutenai
lad=Ladino
lah=Lahnda
lam=Lamba
lao=Lao
lat=Latin
lav=Latvian
lez=Lezghian
lim=Limburgan
lin=Lingala
lit=Lithuanian
lol=Mongo
loz=Lozi
ltz=Luxembourgish
lua=Luba-Lulua
lub=Luba-Katanga
lug=Ganda
lui=Luiseno
lun=Lunda
luo=Luo (Kenya and Tanzania)
lus=Lushai
mac=Macedonian
mad=Madurese
mag=Magahi
mah=Marshallese
mai=Maithili
mak=Makasar
mal=Malayalam
man=Mandingo
mao=Maori
map=Austronesian
mar=Marathi
mas=Masai
may=Malay
mdf=Moksha
mdr=Mandar
men=Mende
mga=Irish, Middle (900-1200)
mic=Mi'kmaq
min=Minangkabau
mis=Uncoded
mkh=Mon-Khmer
mlg=Malagasy
mlt=Maltese
mnc=Manchu
mni=Manipuri
mno=Manobo
moh=Mohawk
mon=Mongolian
mos=Mossi
mul=Multiple
mun=Munda
mus=Creek
mwl=Mirandese
mwr=Marwari
myn=Mayan
myv=Erzya
nah=Nahuatl
nai=North American Indian
nap=Neapolitan
nau=Nauru
nav=Navajo
nbl=Ndebele, South
nde=Ndebele, North
ndo=Ndonga
nds=Low German
nep=Nepali
new=Nepal Bhasa
nia=Nias
nic=Niger-Kordofanian
niu=Niuean
nno=Norwegian Nynorsk
nob=Bokm\u00e5l, Norwegian
nog=Nogai
non=Norse, Old
nor=Norwegian
nqo=N'Ko
nso=Pedi
nub=Nubian
nwc=Classical Newari
nya=Chichewa
nym=Nyamwezi
nyn=Nyankole
nyo=Nyoro
nzi=Nzima
oci=Occitan (post 1500)
oji=Ojibwa
ori=Oriya
orm=Oromo
osa=Osage
oss=Ossetian
ota=Turkish, Ottoman (1500-1928)
oto=Otomian
paa=Papuan
pag=Pangasinan
pal=Pahlavi
pam=Pampanga
pan=Panjabi
pap=Papiamento
pau=Palauan
peo=Persian, Old (ca.600-400 B.C.)
per=Persian
phi=Philippine
phn=Phoenician
pli=Pali
pol=Polish
pon=Pohnpeian
por=Portuguese
pra=Prakrit
pro=Proven\u00e7al, Old (to 1500)
pus=Pushto; Pashto
que=Quechua
raj=Rajasthani
rap=Rapanui
rar=Rarotongan
roa=Romance
roh=Romansh
rom=Romany
rum=Romanian
run=Rundi
rup=Aromanian
rus=Russian
sad=Sandawe
sag=Sango
sah=Yakut
sai=South American Indian
sal=Salishan
sam=Samaritan Aramaic
san=Sanskrit
sas=Sasak
sat=Santali
scn=Sicilian
sco=Scots
sel=Selkup
sem=Semitic
sga=Irish, Old (to 900)
sgn=Sign
shn=Shan
sid=Sidamo
sin=Sinhala
sio=Siouan
sit=Sino-Tibetan
sla=Slavic
slo=Slovak
slv=Slovenian
sma=Southern Sami
sme=Northern Sami
smi=Sami
smj=Lule Sami
smn=Inari Sami
smo=Samoan
sms=Skolt Sami
sna=Shona
snd=Sindhi
snk=Soninke
sog=Sogdian
som=Somali
son=Songhai
sot=Sotho, Southern
spa=Spanish
srd=Sardinian
srn=Sranan Tongo
srp=Serbian
srr=Serer
ssa=Nilo-Saharan
ssw=Swati
suk=Sukuma
sun=Sundanese
sus=Susu
sux=Sumerian
swa=Swahili
swe=Swedish
syc=Classical Syriac
syr=Syriac
tah=Tahitian
tai=Tai
tam=Tamil
tat=Tatar
tel=Telugu
tem=Timne
ter=Tereno
tet=Tetum
tgk=Tajik
tgl=Tagalog
tha=Thai
tib=Tibetan
tig=Tigre
tir=Tigrinya
tiv=Tiv
tkl=Tokelau
tlh=Klingon
tli=Tlingit
tmh=Tamashek
tog=Tonga (Nyasa)
ton=Tonga (Tonga Islands)
tpi=Tok Pisin
tsi=Tsimshian
tsn=Tswana
tso=Tsonga
tuk=Turkmen
tum=Tumbuka
tup=Tupi
tur=Turkish
tut=Altaic
tvl=Tuvalu
twi=Twi
tyv=Tuvinian
udm=Udmurt
uga=Ugaritic
uig=Uighur
ukr=Ukrainian
umb=Umbundu
und=Undetermined
urd=Urdu
uzb=Uzbek
vai=Vai
ven=Venda
vie=Vietnamese
vol=Volap\u00fck
vot=Votic
wak=Wakashan
wal=Wolaitta
war=Waray
was=Washo
wel=Welsh
wen=Sorbian
wln=Walloon
wol=Wolof
xal=Kalmyk
xho=Xhosa
yao=Yao
yap=Yapese
yid=Yiddish
yor=Yoruba
ypk=Yupik
zap=Zapotec
zbl=Blissymbols
zen=Zenaga
zha=Zhuang
znd=Zande
zul=Zulu
zun=Zuni
zxx=No linguistic content
zza=Zaza
# script names
# key is ISO 15924 script code
......
......@@ -219,11 +219,14 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
/*
* user.language
* user.country, user.variant (if user's environment specifies them)
* user.script, user.country, user.variant (if user's environment specifies them)
* file.encoding
* file.encoding.pkg
*/
PUTPROP(props, "user.language", sprops->language);
if (sprops->script) {
PUTPROP(props, "user.script", sprops->script);
}
if (sprops->country) {
PUTPROP(props, "user.country", sprops->country);
}
......@@ -305,11 +308,12 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
}
/*
* unset "user.language", "user.country", and "user.variant"
* unset "user.language", "user.script", "user.country", and "user.variant"
* in order to tell whether the command line option "-DXXXX=YYYY" is
* specified or not. They will be reset in fillI18nProps() below.
*/
REMOVEPROP(props, "user.language");
REMOVEPROP(props, "user.script");
REMOVEPROP(props, "user.country");
REMOVEPROP(props, "user.variant");
REMOVEPROP(props, "file.encoding");
......@@ -328,6 +332,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
/* reconstruct i18n related properties */
fillI18nProps(env, props, "user.language", sprops->display_language,
sprops->format_language, putID, getPropID);
fillI18nProps(env, props, "user.script",
sprops->display_script, sprops->format_script, putID, getPropID);
fillI18nProps(env, props, "user.country",
sprops->display_country, sprops->format_country, putID, getPropID);
fillI18nProps(env, props, "user.variant",
......
......@@ -55,6 +55,9 @@ typedef struct {
char *language;
char *format_language;
char *display_language;
char *script;
char *format_script;
char *display_script;
char *country;
char *format_country;
char *display_country;
......
......@@ -117,7 +117,8 @@ setPathEnvironment(char *envstring)
#define P_tmpdir "/var/tmp"
#endif
static int ParseLocale(int cat, char ** std_language, char ** std_country, char ** std_variant, char ** std_encoding) {
static int ParseLocale(int cat, char ** std_language, char ** std_script,
char ** std_country, char ** std_variant, char ** std_encoding) {
char temp[64];
char *language = NULL, *country = NULL, *variant = NULL,
*encoding = NULL;
......@@ -181,14 +182,22 @@ static int ParseLocale(int cat, char ** std_language, char ** std_country, char
strcpy(encoding_variant, p); /* Copy the leading '.' */
*p = '\0';
} else if ((p = strchr(temp, '@')) != NULL) {
strcpy(encoding_variant, p); /* Copy the leading '@' */
*p = '\0';
strcpy(encoding_variant, p); /* Copy the leading '@' */
*p = '\0';
} else {
*encoding_variant = '\0';
}
if (mapLookup(locale_aliases, temp, &p)) {
strcpy(temp, p);
// check the "encoding_variant" again, if any.
if ((p = strchr(temp, '.')) != NULL) {
strcpy(encoding_variant, p); /* Copy the leading '.' */
*p = '\0';
} else if ((p = strchr(temp, '@')) != NULL) {
strcpy(encoding_variant, p); /* Copy the leading '@' */
*p = '\0';
}
}
language = temp;
......@@ -219,10 +228,17 @@ static int ParseLocale(int cat, char ** std_language, char ** std_country, char
mapLookup(country_names, country, std_country);
}
/* Normalize the variant name. Note that we only use
* variants listed in the mapping array; others are ignored. */
if (std_variant != NULL && variant != NULL) {
mapLookup(variant_names, variant, std_variant);
/* Normalize the script and variant name. Note that we only use
* variants listed in the mapping array; others are ignored.
*/
if (variant != NULL) {
if (std_script != NULL) {
mapLookup(script_names, variant, std_script);
}
if (std_variant != NULL) {
mapLookup(variant_names, variant, std_variant);
}
}
/* Normalize the encoding name. Note that we IGNORE the string
......@@ -358,11 +374,13 @@ GetJavaProperties(JNIEnv *env)
setlocale(LC_ALL, "");
if (ParseLocale(LC_CTYPE,
&(sprops.format_language),
&(sprops.format_script),
&(sprops.format_country),
&(sprops.format_variant),
&(sprops.encoding))) {
ParseLocale(LC_MESSAGES,
&(sprops.language),
&(sprops.script),
&(sprops.country),
&(sprops.variant),
NULL);
......@@ -371,6 +389,7 @@ GetJavaProperties(JNIEnv *env)
sprops.encoding = "ISO8859-1";
}
sprops.display_language = sprops.language;
sprops.display_script = sprops.script;
sprops.display_country = sprops.country;
sprops.display_variant = sprops.variant;
sprops.sun_jnu_encoding = sprops.encoding;
......
......@@ -86,6 +86,8 @@
"wa", "wa_BE",
"zh", "zh_CN",
#ifdef __linux__
"bokmal", "nb_NO",
"bokm\u00e5l", "nb_NO",
"catalan", "ca_ES",
"croatian", "hr_HR",
"czech", "cs_CZ",
......@@ -93,9 +95,13 @@
"dansk", "da_DK",
"deutsch", "de_DE",
"dutch", "nl_NL",
"eesti", "et_EE",
"estonian", "et_EE",
"finnish", "fi_FI",
"fran\xE7\x61is", "fr_FR",
"french", "fr_FR",
"galego", "gl_ES",
"galician", "gl_ES",
"german", "de_DE",
"greek", "el_GR",
"hebrew", "iw_IL",
......@@ -104,7 +110,10 @@
"icelandic", "is_IS",
"italian", "it_IT",
"japanese", "ja_JP",
"korean", "ko_KR",
"lithuanian", "lt_LT",
"norwegian", "no_NO",
"nynorsk", "nn_NO",
"polish", "pl_PL",
"portuguese", "pt_PT",
"romanian", "ro_RO",
......@@ -114,11 +123,16 @@
"slovenian", "sl_SI",
"spanish", "es_ES",
"swedish", "sv_SE",
"thai", "th_TH",
"turkish", "tr_TR",
#else
"big5", "zh_TW.Big5",
"chinese", "zh_CN",
"iso_8859_1", "en_US.ISO8859-1",
"iso_8859_15", "en_US.ISO8859-15",
"japanese", "ja_JP",
"no_NY", "no_NO@nynorsk",
"sr_SP", "sr_YU",
"tchinese", "zh_TW",
#endif
""
......@@ -361,6 +375,506 @@ static char *language_names[] = {
"japanese", "ja",
"korean", "ko",
#endif
/* ISO 639.2 codes */
"aar", "aar",
"abk", "abk",
"ace", "ace",
"ach", "ach",
"ada", "ada",
"ady", "ady",
"afa", "afa",
"afh", "afh",
"afr", "afr",
"ain", "ain",
"aka", "aka",
"akk", "akk",
"alb", "alb",
"ale", "ale",
"alg", "alg",
"alt", "alt",
"amh", "amh",
"ang", "ang",
"anp", "anp",
"apa", "apa",
"ara", "ara",
"arc", "arc",
"arg", "arg",
"arm", "arm",
"arn", "arn",
"arp", "arp",
"art", "art",
"arw", "arw",
"asm", "asm",
"ast", "ast",
"ath", "ath",
"aus", "aus",
"ava", "ava",
"ave", "ave",
"awa", "awa",
"aym", "aym",
"aze", "aze",
"bad", "bad",
"bai", "bai",
"bak", "bak",
"bal", "bal",
"bam", "bam",
"ban", "ban",
"baq", "baq",
"bas", "bas",
"bat", "bat",
"bej", "bej",
"bel", "bel",
"bem", "bem",
"ben", "ben",
"ber", "ber",
"bho", "bho",
"bih", "bih",
"bik", "bik",
"bin", "bin",
"bis", "bis",
"bla", "bla",
"bnt", "bnt",
"bos", "bos",
"bra", "bra",
"bre", "bre",
"btk", "btk",
"bua", "bua",
"bug", "bug",
"bul", "bul",
"bur", "bur",
"byn", "byn",
"cad", "cad",
"cai", "cai",
"car", "car",
"cat", "cat",
"cau", "cau",
"ceb", "ceb",
"cel", "cel",
"cha", "cha",
"chb", "chb",
"che", "che",
"chg", "chg",
"chi", "chi",
"chk", "chk",
"chm", "chm",
"chn", "chn",
"cho", "cho",
"chp", "chp",
"chr", "chr",
"chu", "chu",
"chv", "chv",
"chy", "chy",
"cmc", "cmc",
"cop", "cop",
"cor", "cor",
"cos", "cos",
"cpe", "cpe",
"cpf", "cpf",
"cpp", "cpp",
"cre", "cre",
"crh", "crh",
"crp", "crp",
"csb", "csb",
"cus", "cus",
"cze", "cze",
"dak", "dak",
"dan", "dan",
"dar", "dar",
"day", "day",
"del", "del",
"den", "den",
"dgr", "dgr",
"din", "din",
"div", "div",
"doi", "doi",
"dra", "dra",
"dsb", "dsb",
"dua", "dua",
"dum", "dum",
"dut", "dut",
"dyu", "dyu",
"dzo", "dzo",
"efi", "efi",
"egy", "egy",
"eka", "eka",
"elx", "elx",
"eng", "eng",
"enm", "enm",
"epo", "epo",
"est", "est",
"ewe", "ewe",
"ewo", "ewo",
"fan", "fan",
"fao", "fao",
"fat", "fat",
"fij", "fij",
"fil", "fil",
"fin", "fin",
"fiu", "fiu",
"fon", "fon",
"fre", "fre",
"frm", "frm",
"fro", "fro",
"frr", "frr",
"frs", "frs",
"fry", "fry",
"ful", "ful",
"fur", "fur",
"gaa", "gaa",
"gay", "gay",
"gba", "gba",
"gem", "gem",
"geo", "geo",
"ger", "ger",
"gez", "gez",
"gil", "gil",
"gla", "gla",
"gle", "gle",
"glg", "glg",
"glv", "glv",
"gmh", "gmh",
"goh", "goh",
"gon", "gon",
"gor", "gor",
"got", "got",
"grb", "grb",
"grc", "grc",
"gre", "gre",
"grn", "grn",
"gsw", "gsw",
"guj", "guj",
"gwi", "gwi",
"hai", "hai",
"hat", "hat",
"hau", "hau",
"haw", "haw",
"heb", "heb",
"her", "her",
"hil", "hil",
"him", "him",
"hin", "hin",
"hit", "hit",
"hmn", "hmn",
"hmo", "hmo",
"hrv", "hrv",
"hsb", "hsb",
"hun", "hun",
"hup", "hup",
"iba", "iba",
"ibo", "ibo",
"ice", "ice",
"ido", "ido",
"iii", "iii",
"ijo", "ijo",
"iku", "iku",
"ile", "ile",
"ilo", "ilo",
"ina", "ina",
"inc", "inc",
"ind", "ind",
"ine", "ine",
"inh", "inh",
"ipk", "ipk",
"ira", "ira",
"iro", "iro",
"ita", "ita",
"jav", "jav",
"jbo", "jbo",
"jpn", "jpn",
"jpr", "jpr",
"jrb", "jrb",
"kaa", "kaa",
"kab", "kab",
"kac", "kac",
"kal", "kal",
"kam", "kam",
"kan", "kan",
"kar", "kar",
"kas", "kas",
"kau", "kau",
"kaw", "kaw",
"kaz", "kaz",
"kbd", "kbd",
"kha", "kha",
"khi", "khi",
"khm", "khm",
"kho", "kho",
"kik", "kik",
"kin", "kin",
"kir", "kir",
"kmb", "kmb",
"kok", "kok",
"kom", "kom",
"kon", "kon",
"kor", "kor",
"kos", "kos",
"kpe", "kpe",
"krc", "krc",
"krl", "krl",
"kro", "kro",
"kru", "kru",
"kua", "kua",
"kum", "kum",
"kur", "kur",
"kut", "kut",
"lad", "lad",
"lah", "lah",
"lam", "lam",
"lao", "lao",
"lat", "lat",
"lav", "lav",
"lez", "lez",
"lim", "lim",
"lin", "lin",
"lit", "lit",
"lol", "lol",
"loz", "loz",
"ltz", "ltz",
"lua", "lua",
"lub", "lub",
"lug", "lug",
"lui", "lui",
"lun", "lun",
"luo", "luo",
"lus", "lus",
"mac", "mac",
"mad", "mad",
"mag", "mag",
"mah", "mah",
"mai", "mai",
"mak", "mak",
"mal", "mal",
"man", "man",
"mao", "mao",
"map", "map",
"mar", "mar",
"mas", "mas",
"may", "may",
"mdf", "mdf",
"mdr", "mdr",
"men", "men",
"mga", "mga",
"mic", "mic",
"min", "min",
"mis", "mis",
"mkh", "mkh",
"mlg", "mlg",
"mlt", "mlt",
"mnc", "mnc",
"mni", "mni",
"mno", "mno",
"moh", "moh",
"mon", "mon",
"mos", "mos",
"mul", "mul",
"mun", "mun",
"mus", "mus",
"mwl", "mwl",
"mwr", "mwr",
"myn", "myn",
"myv", "myv",
"nah", "nah",
"nai", "nai",
"nap", "nap",
"nau", "nau",
"nav", "nav",
"nbl", "nbl",
"nde", "nde",
"ndo", "ndo",
"nds", "nds",
"nep", "nep",
"new", "new",
"nia", "nia",
"nic", "nic",
"niu", "niu",
"nno", "nno",
"nob", "nob",
"nog", "nog",
"non", "non",
"nor", "nor",
"nqo", "nqo",
"nso", "nso",
"nub", "nub",
"nwc", "nwc",
"nya", "nya",
"nym", "nym",
"nyn", "nyn",
"nyo", "nyo",
"nzi", "nzi",
"oci", "oci",
"oji", "oji",
"ori", "ori",
"orm", "orm",
"osa", "osa",
"oss", "oss",
"ota", "ota",
"oto", "oto",
"paa", "paa",
"pag", "pag",
"pal", "pal",
"pam", "pam",
"pan", "pan",
"pap", "pap",
"pau", "pau",
"peo", "peo",
"per", "per",
"phi", "phi",
"phn", "phn",
"pli", "pli",
"pol", "pol",
"pon", "pon",
"por", "por",
"pra", "pra",
"pro", "pro",
"pus", "pus",
"que", "que",
"raj", "raj",
"rap", "rap",
"rar", "rar",
"roa", "roa",
"roh", "roh",
"rom", "rom",
"rum", "rum",
"run", "run",
"rup", "rup",
"rus", "rus",
"sad", "sad",
"sag", "sag",
"sah", "sah",
"sai", "sai",
"sal", "sal",
"sam", "sam",
"san", "san",
"sas", "sas",
"sat", "sat",
"scn", "scn",
"sco", "sco",
"sel", "sel",
"sem", "sem",
"sga", "sga",
"sgn", "sgn",
"shn", "shn",
"sid", "sid",
"sin", "sin",
"sio", "sio",
"sit", "sit",
"sla", "sla",
"slo", "slo",
"slv", "slv",
"sma", "sma",
"sme", "sme",
"smi", "smi",
"smj", "smj",
"smn", "smn",
"smo", "smo",
"sms", "sms",
"sna", "sna",
"snd", "snd",
"snk", "snk",
"sog", "sog",
"som", "som",
"son", "son",
"sot", "sot",
"spa", "spa",
"srd", "srd",
"srn", "srn",
"srp", "srp",
"srr", "srr",
"ssa", "ssa",
"ssw", "ssw",
"suk", "suk",
"sun", "sun",
"sus", "sus",
"sux", "sux",
"swa", "swa",
"swe", "swe",
"syc", "syc",
"syr", "syr",
"tah", "tah",
"tai", "tai",
"tam", "tam",
"tat", "tat",
"tel", "tel",
"tem", "tem",
"ter", "ter",
"tet", "tet",
"tgk", "tgk",
"tgl", "tgl",
"tha", "tha",
"tib", "tib",
"tig", "tig",
"tir", "tir",
"tiv", "tiv",
"tkl", "tkl",
"tlh", "tlh",
"tli", "tli",
"tmh", "tmh",
"tog", "tog",
"ton", "ton",
"tpi", "tpi",
"tsi", "tsi",
"tsn", "tsn",
"tso", "tso",
"tuk", "tuk",
"tum", "tum",
"tup", "tup",
"tur", "tur",
"tut", "tut",
"tvl", "tvl",
"twi", "twi",
"tyv", "tyv",
"udm", "udm",
"uga", "uga",
"uig", "uig",
"ukr", "ukr",
"umb", "umb",
"und", "und",
"urd", "urd",
"uzb", "uzb",
"vai", "vai",
"ven", "ven",
"vie", "vie",
"vol", "vol",
"vot", "vot",
"wak", "wak",
"wal", "wal",
"war", "war",
"was", "was",
"wel", "wel",
"wen", "wen",
"wln", "wln",
"wol", "wol",
"xal", "xal",
"xho", "xho",
"yao", "yao",
"yap", "yap",
"yid", "yid",
"yor", "yor",
"ypk", "ypk",
"zap", "zap",
"zbl", "zbl",
"zen", "zen",
"zha", "zha",
"znd", "znd",
"zul", "zul",
"zun", "zun",
"zxx", "zxx",
"zza", "zza",
"",
};
/*
* Linux/Solaris script string to Java script name mapping table.
*/
static char *script_names[] = {
#ifdef __linux__
"cyrillic", "Cyrl",
"devanagari", "Deva",
"iqtelif", "Latn",
"latin", "Latn",
#endif
"",
};
......@@ -503,6 +1017,7 @@ static char *country_names[] = {
"MA", "MA",
"MC", "MC",
"MD", "MD",
"ME", "ME",
"MG", "MG",
"MH", "MH",
"MK", "MK",
......@@ -554,6 +1069,7 @@ static char *country_names[] = {
"RN", "US", // used on Linux, not clear what it stands for
#endif
"RO", "RO",
"RS", "RS",
"RU", "RU",
"RW", "RW",
"SA", "SA",
......
......@@ -51,6 +51,92 @@ static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
static jboolean GetJREPath(char *path, jint pathsize);
static void EnsureJreInstallation(const char *jrepath);
/* We supports warmup for UI stack that is performed in parallel
* to VM initialization.
* This helps to improve startup of UI application as warmup phase
* might be long due to initialization of OS or hardware resources.
* It is not CPU bound and therefore it does not interfere with VM init.
* Obviously such warmup only has sense for UI apps and therefore it needs
* to be explicitly requested by passing -Dsun.awt.warmup=true property
* (this is always the case for plugin/javaws).
*
* Implementation launches new thread after VM starts and use it to perform
* warmup code (platform dependent).
* This thread is later reused as AWT toolkit thread as graphics toolkit
* often assume that they are used from the same thread they were launched on.
*
* At the moment we only support warmup for D3D. It only possible on windows
* and only if other flags do not prohibit this (e.g. OpenGL support requested).
*/
#undef ENABLE_AWT_PRELOAD
#ifndef JAVA_ARGS /* turn off AWT preloading for javac, jar, etc */
#define ENABLE_AWT_PRELOAD
#endif
#ifdef ENABLE_AWT_PRELOAD
/* "AWT was preloaded" flag;
* turned on by AWTPreload().
*/
int awtPreloaded = 0;
/* Calls a function with the name specified
* the function must be int(*fn)(void).
*/
int AWTPreload(const char *funcName);
/* stops AWT preloading */
void AWTPreloadStop();
/* D3D preloading */
/* -1: not initialized; 0: OFF, 1: ON */
int awtPreloadD3D = -1;
/* command line parameter to swith D3D preloading on */
#define PARAM_PRELOAD_D3D "-Dsun.awt.warmup"
/* D3D/OpenGL management parameters */
#define PARAM_NODDRAW "-Dsun.java2d.noddraw"
#define PARAM_D3D "-Dsun.java2d.d3d"
#define PARAM_OPENGL "-Dsun.java2d.opengl"
/* funtion in awt.dll (src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp) */
#define D3D_PRELOAD_FUNC "preloadD3D"
/* Extracts value of a parameter with the specified name
* from command line argument (returns pointer in the argument).
* Returns NULL if the argument does not contains the parameter.
* e.g.:
* GetParamValue("theParam", "theParam=value") returns pointer to "value".
*/
const char * GetParamValue(const char *paramName, const char *arg) {
int nameLen = JLI_StrLen(paramName);
if (JLI_StrNCmp(paramName, arg, nameLen) == 0) {
/* arg[nameLen] is valid (may contain final NULL) */
if (arg[nameLen] == '=') {
return arg + nameLen + 1;
}
}
return NULL;
}
/* Checks if commandline argument contains property specified
* and analyze it as boolean property (true/false).
* Returns -1 if the argument does not contain the parameter;
* Returns 1 if the argument contains the parameter and its value is "true";
* Returns 0 if the argument contains the parameter and its value is "false".
*/
int GetBoolParamValue(const char *paramName, const char *arg) {
const char * paramValue = GetParamValue(paramName, arg);
if (paramValue != NULL) {
if (JLI_StrCaseCmp(paramValue, "true") == 0) {
return 1;
}
if (JLI_StrCaseCmp(paramValue, "false") == 0) {
return 0;
}
}
return -1;
}
#endif /* ENABLE_AWT_PRELOAD */
static jboolean _isjavaw = JNI_FALSE;
......@@ -132,6 +218,30 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
exit(4);
}
/* If we got here, jvmpath has been correctly initialized. */
/* Check if we need preload AWT */
#ifdef ENABLE_AWT_PRELOAD
argv = *pargv;
for (i = 0; i < *pargc ; i++) {
/* Tests the "turn on" parameter only if not set yet. */
if (awtPreloadD3D < 0) {
if (GetBoolParamValue(PARAM_PRELOAD_D3D, argv[i]) == 1) {
awtPreloadD3D = 1;
}
}
/* Test parameters which can disable preloading if not already disabled. */
if (awtPreloadD3D != 0) {
if (GetBoolParamValue(PARAM_NODDRAW, argv[i]) == 1
|| GetBoolParamValue(PARAM_D3D, argv[i]) == 0
|| GetBoolParamValue(PARAM_OPENGL, argv[i]) == 1)
{
awtPreloadD3D = 0;
/* no need to test the rest of the parameters */
break;
}
}
}
#endif /* ENABLE_AWT_PRELOAD */
}
......@@ -1087,6 +1197,40 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void
0,
&thread_id);
}
/* AWT preloading (AFTER main thread start) */
#ifdef ENABLE_AWT_PRELOAD
/* D3D preloading */
if (awtPreloadD3D != 0) {
char *envValue;
/* D3D routines checks env.var J2D_D3D if no appropriate
* command line params was specified
*/
envValue = getenv("J2D_D3D");
if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
awtPreloadD3D = 0;
}
/* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */
envValue = getenv("J2D_D3D_PRELOAD");
if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
awtPreloadD3D = 0;
}
if (awtPreloadD3D < 0) {
/* If awtPreloadD3D is still undefined (-1), test
* if it is turned on by J2D_D3D_PRELOAD env.var.
* By default it's turned OFF.
*/
awtPreloadD3D = 0;
if (envValue != NULL && JLI_StrCaseCmp(envValue, "true") == 0) {
awtPreloadD3D = 1;
}
}
}
if (awtPreloadD3D) {
AWTPreload(D3D_PRELOAD_FUNC);
}
#endif /* ENABLE_AWT_PRELOAD */
if (thread_handle) {
WaitForSingleObject(thread_handle, INFINITE);
GetExitCodeThread(thread_handle, &rslt);
......@@ -1094,6 +1238,13 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void
} else {
rslt = continuation(args);
}
#ifdef ENABLE_AWT_PRELOAD
if (awtPreloaded) {
AWTPreloadStop();
}
#endif /* ENABLE_AWT_PRELOAD */
return rslt;
}
......@@ -1140,3 +1291,98 @@ InitLauncher(boolean javaw)
_isjavaw = javaw;
JLI_SetTraceLauncher();
}
/* ============================== */
/* AWT preloading */
#ifdef ENABLE_AWT_PRELOAD
typedef int FnPreloadStart(void);
typedef void FnPreloadStop(void);
static FnPreloadStop *fnPreloadStop = NULL;
static HMODULE hPreloadAwt = NULL;
/*
* Starts AWT preloading
*/
int AWTPreload(const char *funcName)
{
int result = -1;
/* load AWT library once (if several preload function should be called) */
if (hPreloadAwt == NULL) {
/* awt.dll is not loaded yet */
char libraryPath[MAXPATHLEN];
int jrePathLen = 0;
HMODULE hJava = NULL;
HMODULE hVerify = NULL;
while (1) {
/* awt.dll depends on jvm.dll & java.dll;
* jvm.dll is already loaded, so we need only java.dll;
* java.dll depends on MSVCRT lib & verify.dll.
*/
if (!GetJREPath(libraryPath, MAXPATHLEN)) {
break;
}
/* save path length */
jrePathLen = JLI_StrLen(libraryPath);
/* load msvcrt 1st */
LoadMSVCRT();
/* load verify.dll */
JLI_StrCat(libraryPath, "\\bin\\verify.dll");
hVerify = LoadLibrary(libraryPath);
if (hVerify == NULL) {
break;
}
/* restore jrePath */
libraryPath[jrePathLen] = 0;
/* load java.dll */
JLI_StrCat(libraryPath, "\\bin\\" JAVA_DLL);
hJava = LoadLibrary(libraryPath);
if (hJava == NULL) {
break;
}
/* restore jrePath */
libraryPath[jrePathLen] = 0;
/* load awt.dll */
JLI_StrCat(libraryPath, "\\bin\\awt.dll");
hPreloadAwt = LoadLibrary(libraryPath);
if (hPreloadAwt == NULL) {
break;
}
/* get "preloadStop" func ptr */
fnPreloadStop = (FnPreloadStop *)GetProcAddress(hPreloadAwt, "preloadStop");
break;
}
}
if (hPreloadAwt != NULL) {
FnPreloadStart *fnInit = (FnPreloadStart *)GetProcAddress(hPreloadAwt, funcName);
if (fnInit != NULL) {
/* don't forget to stop preloading */
awtPreloaded = 1;
result = fnInit();
}
}
return result;
}
/*
* Terminates AWT preloading
*/
void AWTPreloadStop() {
if (fnPreloadStop != NULL) {
fnPreloadStop();
}
}
#endif /* ENABLE_AWT_PRELOAD */
......@@ -169,7 +169,7 @@ public class WInputMethod extends InputMethodAdapter
locale.equals(Locale.JAPAN) && lang.equals(Locale.JAPANESE) ||
locale.equals(Locale.KOREA) && lang.equals(Locale.KOREAN)) {
if (isActive) {
setNativeLocale(locale.toString(), onActivate);
setNativeLocale(locale.toLanguageTag(), onActivate);
}
currentLocale = locale;
return true;
......
......@@ -218,6 +218,8 @@ public class WToolkit extends SunToolkit implements Runnable {
private static native void postDispose();
private static native boolean startToolkitThread(Runnable thread);
public WToolkit() {
// Startup toolkit threads
if (PerformanceLogger.loggingEnabled()) {
......@@ -231,9 +233,6 @@ public class WToolkit extends SunToolkit implements Runnable {
// where notifyAll can be called before
// the "AWT-Windows" thread's parent thread is
// waiting, resulting in a deadlock on startup.
Thread toolkitThread = new Thread(this, "AWT-Windows");
toolkitThread.setDaemon(true);
toolkitThread.setPriority(Thread.NORM_PRIORITY+1);
/*
* Fix for 4701990.
......@@ -242,7 +241,11 @@ public class WToolkit extends SunToolkit implements Runnable {
*/
AWTAutoShutdown.notifyToolkitThreadBusy();
toolkitThread.start();
if (!startToolkitThread(this)) {
Thread toolkitThread = new Thread(this, "AWT-Windows");
toolkitThread.setDaemon(true);
toolkitThread.start();
}
try {
wait();
......@@ -263,6 +266,7 @@ public class WToolkit extends SunToolkit implements Runnable {
}
public void run() {
Thread.currentThread().setPriority(Thread.NORM_PRIORITY+1);
boolean startPump = init();
if (startPump) {
......
......@@ -476,6 +476,7 @@ DS_StartBufferHelper::Data::~Data() {
DWORD WINAPI __stdcall DS_StartBufferHelper::ThreadProc(void *param)
{
::CoInitialize(NULL);
while (1) {
// wait for something to do
::WaitForSingleObject(data.startEvent, INFINITE);
......@@ -492,6 +493,7 @@ DWORD WINAPI __stdcall DS_StartBufferHelper::ThreadProc(void *param)
}
::SetEvent(data.startedEvent);
}
::CoUninitialize();
return 0;
}
......
......@@ -43,11 +43,14 @@
#endif
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
static void SetupI18nProps(LCID lcid, char** language, char** country,
static void SetupI18nProps(LCID lcid, char** language, char** script, char** country,
char** variant, char** encoding);
#define SHELL_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
#define PROPSIZE 9 // eight-letter + null terminator
#define SNAMESIZE 86 // max number of chars for LOCALE_SNAME is 85
static char *
getEncodingInternal(LCID lcid)
{
......@@ -127,30 +130,31 @@ getEncodingFromLangID(LANGID langID)
return getEncodingInternal(MAKELCID(langID, SORT_DEFAULT));
}
// Returns BCP47 Language Tag
DllExport const char *
getJavaIDFromLangID(LANGID langID)
{
char * lang;
char * ctry;
char * vrnt;
char * enc;
char * ret = malloc(16);
char * elems[5]; // lang, script, ctry, variant, encoding
char * ret = malloc(SNAMESIZE);
int index;
SetupI18nProps(MAKELCID(langID, SORT_DEFAULT), &lang, &ctry, &vrnt, &enc);
if (ctry[0] != '\0') {
if (vrnt[0] != '\0') {
sprintf(ret, "%s_%s_%s", lang, ctry, vrnt);
} else {
sprintf(ret, "%s_%s", lang, ctry);
SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
&(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]));
// there always is the "language" tag
strcpy(ret, elems[0]);
// append other elements, if any
for (index = 1; index < 4; index++) {
if ((elems[index])[0] != '\0') {
strcat(ret, "-");
strcat(ret, elems[index]);
}
} else {
strcpy(ret, lang);
}
free(lang);
free(ctry);
free(vrnt);
free(enc);
for (index = 0; index < 5; index++) {
free(elems[index]);
}
return ret;
}
......@@ -289,39 +293,38 @@ cpu_isalist(void)
return NULL;
}
#define PROPSIZE 3 // two-letter + null terminator
static void
SetupI18nProps(LCID lcid, char** language, char** country,
SetupI18nProps(LCID lcid, char** language, char** script, char** country,
char** variant, char** encoding) {
/* script */
char tmp[SNAMESIZE];
*script = malloc(PROPSIZE);
if (GetLocaleInfo(lcid,
LOCALE_SNAME, tmp, SNAMESIZE) == 0 ||
sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 ||
strlen(*script) != 4) {
(*script)[0] = '\0';
}
/* country */
*country = malloc(PROPSIZE);
if (GetLocaleInfo(lcid,
LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0) {
LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 &&
GetLocaleInfo(lcid,
LOCALE_SISO3166CTRYNAME2, *country, PROPSIZE) == 0) {
(*country)[0] = '\0';
}
/* language */
*language = malloc(PROPSIZE);
if (lcid == 0x46c) {
/* Windows returns non-existent language code "ns" for Northern Sotho.
* Defaults to en_US
*/
strcpy(*language, "en");
strcpy(*country, "US");
} else if (GetLocaleInfo(lcid,
LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0) {
if (lcid == 0x465) {
/* for some reason, Windows returns "div" for this Divehi LCID, even though
* there is a two letter language code "dv". Tweak it here.
*/
strcpy(*language, "dv");
strcpy(*country, "MV");
} else {
if (GetLocaleInfo(lcid,
LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 &&
GetLocaleInfo(lcid,
LOCALE_SISO639LANGNAME2, *language, PROPSIZE) == 0) {
/* defaults to en_US */
strcpy(*language, "en");
strcpy(*country, "US");
}
}
/* variant */
*variant = malloc(PROPSIZE);
......@@ -564,7 +567,7 @@ GetJavaProperties(JNIEnv* env)
/*
* user.language
* user.country, user.variant (if user's environment specifies them)
* user.script, user.country, user.variant (if user's environment specifies them)
* file.encoding
* file.encoding.pkg
*/
......@@ -582,16 +585,19 @@ GetJavaProperties(JNIEnv* env)
SetupI18nProps(userDefaultUILang,
&sprops.language,
&sprops.script,
&sprops.country,
&sprops.variant,
&display_encoding);
SetupI18nProps(userDefaultLCID,
&sprops.format_language,
&sprops.format_script,
&sprops.format_country,
&sprops.format_variant,
&sprops.encoding);
SetupI18nProps(userDefaultUILang,
&sprops.display_language,
&sprops.display_script,
&sprops.display_country,
&sprops.display_variant,
&display_encoding);
......
......@@ -36,22 +36,6 @@ extern jobject CreateDisplayMode(JNIEnv* env, jint width, jint height,
extern void addDisplayMode(JNIEnv* env, jobject arrayList, jint width,
jint height, jint bitDepth, jint refreshRate);
void InitD3D(void *pReturn)
{
J2dTraceLn(J2D_TRACE_INFO, "InitD3D");
jboolean *pRet = (jboolean *)pReturn;
D3DPipelineManager *pMgr = D3DPipelineManager::CreateInstance();
if (pMgr == NULL) {
J2dTraceLn(J2D_TRACE_ERROR, "InitD3D: could not create or init d3d");
*pRet = JNI_FALSE;
} else {
J2dTraceLn(J2D_TRACE_INFO, "InitD3D: successfully initialized d3d");
*pRet = JNI_TRUE;
}
}
extern "C" {
/*
* Class: sun_java2d_d3d_D3DGraphicsDevice
......@@ -63,8 +47,8 @@ JNIEXPORT jboolean JNICALL Java_sun_java2d_d3d_D3DGraphicsDevice_initD3D
{
J2dTraceLn(J2D_TRACE_INFO, "D3DGD_initD3D");
jboolean result = JNI_FALSE;
AwtToolkit::GetInstance().InvokeFunction(InitD3D, &result);
jboolean result = D3DInitializer::GetInstance().EnsureInited()
? JNI_TRUE : JNI_FALSE;
J2dTraceLn1(J2D_TRACE_INFO, "D3DGD_initD3D: result=%x", result);
return result;
}
......
......@@ -40,6 +40,7 @@ static BOOL bNoHwCheck = (getenv("J2D_D3D_NO_HWCHECK") != NULL);
D3DPipelineManager *D3DPipelineManager::pMgr = NULL;
D3DPipelineManager * D3DPipelineManager::CreateInstance(void)
{
if (!IsD3DEnabled() ||
......@@ -179,6 +180,12 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
HMONITOR hMon;
int gdiScreen;
D3DPipelineManager *pMgr;
// fix for 6946559: if d3d preloading fails jmv may be NULL
if (jvm == NULL) {
return;
}
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
pMgr = D3DPipelineManager::GetInstance();
......@@ -934,3 +941,87 @@ HRESULT D3DPipelineManager::GetD3DContext(UINT adapterOrdinal,
*ppd3dContext = pAdapters[adapterOrdinal].pd3dContext;
return res;
}
//==============================================================
// D3DInitializer
//==============================================================
D3DInitializer D3DInitializer::theInstance;
D3DInitializer::D3DInitializer()
: bComInitialized(false), pAdapterIniters(NULL)
{
}
D3DInitializer::~D3DInitializer()
{
if (pAdapterIniters) {
delete[] pAdapterIniters;
}
}
void D3DInitializer::InitImpl()
{
J2dRlsTraceLn(J2D_TRACE_INFO, "D3DInitializer::InitImpl");
if (SUCCEEDED(::CoInitialize(NULL))) {
bComInitialized = true;
}
D3DPipelineManager *pMgr = D3DPipelineManager::CreateInstance();
if (pMgr != NULL) {
UINT adapterCount = pMgr->adapterCount;
pAdapterIniters = new D3DAdapterInitializer[adapterCount];
for (UINT i=0; i<adapterCount; i++) {
pAdapterIniters[i].setAdapter(i);
AwtToolkit::GetInstance().GetPreloadThread().AddAction(&pAdapterIniters[i]);
}
}
}
void D3DInitializer::CleanImpl(bool reInit)
{
J2dRlsTraceLn1(J2D_TRACE_INFO, "D3DInitializer::CleanImpl (%s)",
reInit ? "RELAUNCH" : "normal");
D3DPipelineManager::DeleteInstance();
if (bComInitialized) {
CoUninitialize();
}
}
void D3DInitializer::D3DAdapterInitializer::InitImpl()
{
J2dRlsTraceLn1(J2D_TRACE_INFO, "D3DAdapterInitializer::InitImpl(%d) started", adapter);
D3DPipelineManager *pMgr = D3DPipelineManager::GetInstance();
if (pMgr == NULL) {
return;
}
D3DContext *pd3dContext;
pMgr->GetD3DContext(adapter, &pd3dContext);
J2dRlsTraceLn1(J2D_TRACE_INFO, "D3DAdapterInitializer::InitImpl(%d) finished", adapter);
}
void D3DInitializer::D3DAdapterInitializer::CleanImpl(bool reInit)
{
// nothing to do - D3DPipelineManager cleans adapters
}
extern "C" {
/*
* Export function to start D3D preloading
* (called from java/javaw - see src/windows/bin/java-md.c)
*/
__declspec(dllexport) int preloadD3D()
{
J2dRlsTraceLn(J2D_TRACE_INFO, "AWT warmup: preloadD3D");
AwtToolkit::GetInstance().GetPreloadThread().AddAction(&D3DInitializer::GetInstance());
return 1;
}
}
......@@ -26,6 +26,7 @@
#include "D3DPipeline.h"
#include "D3DContext.h"
#include "awt_Toolkit.h"
typedef class D3DPipelineManager *LPD3DPIPELINEMANAGER;
......@@ -38,11 +39,15 @@ typedef struct D3DAdapter
class D3DPIPELINE_API D3DPipelineManager
{
public:
friend class D3DInitializer;
private:
// creates and initializes instance of D3DPipelineManager, may return NULL
static D3DPipelineManager* CreateInstance(void);
// deletes the single instance of the manager
static void DeleteInstance();
public:
// returns the single instance of the manager, may return NULL
static D3DPipelineManager* GetInstance(void);
......@@ -143,3 +148,40 @@ private:
#define OS_ALL (OS_VISTA|OS_WINSERV_2008|OS_WINXP|OS_WINXP_64|OS_WINSERV_2003)
#define OS_UNKNOWN (~OS_ALL)
BOOL D3DPPLM_OsVersionMatches(USHORT osInfo);
class D3DInitializer : public AwtToolkit::PreloadAction {
private:
D3DInitializer();
~D3DInitializer();
protected:
// PreloadAction overrides
virtual void InitImpl();
virtual void CleanImpl(bool reInit);
public:
static D3DInitializer& GetInstance() { return theInstance; }
private:
// single instance
static D3DInitializer theInstance;
// adapter initializer class
class D3DAdapterInitializer : public AwtToolkit::PreloadAction {
public:
void setAdapter(UINT adapter) { this->adapter = adapter; }
protected:
// PreloadAction overrides
virtual void InitImpl();
virtual void CleanImpl(bool reInit);
private:
UINT adapter;
};
// the flag indicates success of COM initialization
bool bComInitialized;
D3DAdapterInitializer *pAdapterIniters;
};
......@@ -28,7 +28,8 @@
#include "WindowsFlags.h"
BOOL accelReset; // reset registry 2d acceleration settings
BOOL useD3D; // d3d enabled flag
BOOL useD3D = TRUE; // d3d enabled flag
// initially is TRUE to allow D3D preloading
BOOL forceD3DUsage; // force d3d on or off
jboolean g_offscreenSharing; // JAWT accelerated surface sharing
BOOL checkRegistry; // Diagnostic tool: outputs 2d registry settings
......
......@@ -540,34 +540,15 @@ jobject CreateLocaleObject(JNIEnv *env, const char * name)
{
TRY;
// get language, country, variant information
char * language = (char *)safe_Malloc(strlen(name) + 1);
char * country;
char * variant;
DASSERT(!safe_ExceptionOccurred(env));
strcpy(language, name);
for (country = language; *country != '_' && *country != '\0'; country++);
if (*country == '_') {
*country++ = '\0';
for (variant = country; *variant != '_' && *variant != '\0'; variant++);
if (*variant == '_') {
*variant++ = '\0';
}
} else {
variant = country;
}
// create Locale object
jobject langObj = env->NewStringUTF(language);
jobject ctryObj = env->NewStringUTF(country);
jobject vrntObj = env->NewStringUTF(variant);
jobject localeObj = JNU_NewObjectByName(env, "java/util/Locale",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
langObj, ctryObj, vrntObj);
free(language);
env->DeleteLocalRef(langObj);
env->DeleteLocalRef(ctryObj);
env->DeleteLocalRef(vrntObj);
jobject langtagObj = env->NewStringUTF(name);
jobject localeObj = JNU_CallStaticMethodByName(env,
NULL,
"java/util/Locale",
"forLanguageTag",
"(Ljava/lang/String;)Ljava/util/Locale;",
langtagObj).l;
env->DeleteLocalRef(langtagObj);
return localeObj;
......
......@@ -28,6 +28,7 @@
#include "awt.h"
#include <signal.h>
#include <windowsx.h>
#include <process.h>
#include "awt_DrawingSurface.h"
#include "awt_AWTEvent.h"
......@@ -88,7 +89,7 @@ extern void DWMResetCompositionEnabled();
/* Initialize the Java VM instance variable when the library is
first loaded */
JavaVM *jvm;
JavaVM *jvm = NULL;
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved)
......@@ -358,6 +359,95 @@ HWND AwtToolkit::CreateToolkitWnd(LPCTSTR name)
return hwnd;
}
struct ToolkitThreadProc_Data {
bool result;
HANDLE hCompleted;
jobject thread;
};
void ToolkitThreadProc(void *param)
{
ToolkitThreadProc_Data *data = (ToolkitThreadProc_Data *)param;
bool bNotified = false;
JNIEnv *env;
JavaVMAttachArgs attachArgs;
attachArgs.version = JNI_VERSION_1_2;
attachArgs.name = "AWT-Windows";
attachArgs.group = NULL;
jint res = jvm->AttachCurrentThreadAsDaemon((void **)&env, &attachArgs);
if (res < 0) {
return;
}
jobject thread = env->NewGlobalRef(data->thread);
if (thread != NULL) {
jclass cls = env->GetObjectClass(thread);
if (cls != NULL) {
jmethodID runId = env->GetMethodID(cls, "run", "()V");
if (runId != NULL) {
data->result = true;
::SetEvent(data->hCompleted);
bNotified = true;
env->CallVoidMethod(thread, runId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
// TODO: handle
}
}
env->DeleteLocalRef(cls);
}
env->DeleteGlobalRef(thread);
}
if (!bNotified) {
::SetEvent(data->hCompleted);
}
jvm->DetachCurrentThread();
}
/*
* Class: sun_awt_windows_WToolkit
* Method: startToolkitThread
* Signature: (Ljava/lang/Runnable;)Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WToolkit_startToolkitThread(JNIEnv *env, jclass cls, jobject thread)
{
AwtToolkit& tk = AwtToolkit::GetInstance();
ToolkitThreadProc_Data data;
data.result = false;
data.thread = env->NewGlobalRef(thread);
if (data.thread == NULL) {
return JNI_FALSE;
}
data.hCompleted = ::CreateEvent(NULL, FALSE, FALSE, NULL);
bool result = tk.GetPreloadThread()
.InvokeAndTerminate(ToolkitThreadProc, &data);
if (result) {
::WaitForSingleObject(data.hCompleted, INFINITE);
result = data.result;
} else {
// no awt preloading
// return back to the usual toolkit way
}
::CloseHandle(data.hCompleted);
env->DeleteGlobalRef(data.thread);
return result ? JNI_TRUE : JNI_FALSE;
}
BOOL AwtToolkit::Initialize(BOOL localPump) {
AwtToolkit& tk = AwtToolkit::GetInstance();
......@@ -371,6 +461,11 @@ BOOL AwtToolkit::Initialize(BOOL localPump) {
// ComCtl32Util was constructed but not disposed
ComCtl32Util::GetInstance().InitLibraries();
if (!localPump) {
// if preload thread was run, terminate it
preloadThread.Terminate(true);
}
/* Register this toolkit's helper window */
VERIFY(tk.RegisterClass() != NULL);
......@@ -439,7 +534,7 @@ BOOL AwtToolkit::Dispose() {
// dispose Direct3D-related resources. This should be done
// before AwtObjectList::Cleanup() as the d3d will attempt to
// shutdown when the last of its windows is disposed of
D3DPipelineManager::DeleteInstance();
D3DInitializer::GetInstance().Clean();
AwtObjectList::Cleanup();
AwtFont::Cleanup();
......@@ -1635,6 +1730,270 @@ void AwtToolkit::GetWindowRect(HWND hWnd, LPRECT lpRect)
::GetWindowRect(hWnd, lpRect);
}
/************************************************************************
* AWT preloading support
*/
bool AwtToolkit::PreloadAction::EnsureInited()
{
DWORD _initThreadId = GetInitThreadID();
if (_initThreadId != 0) {
// already inited
// ensure the action is inited on correct thread
PreloadThread &preloadThread
= AwtToolkit::GetInstance().GetPreloadThread();
if (_initThreadId == preloadThread.GetThreadId()) {
if (!preloadThread.IsWrongThread()) {
return true;
}
// inited on preloadThread (wrongThread), not cleaned yet
// have to wait cleanup completion
preloadThread.Wait4Finish();
} else {
// inited on other thread (Toolkit thread?)
// consider as correctly inited
return true;
}
}
// init on Toolkit thread
AwtToolkit::GetInstance().InvokeFunction(InitWrapper, this);
return true;
}
DWORD AwtToolkit::PreloadAction::GetInitThreadID()
{
CriticalSection::Lock lock(initLock);
return initThreadId;
}
bool AwtToolkit::PreloadAction::Clean()
{
DWORD _initThreadId = GetInitThreadID();
if (_initThreadId == ::GetCurrentThreadId()) {
// inited on this thread
Clean(false);
return true;
}
return false;
}
/*static*/
void AwtToolkit::PreloadAction::InitWrapper(void *param)
{
PreloadAction *pThis = (PreloadAction *)param;
pThis->Init();
}
void AwtToolkit::PreloadAction::Init()
{
CriticalSection::Lock lock(initLock);
if (initThreadId == 0) {
initThreadId = ::GetCurrentThreadId();
InitImpl();
}
}
void AwtToolkit::PreloadAction::Clean(bool reInit) {
CriticalSection::Lock lock(initLock);
if (initThreadId != 0) {
//ASSERT(initThreadId == ::GetCurrentThreadId());
CleanImpl(reInit);
initThreadId = 0;
}
}
// PreloadThread implementation
AwtToolkit::PreloadThread::PreloadThread()
: status(None), wrongThread(false), threadId(0),
pActionChain(NULL), pLastProcessedAction(NULL),
execFunc(NULL), execParam(NULL)
{
hFinished = ::CreateEvent(NULL, TRUE, FALSE, NULL);
hAwake = ::CreateEvent(NULL, FALSE, FALSE, NULL);
}
AwtToolkit::PreloadThread::~PreloadThread()
{
//Terminate(false);
::CloseHandle(hFinished);
::CloseHandle(hAwake);
}
bool AwtToolkit::PreloadThread::AddAction(AwtToolkit::PreloadAction *pAction)
{
CriticalSection::Lock lock(threadLock);
if (status > Preloading) {
// too late - the thread already terminated or run as toolkit thread
return false;
}
if (pActionChain == NULL) {
// 1st action
pActionChain = pAction;
} else {
// add the action to the chain
PreloadAction *pChain = pActionChain;
while (true) {
PreloadAction *pNext = pChain->GetNext();
if (pNext == NULL) {
break;
}
pChain = pNext;
}
pChain->SetNext(pAction);
}
if (status > None) {
// the thread is already running (status == Preloading)
AwakeThread();
return true;
}
// need to start thread
::ResetEvent(hAwake);
::ResetEvent(hFinished);
HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0x100000, StaticThreadProc,
this, 0, &threadId);
if (hThread == 0) {
threadId = 0;
return false;
}
status = Preloading;
::CloseHandle(hThread);
return true;
}
bool AwtToolkit::PreloadThread::Terminate(bool wrongThread)
{
CriticalSection::Lock lock(threadLock);
if (status != Preloading) {
return false;
}
execFunc = NULL;
execParam = NULL;
this->wrongThread = wrongThread;
status = Cleaning;
AwakeThread();
return true;
}
bool AwtToolkit::PreloadThread::InvokeAndTerminate(void(_cdecl *fn)(void *), void *param)
{
CriticalSection::Lock lock(threadLock);
if (status != Preloading) {
return false;
}
execFunc = fn;
execParam = param;
status = fn == NULL ? Cleaning : RunningToolkit;
AwakeThread();
return true;
}
/*static*/
unsigned WINAPI AwtToolkit::PreloadThread::StaticThreadProc(void *param)
{
AwtToolkit::PreloadThread *pThis = (AwtToolkit::PreloadThread *)param;
return pThis->ThreadProc();
}
unsigned AwtToolkit::PreloadThread::ThreadProc()
{
void(_cdecl *_execFunc)(void *) = NULL;
void *_execParam = NULL;
bool _wrongThread = false;
// initialization
while (true) {
PreloadAction *pAction;
{
CriticalSection::Lock lock(threadLock);
if (status != Preloading) {
// get invoke parameters
_execFunc = execFunc;
_execParam = execParam;
_wrongThread = wrongThread;
break;
}
pAction = GetNextAction();
}
if (pAction != NULL) {
pAction->Init();
} else {
::WaitForSingleObject(hAwake, INFINITE);
}
}
// call a function from InvokeAndTerminate
if (_execFunc != NULL) {
_execFunc(_execParam);
} else {
// time to terminate..
}
// cleanup
{
CriticalSection::Lock lock(threadLock);
pLastProcessedAction = NULL; // goto 1st action in the chain
status = Cleaning;
}
for (PreloadAction *pAction = GetNextAction(); pAction != NULL;
pAction = GetNextAction()) {
pAction->Clean(_wrongThread);
}
// don't clear threadId! it is used by PreloadAction::EnsureInited
{
CriticalSection::Lock lock(threadLock);
status = Finished;
}
::SetEvent(hFinished);
return 0;
}
AwtToolkit::PreloadAction* AwtToolkit::PreloadThread::GetNextAction()
{
CriticalSection::Lock lock(threadLock);
PreloadAction *pAction = (pLastProcessedAction == NULL)
? pActionChain
: pLastProcessedAction->GetNext();
if (pAction != NULL) {
pLastProcessedAction = pAction;
}
return pAction;
}
extern "C" {
/* Terminates preload thread (if it's still alive
* - it may occur if the application doesn't use AWT).
* The function is called from launcher after completion main java thread.
*/
__declspec(dllexport) void preloadStop()
{
AwtToolkit::GetInstance().GetPreloadThread().Terminate(false);
}
}
/************************************************************************
* Toolkit native methods
*/
......
......@@ -465,6 +465,151 @@ public:
void InstallMouseLowLevelHook();
void UninstallMouseLowLevelHook();
/* AWT preloading (early Toolkit thread start)
*/
public:
/* Toolkit preload action class.
* Preload actions should be registered with
* AwtToolkit::getInstance().GetPreloadThread().AddAction().
* AwtToolkit thread calls InitImpl method at the beghining
* and CleanImpl(false) before exiting for all registered actions.
* If an application provides own Toolkit thread
* (sun.awt.windows.WToolkit.embeddedInit), the thread calls Clean(true)
* for each action.
*/
class PreloadThread; // forward declaration
class PreloadAction {
friend class PreloadThread;
public:
PreloadAction() : initThreadId(0), pNext(NULL) {}
virtual ~PreloadAction() {}
protected:
// called by PreloadThread or as result
// of EnsureInited() call (on Toolkit thread!).
virtual void InitImpl() = 0;
// called by PreloadThread (before exiting).
// reInit == false: normal shutdown;
// reInit == true: PreloadThread is shutting down due external
// Toolkit thread was provided.
virtual void CleanImpl(bool reInit) = 0;
public:
// Initialized the action on the Toolkit thread if not yet initialized.
bool EnsureInited();
// returns thread ID which the action was inited on (0 if not inited)
DWORD GetInitThreadID();
// Allows to deinitialize action earlier.
// The method must be called on the Toolkit thread only.
// returns true on success,
// false if the action was inited on other thread.
bool Clean();
private:
unsigned initThreadId;
// lock for Init/Clean
CriticalSection initLock;
// Chain support (for PreloadThread)
PreloadAction *pNext; // for action chain used by PreloadThread
void SetNext(PreloadAction *pNext) { this->pNext = pNext; }
PreloadAction *GetNext() { return pNext; }
// wrapper for AwtToolkit::InvokeFunction
static void InitWrapper(void *param);
void Init();
void Clean(bool reInit);
};
/** Toolkit preload thread class.
*/
class PreloadThread {
public:
PreloadThread();
~PreloadThread();
// adds action & start the thread if not yet started
bool AddAction(PreloadAction *pAction);
// sets termination flag; returns true if the thread is running.
// wrongThread specifies cause of the termination:
// false means termination on the application shutdown;
// wrongThread is used as reInit parameter for action cleanup.
bool Terminate(bool wrongThread);
bool InvokeAndTerminate(void(_cdecl *fn)(void *), void *param);
// waits for the the thread completion;
// use the method after Terminate() only if Terminate() returned true
INLINE void Wait4Finish() {
::WaitForSingleObject(hFinished, INFINITE);
}
INLINE unsigned GetThreadId() {
CriticalSection::Lock lock(threadLock);
return threadId;
}
INLINE bool IsWrongThread() {
CriticalSection::Lock lock(threadLock);
return wrongThread;
}
private:
// data access lock
CriticalSection threadLock;
// the thread status
enum Status {
None = -1, // initial
Preloading = 0, // preloading in progress
RunningToolkit, // Running as Toolkit thread
Cleaning, // exited from Toolkit thread proc, cleaning
Finished //
} status;
// "wrong thread" flag
bool wrongThread;
// thread proc (calls (this)param->ThreadProc())
static unsigned WINAPI StaticThreadProc(void *param);
unsigned ThreadProc();
INLINE void AwakeThread() {
::SetEvent(hAwake);
}
// if threadId != 0 -> we are running
unsigned threadId;
// ThreadProc sets the event on exit
HANDLE hFinished;
// ThreadProc waits on the event for NewAction/Terminate/InvokeAndTerminate
HANDLE hAwake;
// function/param to invoke (InvokeAndTerminate)
// if execFunc == NULL => just terminate
void(_cdecl *execFunc)(void *);
void *execParam;
// action chain
PreloadAction *pActionChain;
PreloadAction *pLastProcessedAction;
// returns next action in the list (NULL if no more actions)
PreloadAction* GetNextAction();
};
INLINE PreloadThread& GetPreloadThread() { return preloadThread; }
private:
PreloadThread preloadThread;
};
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests BasicStroke encoding
* @author Sergey Malenkov
*/
import java.awt.BasicStroke;
public final class java_awt_BasicStroke extends AbstractTest<BasicStroke> {
public static void main(String[] args) {
new java_awt_BasicStroke().test(true);
}
protected BasicStroke getObject() {
return new BasicStroke();
}
protected BasicStroke getAnotherObject() {
float[] f = {1.0f, 2.0f, 3.0f, 4.0f};
return new BasicStroke(f[1], BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, f[2], f, f[3]);
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests GradientPaint encoding
* @author Sergey Malenkov
*/
import java.awt.Color;
import java.awt.GradientPaint;
public final class java_awt_GradientPaint extends AbstractTest<GradientPaint> {
public static void main(String[] args) {
new java_awt_GradientPaint().test(true);
}
protected GradientPaint getObject() {
return new GradientPaint(0.1f, 0.2f, Color.BLACK, 0.3f, 0.4f, Color.WHITE, true);
}
protected GradientPaint getAnotherObject() {
return null; /* TODO: could not update property
return new GradientPaint(0.4f, 0.3f, Color.WHITE, 0.2f, 0.1f, Color.BLACK, false);*/
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests LinearGradientPaint encoding
* @author Sergey Malenkov
*/
import java.awt.Color;
import java.awt.LinearGradientPaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import static java.awt.MultipleGradientPaint.ColorSpaceType.LINEAR_RGB;
import static java.awt.MultipleGradientPaint.CycleMethod.REFLECT;
public final class java_awt_LinearGradientPaint extends AbstractTest<LinearGradientPaint> {
public static void main(String[] args) {
new java_awt_LinearGradientPaint().test(true);
}
protected LinearGradientPaint getObject() {
float[] f = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
Color[] c = { Color.BLUE, Color.GREEN, Color.RED, Color.BLUE, Color.GREEN, Color.RED };
return new LinearGradientPaint(f[0], f[1], f[2], f[3], f, c);
}
protected LinearGradientPaint getAnotherObject() {
return null; /* TODO: could not update property
float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f };
Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE };
return new LinearGradientPaint(
new Point2D.Float(f[0], f[1]),
new Point2D.Float(f[2], f[3]),
f, c, REFLECT, LINEAR_RGB,
new AffineTransform(f));*/
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests RadialGradientPaint encoding
* @author Sergey Malenkov
*/
import java.awt.Color;
import java.awt.RadialGradientPaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import static java.awt.MultipleGradientPaint.ColorSpaceType.LINEAR_RGB;
import static java.awt.MultipleGradientPaint.CycleMethod.REFLECT;
public final class java_awt_RadialGradientPaint extends AbstractTest<RadialGradientPaint> {
public static void main(String[] args) {
new java_awt_RadialGradientPaint().test(true);
}
protected RadialGradientPaint getObject() {
float[] f = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
Color[] c = { Color.BLUE, Color.GREEN, Color.RED, Color.BLUE, Color.GREEN, Color.RED };
return new RadialGradientPaint(f[0], f[1], f[2], f, c);
}
protected RadialGradientPaint getAnotherObject() {
return null; /* TODO: could not update property
float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f };
Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE };
return new RadialGradientPaint(
new Point2D.Float(f[0], f[1]), 100.0f,
new Point2D.Float(f[2], f[3]),
f, c, REFLECT, LINEAR_RGB,
new AffineTransform(f));*/
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests AffineTransform encoding
* @author Sergey Malenkov
*/
import java.awt.geom.AffineTransform;
public final class java_awt_geom_AffineTransform extends AbstractTest<AffineTransform> {
public static void main(String[] args) {
new java_awt_geom_AffineTransform().test(true);
}
protected AffineTransform getObject() {
return new AffineTransform(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f);
}
protected AffineTransform getAnotherObject() {
return new AffineTransform(0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f);
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4358979
* @summary Tests StrokeBorder encoding
* @author Sergey Malenkov
*/
import java.awt.BasicStroke;
import java.awt.Color;
import javax.swing.border.StrokeBorder;
public final class javax_swing_border_StrokeBorder extends AbstractTest<StrokeBorder> {
public static void main(String[] args) {
new javax_swing_border_StrokeBorder().test(true);
}
protected StrokeBorder getObject() {
return new StrokeBorder(new BasicStroke(0), Color.WHITE);
}
protected StrokeBorder getAnotherObject() {
return null; // TODO: could not update property
//return new StrokeBorder(new BasicStroke(1));
}
}
......@@ -465,15 +465,15 @@ format locale: ID: be_BY, Name: Belarusian (Belarus)
default charset: UTF-8
OS Locale: be_BY.utf8@latin
default locale: ID: be_BY, Name: Belarusian (Belarus)
display locale: ID: be_BY, Name: Belarusian (Belarus)
format locale: ID: be_BY, Name: Belarusian (Belarus)
default locale: ID: be_BY_#Latn, Name: Belarusian (Latin,Belarus)
display locale: ID: be_BY_#Latn, Name: Belarusian (Latin,Belarus)
format locale: ID: be_BY_#Latn, Name: Belarusian (Latin,Belarus)
default charset: UTF-8
OS Locale: be_BY@latin
default locale: ID: be_BY, Name: Belarusian (Belarus)
display locale: ID: be_BY, Name: Belarusian (Belarus)
format locale: ID: be_BY, Name: Belarusian (Belarus)
default locale: ID: be_BY_#Latn, Name: Belarusian (Latin,Belarus)
display locale: ID: be_BY_#Latn, Name: Belarusian (Latin,Belarus)
format locale: ID: be_BY_#Latn, Name: Belarusian (Latin,Belarus)
default charset: UTF-8
OS Locale: bg_BG
......@@ -518,13 +518,13 @@ display locale: ID: bn_IN, Name: Bengali (India)
format locale: ID: bn_IN, Name: Bengali (India)
default charset: UTF-8
OS Locale: bokml
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
OS Locale: bokmal
default locale: ID: nb_NO, Name: Norwegian Bokml (Norway)
display locale: ID: nb_NO, Name: Norwegian Bokml (Norway)
format locale: ID: nb_NO, Name: Norwegian Bokml (Norway)
default charset: ISO-8859-1
OS Locale: bokmal
OS Locale: bokml
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
......@@ -579,15 +579,15 @@ format locale: ID: bs_BA, Name: Bosnian (Bosnia and Herzegovina)
default charset: UTF-8
OS Locale: byn_ER
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: byn_ER, Name: Blin (Eritrea)
display locale: ID: byn_ER, Name: Blin (Eritrea)
format locale: ID: byn_ER, Name: Blin (Eritrea)
default charset: UTF-8
OS Locale: byn_ER.utf8
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: byn_ER, Name: Blin (Eritrea)
display locale: ID: byn_ER, Name: Blin (Eritrea)
format locale: ID: byn_ER, Name: Blin (Eritrea)
default charset: UTF-8
OS Locale: ca_AD
......@@ -705,15 +705,15 @@ format locale: ID: cs_CZ, Name: Czech (Czech Republic)
default charset: UTF-8
OS Locale: csb_PL
default locale: ID: en_PL, Name: English (Poland)
display locale: ID: en_PL, Name: English (Poland)
format locale: ID: en_PL, Name: English (Poland)
default locale: ID: csb_PL, Name: Kashubian (Poland)
display locale: ID: csb_PL, Name: Kashubian (Poland)
format locale: ID: csb_PL, Name: Kashubian (Poland)
default charset: UTF-8
OS Locale: csb_PL.utf8
default locale: ID: en_PL, Name: English (Poland)
display locale: ID: en_PL, Name: English (Poland)
format locale: ID: en_PL, Name: English (Poland)
default locale: ID: csb_PL, Name: Kashubian (Poland)
display locale: ID: csb_PL, Name: Kashubian (Poland)
format locale: ID: csb_PL, Name: Kashubian (Poland)
default charset: UTF-8
OS Locale: cy_GB
......@@ -939,9 +939,9 @@ format locale: ID: dz_BT, Name: Dzongkha (Bhutan)
default charset: UTF-8
OS Locale: eesti
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: et_EE, Name: Estonian (Estonia)
display locale: ID: et_EE, Name: Estonian (Estonia)
format locale: ID: et_EE, Name: Estonian (Estonia)
default charset: ISO-8859-1
OS Locale: el_CY
......@@ -1623,9 +1623,9 @@ format locale: ID: es_VE, Name: Spanish (Venezuela)
default charset: UTF-8
OS Locale: estonian
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: et_EE, Name: Estonian (Estonia)
display locale: ID: et_EE, Name: Estonian (Estonia)
format locale: ID: et_EE, Name: Estonian (Estonia)
default charset: ISO-8859-1
OS Locale: et_EE
......@@ -1929,15 +1929,15 @@ format locale: ID: ga_IE, Name: Irish (Ireland)
default charset: ISO-8859-15
OS Locale: galego
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: gl_ES, Name: Gallegan (Spain)
display locale: ID: gl_ES, Name: Gallegan (Spain)
format locale: ID: gl_ES, Name: Gallegan (Spain)
default charset: ISO-8859-1
OS Locale: galician
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: gl_ES, Name: Gallegan (Spain)
display locale: ID: gl_ES, Name: Gallegan (Spain)
format locale: ID: gl_ES, Name: Gallegan (Spain)
default charset: ISO-8859-1
OS Locale: gd_GB
......@@ -1965,51 +1965,51 @@ format locale: ID: de_DE, Name: German (Germany)
default charset: ISO-8859-1
OS Locale: gez_ER
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: gez_ER, Name: Geez (Eritrea)
display locale: ID: gez_ER, Name: Geez (Eritrea)
format locale: ID: gez_ER, Name: Geez (Eritrea)
default charset: UTF-8
OS Locale: gez_ER.utf8
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: gez_ER, Name: Geez (Eritrea)
display locale: ID: gez_ER, Name: Geez (Eritrea)
format locale: ID: gez_ER, Name: Geez (Eritrea)
default charset: UTF-8
OS Locale: gez_ER.utf8@abegede
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: gez_ER, Name: Geez (Eritrea)
display locale: ID: gez_ER, Name: Geez (Eritrea)
format locale: ID: gez_ER, Name: Geez (Eritrea)
default charset: UTF-8
OS Locale: gez_ER@abegede
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: gez_ER, Name: Geez (Eritrea)
display locale: ID: gez_ER, Name: Geez (Eritrea)
format locale: ID: gez_ER, Name: Geez (Eritrea)
default charset: UTF-8
OS Locale: gez_ET
default locale: ID: en_ET, Name: English (Ethiopia)
display locale: ID: en_ET, Name: English (Ethiopia)
format locale: ID: en_ET, Name: English (Ethiopia)
default locale: ID: gez_ET, Name: Geez (Ethiopia)
display locale: ID: gez_ET, Name: Geez (Ethiopia)
format locale: ID: gez_ET, Name: Geez (Ethiopia)
default charset: UTF-8
OS Locale: gez_ET.utf8
default locale: ID: en_ET, Name: English (Ethiopia)
display locale: ID: en_ET, Name: English (Ethiopia)
format locale: ID: en_ET, Name: English (Ethiopia)
default locale: ID: gez_ET, Name: Geez (Ethiopia)
display locale: ID: gez_ET, Name: Geez (Ethiopia)
format locale: ID: gez_ET, Name: Geez (Ethiopia)
default charset: UTF-8
OS Locale: gez_ET.utf8@abegede
default locale: ID: en_ET, Name: English (Ethiopia)
display locale: ID: en_ET, Name: English (Ethiopia)
format locale: ID: en_ET, Name: English (Ethiopia)
default locale: ID: gez_ET, Name: Geez (Ethiopia)
display locale: ID: gez_ET, Name: Geez (Ethiopia)
format locale: ID: gez_ET, Name: Geez (Ethiopia)
default charset: UTF-8
OS Locale: gez_ET@abegede
default locale: ID: en_ET, Name: English (Ethiopia)
display locale: ID: en_ET, Name: English (Ethiopia)
format locale: ID: en_ET, Name: English (Ethiopia)
default locale: ID: gez_ET, Name: Geez (Ethiopia)
display locale: ID: gez_ET, Name: Geez (Ethiopia)
format locale: ID: gez_ET, Name: Geez (Ethiopia)
default charset: UTF-8
OS Locale: gl_ES
......@@ -2139,21 +2139,21 @@ format locale: ID: hr_HR, Name: Croatian (Croatia)
default charset: ISO-8859-2
OS Locale: hsb_DE
default locale: ID: en_DE, Name: English (Germany)
display locale: ID: en_DE, Name: English (Germany)
format locale: ID: en_DE, Name: English (Germany)
default locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
display locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
format locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
default charset: ISO-8859-2
OS Locale: hsb_DE.iso88592
default locale: ID: en_DE, Name: English (Germany)
display locale: ID: en_DE, Name: English (Germany)
format locale: ID: en_DE, Name: English (Germany)
default locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
display locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
format locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
default charset: ISO-8859-2
OS Locale: hsb_DE.utf8
default locale: ID: en_DE, Name: English (Germany)
display locale: ID: en_DE, Name: English (Germany)
format locale: ID: en_DE, Name: English (Germany)
default locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
display locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
format locale: ID: hsb_DE, Name: Upper Sorbian (Germany)
default charset: UTF-8
OS Locale: hu_HU
......@@ -2445,15 +2445,15 @@ format locale: ID: ko_KR, Name: Korean (South Korea)
default charset: UTF-8
OS Locale: korean
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: ko_KR, Name: Korean (South Korea)
display locale: ID: ko_KR, Name: Korean (South Korea)
format locale: ID: ko_KR, Name: Korean (South Korea)
default charset: EUC-KR
OS Locale: korean.euc
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: ko_KR, Name: Korean (South Korea)
display locale: ID: ko_KR, Name: Korean (South Korea)
format locale: ID: ko_KR, Name: Korean (South Korea)
default charset: EUC-KR
OS Locale: ku_TR
......@@ -2523,9 +2523,9 @@ format locale: ID: lg_UG, Name: Ganda (Uganda)
default charset: UTF-8
OS Locale: lithuanian
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: lt_LT, Name: Lithuanian (Lithuania)
display locale: ID: lt_LT, Name: Lithuanian (Lithuania)
format locale: ID: lt_LT, Name: Lithuanian (Lithuania)
default charset: ISO-8859-13
OS Locale: lo_LA
......@@ -2577,15 +2577,15 @@ format locale: ID: lv_LV, Name: Latvian (Latvia)
default charset: UTF-8
OS Locale: mai_IN
default locale: ID: en_IN, Name: English (India)
display locale: ID: en_IN, Name: English (India)
format locale: ID: en_IN, Name: English (India)
default locale: ID: mai_IN, Name: Maithili (India)
display locale: ID: mai_IN, Name: Maithili (India)
format locale: ID: mai_IN, Name: Maithili (India)
default charset: UTF-8
OS Locale: mai_IN.utf8
default locale: ID: en_IN, Name: English (India)
display locale: ID: en_IN, Name: English (India)
format locale: ID: en_IN, Name: English (India)
default locale: ID: mai_IN, Name: Maithili (India)
display locale: ID: mai_IN, Name: Maithili (India)
format locale: ID: mai_IN, Name: Maithili (India)
default charset: UTF-8
OS Locale: mg_MG
......@@ -2859,21 +2859,21 @@ format locale: ID: nr_ZA, Name: South Ndebele (South Africa)
default charset: UTF-8
OS Locale: nso_ZA
default locale: ID: en_ZA, Name: English (South Africa)
display locale: ID: en_ZA, Name: English (South Africa)
format locale: ID: en_ZA, Name: English (South Africa)
default locale: ID: nso_ZA, Name: Pedi (South Africa)
display locale: ID: nso_ZA, Name: Pedi (South Africa)
format locale: ID: nso_ZA, Name: Pedi (South Africa)
default charset: UTF-8
OS Locale: nso_ZA.utf8
default locale: ID: en_ZA, Name: English (South Africa)
display locale: ID: en_ZA, Name: English (South Africa)
format locale: ID: en_ZA, Name: English (South Africa)
default locale: ID: nso_ZA, Name: Pedi (South Africa)
display locale: ID: nso_ZA, Name: Pedi (South Africa)
format locale: ID: nso_ZA, Name: Pedi (South Africa)
default charset: UTF-8
OS Locale: nynorsk
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: nn_NO, Name: Norwegian Nynorsk (Norway)
display locale: ID: nn_NO, Name: Norwegian Nynorsk (Norway)
format locale: ID: nn_NO, Name: Norwegian Nynorsk (Norway)
default charset: ISO-8859-1
OS Locale: oc_FR
......@@ -3147,15 +3147,15 @@ format locale: ID: si_LK, Name: Sinhalese (Sri Lanka)
default charset: UTF-8
OS Locale: sid_ET
default locale: ID: en_ET, Name: English (Ethiopia)
display locale: ID: en_ET, Name: English (Ethiopia)
format locale: ID: en_ET, Name: English (Ethiopia)
default locale: ID: sid_ET, Name: Sidamo (Ethiopia)
display locale: ID: sid_ET, Name: Sidamo (Ethiopia)
format locale: ID: sid_ET, Name: Sidamo (Ethiopia)
default charset: UTF-8
OS Locale: sid_ET.utf8
default locale: ID: en_ET, Name: English (Ethiopia)
display locale: ID: en_ET, Name: English (Ethiopia)
format locale: ID: en_ET, Name: English (Ethiopia)
default locale: ID: sid_ET, Name: Sidamo (Ethiopia)
display locale: ID: sid_ET, Name: Sidamo (Ethiopia)
format locale: ID: sid_ET, Name: Sidamo (Ethiopia)
default charset: UTF-8
OS Locale: sk_SK
......@@ -3321,39 +3321,39 @@ format locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
default charset: UTF-8
OS Locale: sr_ME
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_ME, Name: Serbian (Montenegro)
display locale: ID: sr_ME, Name: Serbian (Montenegro)
format locale: ID: sr_ME, Name: Serbian (Montenegro)
default charset: UTF-8
OS Locale: sr_ME.utf8
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_ME, Name: Serbian (Montenegro)
display locale: ID: sr_ME, Name: Serbian (Montenegro)
format locale: ID: sr_ME, Name: Serbian (Montenegro)
default charset: UTF-8
OS Locale: sr_RS
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_RS, Name: Serbian (Serbia)
display locale: ID: sr_RS, Name: Serbian (Serbia)
format locale: ID: sr_RS, Name: Serbian (Serbia)
default charset: UTF-8
OS Locale: sr_RS.utf8
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_RS, Name: Serbian (Serbia)
display locale: ID: sr_RS, Name: Serbian (Serbia)
format locale: ID: sr_RS, Name: Serbian (Serbia)
default charset: UTF-8
OS Locale: sr_RS.utf8@latin
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_RS_#Latn, Name: Serbian (Latin,Serbia)
display locale: ID: sr_RS_#Latn, Name: Serbian (Latin,Serbia)
format locale: ID: sr_RS_#Latn, Name: Serbian (Latin,Serbia)
default charset: UTF-8
OS Locale: sr_RS@latin
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_RS_#Latn, Name: Serbian (Latin,Serbia)
display locale: ID: sr_RS_#Latn, Name: Serbian (Latin,Serbia)
format locale: ID: sr_RS_#Latn, Name: Serbian (Latin,Serbia)
default charset: UTF-8
OS Locale: ss_ZA
......@@ -3507,9 +3507,9 @@ format locale: ID: th_TH, Name: Thai (Thailand)
default charset: UTF-8
OS Locale: thai
default locale: ID: en, Name: English
display locale: ID: en, Name: English
format locale: ID: en, Name: English
default locale: ID: th_TH, Name: Thai (Thailand)
display locale: ID: th_TH, Name: Thai (Thailand)
format locale: ID: th_TH, Name: Thai (Thailand)
default charset: TIS-620
OS Locale: ti_ER
......@@ -3537,15 +3537,15 @@ format locale: ID: ti_ET, Name: Tigrinya (Ethiopia)
default charset: UTF-8
OS Locale: tig_ER
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: tig_ER, Name: Tigre (Eritrea)
display locale: ID: tig_ER, Name: Tigre (Eritrea)
format locale: ID: tig_ER, Name: Tigre (Eritrea)
default charset: UTF-8
OS Locale: tig_ER.utf8
default locale: ID: en_ER, Name: English (Eritrea)
display locale: ID: en_ER, Name: English (Eritrea)
format locale: ID: en_ER, Name: English (Eritrea)
default locale: ID: tig_ER, Name: Tigre (Eritrea)
display locale: ID: tig_ER, Name: Tigre (Eritrea)
format locale: ID: tig_ER, Name: Tigre (Eritrea)
default charset: UTF-8
OS Locale: tl_PH
......@@ -3681,15 +3681,15 @@ format locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
default charset: ISO-8859-1
OS Locale: uz_UZ.utf8@cyrillic
default locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
display locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
format locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
default locale: ID: uz_UZ_#Cyrl, Name: Uzbek (Cyrillic,Uzbekistan)
display locale: ID: uz_UZ_#Cyrl, Name: Uzbek (Cyrillic,Uzbekistan)
format locale: ID: uz_UZ_#Cyrl, Name: Uzbek (Cyrillic,Uzbekistan)
default charset: UTF-8
OS Locale: uz_UZ@cyrillic
default locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
display locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
format locale: ID: uz_UZ, Name: Uzbek (Uzbekistan)
default locale: ID: uz_UZ_#Cyrl, Name: Uzbek (Cyrillic,Uzbekistan)
display locale: ID: uz_UZ_#Cyrl, Name: Uzbek (Cyrillic,Uzbekistan)
format locale: ID: uz_UZ_#Cyrl, Name: Uzbek (Cyrillic,Uzbekistan)
default charset: UTF-8
OS Locale: ve_ZA
......
......@@ -1128,9 +1128,9 @@ format locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
default charset: ISO-8859-1
OS Locale: no_NY
default locale: ID: no_, Name: Norwegian ()
display locale: ID: no_, Name: Norwegian ()
format locale: ID: no_, Name: Norwegian ()
default locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
display locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
format locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
default charset: ISO-8859-1
OS Locale: nr
......@@ -1332,9 +1332,9 @@ format locale: ID: sq_AL, Name: Albanian (Albania)
default charset: ISO-8859-2
OS Locale: sr_SP
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
display locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
format locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
default charset: ISO-8859-5
OS Locale: sr_YU
......@@ -1721,5 +1721,5 @@ default charset: UTF-8
OS Locale (LC_CTYPE: C, LC_MESSAGES: zh_CN.UTF-8)
default locale: ID: zh_CN, Name: Chinese (China)
display locale: ID: zh_CN, Name: Chinese (China)
format locale: ID: en, Name: English
format locale: ID: en_CN, Name: English (China)
default charset: US-ASCII
......@@ -1128,9 +1128,9 @@ format locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
default charset: ISO-8859-1
OS Locale: no_NY
default locale: ID: no_, Name: Norwegian ()
display locale: ID: no_, Name: Norwegian ()
format locale: ID: no_, Name: Norwegian ()
default locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
display locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
format locale: ID: no_NO_NY, Name: Norwegian (Norway,Nynorsk)
default charset: ISO-8859-1
OS Locale: nr
......@@ -1332,9 +1332,9 @@ format locale: ID: sq_AL, Name: Albanian (Albania)
default charset: ISO-8859-2
OS Locale: sr_SP
default locale: ID: sr, Name: Serbian
display locale: ID: sr, Name: Serbian
format locale: ID: sr, Name: Serbian
default locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
display locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
format locale: ID: sr_CS, Name: Serbian (Serbia and Montenegro)
default charset: ISO-8859-5
OS Locale: sr_YU
......
......@@ -25,7 +25,7 @@
@summary test Resource Bundle for bug 4168625
@build Bug4168625Class Bug4168625Getter Bug4168625Resource Bug4168625Resource3 Bug4168625Resource3_en Bug4168625Resource3_en_CA Bug4168625Resource3_en_IE Bug4168625Resource3_en_US Bug4168625Resource2_en_US Bug4168625Resource2
@run main/timeout=600 Bug4168625Test
@bug 4168625
@bug 4168625 6993339
*/
/*
*
......@@ -50,9 +50,8 @@ import java.util.*;
import java.io.*;
/**
* This test tries to correct three efficiency problems with the caching
* mechanism of ResourceBundle. All tests assume that none of the bundles
* have been previously loaded and cached. It also allows concurrent loads
* This test tries to correct two efficiency problems with the caching
* mechanism of ResourceBundle. It also allows concurrent loads
* of resource bundles to be performed if the bundles are unrelated (ex. a
* load of a local system resource by one thread while another thread is
* doing a slow load over a network).
......@@ -230,83 +229,6 @@ public class Bug4168625Test extends RBTestFmwk {
}
}
/**
* Previous versions of ResourceBundle exhibited the following caching behavior.
* Assume the class Bug4168625Resource_en exists. Bug4168625Resource_en_US does
* not. Two threads, ThreadA and ThreadB both try to get the same bundle.
* <P>
* <pre>
* ThreadA.getBundle("Bug4168625Resource", new Locale("en", "US"));
* A-->try to load Bug4168625Resource_en_US
* ThreadB.getBundle("Bug4168625Resource", new Locale("en", "US"));
* B-->try to load Bug4168625Resource_en_US
* B-->load Bug4168625Resource_en (#1)
* A-->load Bug4168625Resource_en (#2)
* A-->cache Bug4168625Resource_en (#2) as Bug4168625Resource_en
* A-->cache Bug4168625Resource_en (#2) as Bug4168625Resource_en_US
* A-->return Bug4168625Resource_en (#2)
* B-->cache Bug4168625Resource_en (#1) as Bug4168625Resource_en
* B-->cache Bug4168625Resource_en (#1) as Bug4168625Resource_en_US
* B-->return Bug4168625Resource_en (#1)
* </pre>
* <P>
* Both threads try and fail to load Bug4168625Resource_en_US. Both
* threads load Bug4168625Resource_en. Both threads get their own copy
* of the Bug4168625Resource_en resource.
*
* The desired behavior is as follows:
* <P>
* <pre>
* ThreadA.getBundle("Bug4168625Resource", new Locale("en", "US"));
* A-->try to load Bug4168625Resource_en_US
* ThreadB.getBundle("Bug4168625Resource", new Locale("en", "US"));
* B-->try to load Bug4168625Resource_en_US
* B-->load Bug4168625Resource_en
* A-->load Bug4168625Resource_en (block in ResourceBundle.getBundle)
* B-->cache Bug4168625Resource_en as Bug4168625Resource_en
* B-->cache Bug4168625Resource_en as Bug4168625Resource_en_US
* A-->return Bug4168625Resource_en
* B-->return Bug4168625Resource_en
* </pre>
* <P>
* Note that both threads return the same bundle object.
*/
public void testConcurrentLoading1() throws Exception {
final Loader loader = new Loader( new String[] { "Bug4168625Class" }, new String[] { "Bug4168625Resource3_en_US", "Bug4168625Resource3_en_CA" });
final Class c = loader.loadClass("Bug4168625Class");
final Bug4168625Getter test = (Bug4168625Getter)c.newInstance();
//both threads want the same resource
ConcurrentLoadingThread thread1 = new ConcurrentLoadingThread(loader, test, new Locale("en", "US"));
ConcurrentLoadingThread thread2 = new ConcurrentLoadingThread(loader, test, new Locale("en", "US"));
thread1.start(); //start thread 1
loader.waitForNotify(1); //wait for thread1 to do getBundle & block in loader
thread2.start(); //start second thread
loader.waitForNotify(2, 1000); //wait until thread2 blocks somewhere in getBundle
thread1.ping(); //continue both threads
thread2.ping();
thread1.join(); //wait unitl both threads complete
thread2.join();
//Now, examine the class loads that were done.
loader.logClasses("Classes loaded after completion of both threads:");
boolean dups = false;
for (int i = loader.loadedClasses.size() - 1; i >= 0 ; i--) {
final Object item = loader.loadedClasses.elementAt(i);
loader.loadedClasses.removeElementAt(i);
if (loader.loadedClasses.contains(item)) {
logln("Resource loaded more than once: "+item);
dups = true;
}
}
if (dups) {
errln("ResourceBundle loaded some classes multiple times");
}
}
private class ConcurrentLoadingThread extends Thread {
private Loader loader;
public Object bundle;
......@@ -355,7 +277,7 @@ public class Bug4168625Test extends RBTestFmwk {
* This test ensures that multiple resources can be loading at the same
* time as long as they don't depend on each other in some way.
*/
public void testConcurrentLoading2() throws Exception {
public void testConcurrentLoading() throws Exception {
final Loader loader = new Loader( new String[] { "Bug4168625Class" }, new String[] { "Bug4168625Resource3_en_US", "Bug4168625Resource3_en_CA" });
final Class c = loader.loadClass("Bug4168625Class");
final Bug4168625Getter test = (Bug4168625Getter)c.newInstance();
......
此差异已折叠。
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 6735286
@summary javax.swing.DefaultTableCellRender.getTableCellRendererComponent() doesn't allow passing null Tables
@author Pavel Porvatov
*/
import javax.swing.*;
public class bug6735286 {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new JTable().getDefaultRenderer(Object.class).getTableCellRendererComponent(null, "a value",
true, true, 0, 0);
}
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册