提交 d432c9f5 编写于 作者: L lana

Merge

...@@ -175,6 +175,10 @@ endif ...@@ -175,6 +175,10 @@ endif
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
COMPILEFONTCONFIG_FLAGS =
ifdef ALT_COMPILEFONTCONFIG_FLAGS
COMPILEFONTCONFIG_FLAGS += $(ALT_COMPILEFONTCONFIG_FLAGS)
endif
build: fontconfigs build: fontconfigs
...@@ -406,7 +410,7 @@ COMPILEFONTCONFIG_JARFILE = $(BUILDTOOLJARDIR)/compilefontconfig.jar ...@@ -406,7 +410,7 @@ COMPILEFONTCONFIG_JARFILE = $(BUILDTOOLJARDIR)/compilefontconfig.jar
$(LIBDIR)/%.bfc: $(FONTCONFIGS_SRC)/$(FONTCONFIGS_SRC_PREFIX)%.properties \ $(LIBDIR)/%.bfc: $(FONTCONFIGS_SRC)/$(FONTCONFIGS_SRC_PREFIX)%.properties \
$(COMPILEFONTCONFIG_JARFILE) $(COMPILEFONTCONFIG_JARFILE)
$(prep-target) $(prep-target)
$(BOOT_JAVA_CMD) -jar $(COMPILEFONTCONFIG_JARFILE) $< $@ $(BOOT_JAVA_CMD) -jar $(COMPILEFONTCONFIG_JARFILE) $(COMPILEFONTCONFIG_FLAGS) $< $@
$(install-module-file) $(install-module-file)
$(call chmod-file, 444) $(call chmod-file, 444)
@$(java-vm-cleanup) @$(java-vm-cleanup)
......
...@@ -222,6 +222,7 @@ class Zoneinfo { ...@@ -222,6 +222,7 @@ class Zoneinfo {
boolean continued = false; boolean continued = false;
Zone zone = null; Zone zone = null;
String l; String l;
lineNum = 0;
try { try {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
......
...@@ -58,20 +58,20 @@ import java.util.Set; ...@@ -58,20 +58,20 @@ import java.util.Set;
* It is also possible to perform numeric shaping explicitly using instances * It is also possible to perform numeric shaping explicitly using instances
* of <code>NumericShaper</code>, as this code snippet demonstrates:<br> * of <code>NumericShaper</code>, as this code snippet demonstrates:<br>
* <blockquote><pre> * <blockquote><pre>
* char[] text = ...; * char[] text = ...;
* // shape all EUROPEAN digits (except zero) to ARABIC digits * // shape all EUROPEAN digits (except zero) to ARABIC digits
* NumericShaper shaper = NumericShaper.getShaper(NumericShaper.ARABIC); * NumericShaper shaper = NumericShaper.getShaper(NumericShaper.ARABIC);
* shaper.shape(text, start, count); * shaper.shape(text, start, count);
* *
* // shape European digits to ARABIC digits if preceding text is Arabic, or * // shape European digits to ARABIC digits if preceding text is Arabic, or
* // shape European digits to TAMIL digits if preceding text is Tamil, or * // shape European digits to TAMIL digits if preceding text is Tamil, or
* // leave European digits alone if there is no preceding text, or * // leave European digits alone if there is no preceding text, or
* // preceding text is neither Arabic nor Tamil * // preceding text is neither Arabic nor Tamil
* NumericShaper shaper = * NumericShaper shaper =
* NumericShaper.getContextualShaper(NumericShaper.ARABIC | * NumericShaper.getContextualShaper(NumericShaper.ARABIC |
* NumericShaper.TAMIL, * NumericShaper.TAMIL,
* NumericShaper.EUROPEAN); * NumericShaper.EUROPEAN);
* shaper.shape(text, start, count); * shaper.shape(text, start, count);
* </pre></blockquote> * </pre></blockquote>
* *
* <p><b>Bit mask- and enum-based Unicode ranges</b></p> * <p><b>Bit mask- and enum-based Unicode ranges</b></p>
...@@ -99,6 +99,37 @@ import java.util.Set; ...@@ -99,6 +99,37 @@ import java.util.Set;
* values are specified, such as {@code NumericShaper.Range.BALINESE}, * values are specified, such as {@code NumericShaper.Range.BALINESE},
* those ranges are ignored. * those ranges are ignored.
* *
* <p><b>Decimal Digits Precedence</b></p>
*
* <p>A Unicode range may have more than one set of decimal digits. If
* multiple decimal digits sets are specified for the same Unicode
* range, one of the sets will take precedence as follows.
*
* <table border=1 cellspacing=3 cellpadding=0 summary="NumericShaper constants precedence.">
* <tr>
* <th class="TableHeadingColor">Unicode Range</th>
* <th class="TableHeadingColor"><code>NumericShaper</code> Constants</th>
* <th class="TableHeadingColor">Precedence</th>
* </tr>
* <tr>
* <td rowspan="2">Arabic</td>
* <td>{@link NumericShaper#ARABIC NumericShaper.ARABIC}<br>
* {@link NumericShaper#EASTERN_ARABIC NumericShaper.EASTERN_ARABIC}</td>
* <td>{@link NumericShaper#EASTERN_ARABIC NumericShaper.EASTERN_ARABIC}</td>
* </tr>
* <tr>
* <td>{@link NumericShaper.Range#ARABIC}<br>
* {@link NumericShaper.Range#EASTERN_ARABIC}</td>
* <td>{@link NumericShaper.Range#EASTERN_ARABIC}</td>
* </tr>
* <tr>
* <td>Tai Tham</td>
* <td>{@link NumericShaper.Range#TAI_THAM_HORA}<br>
* {@link NumericShaper.Range#TAI_THAM_THAM}</td>
* <td>{@link NumericShaper.Range#TAI_THAM_THAM}</td>
* </tr>
* </table>
*
* @since 1.4 * @since 1.4
*/ */
......
...@@ -1662,6 +1662,81 @@ public class SimpleDateFormat extends DateFormat { ...@@ -1662,6 +1662,81 @@ public class SimpleDateFormat extends DateFormat {
return 0; return 0;
} }
/**
* Parses numeric forms of time zone offset, such as "hh:mm", and
* sets calb to the parsed value.
*
* @param text the text to be parsed
* @param start the character position to start parsing
* @param sign 1: positive; -1: negative
* @param count 0: 'Z' or "GMT+hh:mm" parsing; 1 - 3: the number of 'X's
* @param colon true - colon required between hh and mm; false - no colon required
* @param calb a CalendarBuilder in which the parsed value is stored
* @return updated parsed position, or its negative value to indicate a parsing error
*/
private int subParseNumericZone(String text, int start, int sign, int count,
boolean colon, CalendarBuilder calb) {
int index = start;
parse:
try {
char c = text.charAt(index++);
// Parse hh
int hours;
if (!isDigit(c)) {
break parse;
}
hours = c - '0';
c = text.charAt(index++);
if (isDigit(c)) {
hours = hours * 10 + (c - '0');
} else {
// If no colon in RFC 822 or 'X' (ISO), two digits are
// required.
if (count > 0 || !colon) {
break parse;
}
--index;
}
if (hours > 23) {
break parse;
}
int minutes = 0;
if (count != 1) {
// Proceed with parsing mm
c = text.charAt(index++);
if (colon) {
if (c != ':') {
break parse;
}
c = text.charAt(index++);
}
if (!isDigit(c)) {
break parse;
}
minutes = c - '0';
c = text.charAt(index++);
if (!isDigit(c)) {
break parse;
}
minutes = minutes * 10 + (c - '0');
if (minutes > 59) {
break parse;
}
}
minutes += hours * 60;
calb.set(Calendar.ZONE_OFFSET, minutes * MILLIS_PER_MINUTE * sign)
.set(Calendar.DST_OFFSET, 0);
return index;
} catch (IndexOutOfBoundsException e) {
}
return 1 - index; // -(index - 1)
}
private boolean isDigit(char c) {
return c >= '0' && c <= '9';
}
/** /**
* Private member function that converts the parsed date strings into * Private member function that converts the parsed date strings into
* timeFields. Returns -start (for ParsePosition) if failed. * timeFields. Returns -start (for ParsePosition) if failed.
...@@ -1907,248 +1982,95 @@ public class SimpleDateFormat extends DateFormat { ...@@ -1907,248 +1982,95 @@ public class SimpleDateFormat extends DateFormat {
case PATTERN_ZONE_NAME: // 'z' case PATTERN_ZONE_NAME: // 'z'
case PATTERN_ZONE_VALUE: // 'Z' case PATTERN_ZONE_VALUE: // 'Z'
// First try to parse generic forms such as GMT-07:00. Do this first
// in case localized TimeZoneNames contains the string "GMT"
// for a zone; in that case, we don't want to match the first three
// characters of GMT+/-hh:mm etc.
{ {
int sign = 0; int sign = 0;
int offset; try {
char c = text.charAt(pos.index);
// For time zones that have no known names, look for strings if (c == '+') {
// of the form: sign = 1;
// GMT[+-]hours:minutes or } else if (c == '-') {
// GMT. sign = -1;
if ((text.length() - start) >= GMT.length() &&
text.regionMatches(true, start, GMT, 0, GMT.length())) {
int num;
calb.set(Calendar.DST_OFFSET, 0);
pos.index = start + GMT.length();
try { // try-catch for "GMT" only time zone string
char c = text.charAt(pos.index);
if (c == '+') {
sign = 1;
} else if (c == '-') {
sign = -1;
}
}
catch(StringIndexOutOfBoundsException e) {}
if (sign == 0) { /* "GMT" without offset */
calb.set(Calendar.ZONE_OFFSET, 0);
return pos.index;
} }
if (sign == 0) {
// Look for hours. // Try parsing a custom time zone "GMT+hh:mm" or "GMT".
try { if ((c == 'G' || c == 'g')
char c = text.charAt(++pos.index); && (text.length() - start) >= GMT.length()
if (c < '0' || c > '9') { /* must be from '0' to '9'. */ && text.regionMatches(true, start, GMT, 0, GMT.length())) {
break parsing; pos.index = start + GMT.length();
}
num = c - '0'; if ((text.length() - pos.index) > 0) {
c = text.charAt(pos.index);
if (text.charAt(++pos.index) != ':') { if (c == '+') {
c = text.charAt(pos.index); sign = 1;
if (c < '0' || c > '9') { /* must be from '0' to '9'. */ } else if (c == '-') {
break parsing; sign = -1;
}
} }
num *= 10;
num += c - '0';
pos.index++;
}
if (num > 23) {
--pos.index;
break parsing;
}
if (text.charAt(pos.index) != ':') {
break parsing;
}
// Look for minutes. if (sign == 0) { /* "GMT" without offset */
offset = num * 60; calb.set(Calendar.ZONE_OFFSET, 0)
c = text.charAt(++pos.index); .set(Calendar.DST_OFFSET, 0);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */ return pos.index;
break parsing; }
}
num = c - '0';
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
num *= 10;
num += c - '0';
if (num > 59) { // Parse the rest as "hh:mm"
break parsing; int i = subParseNumericZone(text, ++pos.index,
} sign, 0, true, calb);
} catch (StringIndexOutOfBoundsException e) { if (i > 0) {
break parsing; return i;
} }
offset += num; pos.index = -i;
// Fall through for final processing below of 'offset' and 'sign'.
} else {
// If the first character is a sign, look for numeric timezones of
// the form [+-]hhmm as specified by RFC 822. Otherwise, check
// for named time zones by looking through the locale data from
// the TimeZoneNames strings.
try {
char c = text.charAt(pos.index);
if (c == '+') {
sign = 1;
} else if (c == '-') {
sign = -1;
} else { } else {
// Try parsing the text as a time zone name (abbr). // Try parsing the text as a time zone
// name or abbreviation.
int i = subParseZoneString(text, pos.index, calb); int i = subParseZoneString(text, pos.index, calb);
if (i != 0) { if (i > 0) {
return i; return i;
} }
break parsing; pos.index = -i;
}
// Parse the text as an RFC 822 time zone string. This code is
// actually a little more permissive than RFC 822. It will
// try to do its best with numbers that aren't strictly 4
// digits long.
// Look for hh.
int hours = 0;
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
} }
hours = c - '0'; } else {
c = text.charAt(++pos.index); // Parse the rest as "hhmm" (RFC 822)
if (c < '0' || c > '9') { /* must be from '0' to '9'. */ int i = subParseNumericZone(text, ++pos.index,
break parsing; sign, 0, false, calb);
} if (i > 0) {
hours *= 10; return i;
hours += c - '0';
if (hours > 23) {
break parsing;
}
// Look for mm.
int minutes = 0;
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
minutes = c - '0';
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
minutes *= 10;
minutes += c - '0';
if (minutes > 59) {
break parsing;
} }
pos.index = -i;
offset = hours * 60 + minutes;
} catch (StringIndexOutOfBoundsException e) {
break parsing;
} }
} } catch (IndexOutOfBoundsException e) {
// Do the final processing for both of the above cases. We only
// arrive here if the form GMT+/-... or an RFC 822 form was seen.
if (sign != 0) {
offset *= MILLIS_PER_MINUTE * sign;
calb.set(Calendar.ZONE_OFFSET, offset).set(Calendar.DST_OFFSET, 0);
return ++pos.index;
} }
} }
break parsing; break parsing;
case PATTERN_ISO_ZONE: // 'X' case PATTERN_ISO_ZONE: // 'X'
{ {
int sign = 0; if ((text.length() - pos.index) <= 0) {
int offset = 0; break parsing;
iso8601: {
try {
char c = text.charAt(pos.index);
if (c == 'Z') {
calb.set(Calendar.ZONE_OFFSET, 0).set(Calendar.DST_OFFSET, 0);
return ++pos.index;
}
// parse text as "+/-hh[[:]mm]" based on count
if (c == '+') {
sign = 1;
} else if (c == '-') {
sign = -1;
}
// Look for hh.
int hours = 0;
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
hours = c - '0';
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
hours *= 10;
hours += c - '0';
if (hours > 23) {
break parsing;
}
if (count == 1) { // "X"
offset = hours * 60;
break iso8601;
}
c = text.charAt(++pos.index);
// Skip ':' if "XXX"
if (c == ':') {
if (count == 2) {
break parsing;
}
c = text.charAt(++pos.index);
} else {
if (count == 3) {
// missing ':'
break parsing;
}
}
// Look for mm.
int minutes = 0;
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
minutes = c - '0';
c = text.charAt(++pos.index);
if (c < '0' || c > '9') { /* must be from '0' to '9'. */
break parsing;
}
minutes *= 10;
minutes += c - '0';
if (minutes > 59) {
break parsing;
}
offset = hours * 60 + minutes;
} catch (StringIndexOutOfBoundsException e) {
break parsing;
}
} }
// Do the final processing for both of the above cases. We only int sign = 0;
// arrive here if the form GMT+/-... or an RFC 822 form was seen. char c = text.charAt(pos.index);
if (sign != 0) { if (c == 'Z') {
offset *= MILLIS_PER_MINUTE * sign; calb.set(Calendar.ZONE_OFFSET, 0).set(Calendar.DST_OFFSET, 0);
calb.set(Calendar.ZONE_OFFSET, offset).set(Calendar.DST_OFFSET, 0);
return ++pos.index; return ++pos.index;
} }
// parse text as "+/-hh[[:]mm]" based on count
if (c == '+') {
sign = 1;
} else if (c == '-') {
sign = -1;
} else {
++pos.index;
break parsing;
}
int i = subParseNumericZone(text, ++pos.index, sign, count,
count == 3, calb);
if (i > 0) {
return i;
}
pos.index = -i;
} }
break parsing; break parsing;
......
...@@ -1449,10 +1449,15 @@ public final class Locale implements Cloneable, Serializable { ...@@ -1449,10 +1449,15 @@ public final class Locale implements Cloneable, Serializable {
* three-letter language abbreviation is not available for this locale. * three-letter language abbreviation is not available for this locale.
*/ */
public String getISO3Language() throws MissingResourceException { public String getISO3Language() throws MissingResourceException {
String language3 = getISO3Code(_baseLocale.getLanguage(), LocaleISOData.isoLanguageTable); String lang = _baseLocale.getLanguage();
if (lang.length() == 3) {
return lang;
}
String language3 = getISO3Code(lang, LocaleISOData.isoLanguageTable);
if (language3 == null) { if (language3 == null) {
throw new MissingResourceException("Couldn't find 3-letter language code for " throw new MissingResourceException("Couldn't find 3-letter language code for "
+ _baseLocale.getLanguage(), "FormatData_" + toString(), "ShortLanguage"); + lang, "FormatData_" + toString(), "ShortLanguage");
} }
return language3; return language3;
} }
......
...@@ -310,7 +310,7 @@ public class MidiSystem { ...@@ -310,7 +310,7 @@ public class MidiSystem {
} else { } else {
transmitter = device.getTransmitter(); transmitter = device.getTransmitter();
} }
if (!(transmitter instanceof MidiDeviceReceiver)) { if (!(transmitter instanceof MidiDeviceTransmitter)) {
transmitter = new MidiDeviceTransmitterEnvelope(device, transmitter); transmitter = new MidiDeviceTransmitterEnvelope(device, transmitter);
} }
return transmitter; return transmitter;
......
...@@ -40,7 +40,8 @@ import java.beans.*; ...@@ -40,7 +40,8 @@ import java.beans.*;
/** /**
* A component that lets the user graphically select a value by sliding * A component that lets the user graphically select a value by sliding
* a knob within a bounded interval. * a knob within a bounded interval. The knob is always positioned
* at the points that match integer values within the specified interval.
* <p> * <p>
* The slider can show both * The slider can show both
* major tick marks, and minor tick marks between the major ones. The number of * major tick marks, and minor tick marks between the major ones. The number of
......
...@@ -908,6 +908,14 @@ public class BasicSpinnerUI extends SpinnerUI ...@@ -908,6 +908,14 @@ public class BasicSpinnerUI extends SpinnerUI
int height = parent.getHeight(); int height = parent.getHeight();
Insets insets = parent.getInsets(); Insets insets = parent.getInsets();
if (nextButton == null && previousButton == null) {
setBounds(editor, insets.left, insets.top, width - insets.left - insets.right,
height - insets.top - insets.bottom);
return;
}
Dimension nextD = preferredSize(nextButton); Dimension nextD = preferredSize(nextButton);
Dimension previousD = preferredSize(previousButton); Dimension previousD = preferredSize(previousButton);
int buttonsWidth = Math.max(nextD.width, previousD.width); int buttonsWidth = Math.max(nextD.width, previousD.width);
......
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,10 +37,10 @@ import java.nio.charset.Charset; ...@@ -37,10 +37,10 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
...@@ -329,6 +329,8 @@ public abstract class FontConfiguration { ...@@ -329,6 +329,8 @@ public abstract class FontConfiguration {
* tables. * tables.
*/ */
public static void saveBinary(OutputStream out) throws IOException { public static void saveBinary(OutputStream out) throws IOException {
sanityCheck();
DataOutputStream dataOut = new DataOutputStream(out); DataOutputStream dataOut = new DataOutputStream(out);
writeShortTable(dataOut, head); writeShortTable(dataOut, head);
writeShortTable(dataOut, table_scriptIDs); writeShortTable(dataOut, table_scriptIDs);
...@@ -350,7 +352,6 @@ public abstract class FontConfiguration { ...@@ -350,7 +352,6 @@ public abstract class FontConfiguration {
if (verbose) { if (verbose) {
dump(); dump();
} }
sanityCheck();
} }
//private static boolean loadingProperties; //private static boolean loadingProperties;
...@@ -1343,6 +1344,11 @@ public abstract class FontConfiguration { ...@@ -1343,6 +1344,11 @@ public abstract class FontConfiguration {
private static short[] table_stringIDs; private static short[] table_stringIDs;
private static char[] table_stringTable; private static char[] table_stringTable;
/**
* Checks consistencies of complied fontconfig data. This method
* is called only at the build-time from
* build.tools.compilefontconfig.CompileFontConfig.
*/
private static void sanityCheck() { private static void sanityCheck() {
int errors = 0; int errors = 0;
...@@ -1358,12 +1364,20 @@ public abstract class FontConfiguration { ...@@ -1358,12 +1364,20 @@ public abstract class FontConfiguration {
//componentFontNameID starts from "1" //componentFontNameID starts from "1"
for (int ii = 1; ii < table_filenames.length; ii++) { for (int ii = 1; ii < table_filenames.length; ii++) {
if (table_filenames[ii] == -1) { if (table_filenames[ii] == -1) {
System.out.println("\n Warning: " // The corresponding finename entry for a component
+ "<filename." // font name is mandatory on Windows, but it's
+ getString(table_componentFontNameIDs[ii]) // optional on Solaris and Linux.
+ "> entry is missing!!!"); if (osName.contains("Windows")) {
if (!osName.contains("Linux")) { System.err.println("\n Error: <filename."
+ getString(table_componentFontNameIDs[ii])
+ "> entry is missing!!!");
errors++; errors++;
} else {
if (verbose && !isEmpty(table_filenames)) {
System.err.println("\n Note: 'filename' entry is undefined for \""
+ getString(table_componentFontNameIDs[ii])
+ "\"");
}
} }
} }
} }
...@@ -1382,7 +1396,7 @@ public abstract class FontConfiguration { ...@@ -1382,7 +1396,7 @@ public abstract class FontConfiguration {
int jj = iii * NUM_STYLES + iij; int jj = iii * NUM_STYLES + iij;
short ffid = table_scriptFonts[fid + jj]; short ffid = table_scriptFonts[fid + jj];
if (ffid == 0) { if (ffid == 0) {
System.out.println("\n Error: <" System.err.println("\n Error: <"
+ getFontName(iii) + "." + getFontName(iii) + "."
+ getStyleName(iij) + "." + getStyleName(iij) + "."
+ getString(table_scriptIDs[ii]) + getString(table_scriptIDs[ii])
...@@ -1402,7 +1416,7 @@ public abstract class FontConfiguration { ...@@ -1402,7 +1416,7 @@ public abstract class FontConfiguration {
script.contains("symbol")) { script.contains("symbol")) {
continue; continue;
} }
System.out.println("\nError: " System.err.println("\nError: "
+ "<awtfontpath." + "<awtfontpath."
+ script + script
+ "> entry is missing!!!"); + "> entry is missing!!!");
...@@ -1411,11 +1425,19 @@ public abstract class FontConfiguration { ...@@ -1411,11 +1425,19 @@ public abstract class FontConfiguration {
} }
} }
if (errors != 0) { if (errors != 0) {
System.out.println("!!THERE ARE " + errors + " ERROR(S) IN " System.err.println("!!THERE ARE " + errors + " ERROR(S) IN "
+ "THE FONTCONFIG FILE, PLEASE CHECK ITS CONTENT!!\n"); + "THE FONTCONFIG FILE, PLEASE CHECK ITS CONTENT!!\n");
System.exit(1); System.exit(1);
}
}
private static boolean isEmpty(short[] a) {
for (short s : a) {
if (s != -1) {
return false;
}
} }
return true;
} }
//dump the fontconfig data tables //dump the fontconfig data tables
...@@ -1652,20 +1674,16 @@ public abstract class FontConfiguration { ...@@ -1652,20 +1674,16 @@ public abstract class FontConfiguration {
private static void writeShortTable(DataOutputStream out, short[] data) private static void writeShortTable(DataOutputStream out, short[] data)
throws IOException { throws IOException {
for (int i = 0; i < data.length; i++) { for (short val : data) {
out.writeShort(data[i]); out.writeShort(val);
} }
} }
private static short[] toList(HashMap map) { private static short[] toList(HashMap<String, Short> map) {
short[] list = new short[map.size()]; short[] list = new short[map.size()];
for (int i = 0; i < list.length; i++) { Arrays.fill(list, (short) -1);
list[i] = -1; for (Entry<String, Short> entry : map.entrySet()) {
} list[entry.getValue()] = getStringID(entry.getKey());
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, Short> entry = (Entry <String, Short>)iterator.next();
list[entry.getValue().shortValue()] = getStringID(entry.getKey());
} }
return list; return list;
} }
...@@ -1763,25 +1781,19 @@ public abstract class FontConfiguration { ...@@ -1763,25 +1781,19 @@ public abstract class FontConfiguration {
int len = table_scriptIDs.length + scriptFonts.size() * 20; int len = table_scriptIDs.length + scriptFonts.size() * 20;
table_scriptFonts = new short[len]; table_scriptFonts = new short[len];
Iterator iterator = scriptAllfonts.entrySet().iterator(); for (Entry<Short, Short> entry : scriptAllfonts.entrySet()) {
while (iterator.hasNext()) { table_scriptFonts[entry.getKey().intValue()] = entry.getValue();
Entry<Short, Short> entry = (Entry <Short, Short>)iterator.next();
table_scriptFonts[entry.getKey().intValue()] = (short)entry.getValue().shortValue();
} }
int off = table_scriptIDs.length; int off = table_scriptIDs.length;
iterator = scriptFonts.entrySet().iterator(); for (Entry<Short, Short[]> entry : scriptFonts.entrySet()) {
while (iterator.hasNext()) {
Entry<Short, Short[]> entry = (Entry <Short, Short[]>)iterator.next();
table_scriptFonts[entry.getKey().intValue()] = (short)-off; table_scriptFonts[entry.getKey().intValue()] = (short)-off;
Short[] v = entry.getValue(); Short[] v = entry.getValue();
int i = 0; for (int i = 0; i < 20; i++) {
while (i < 20) {
if (v[i] != null) { if (v[i] != null) {
table_scriptFonts[off++] = v[i].shortValue(); table_scriptFonts[off++] = v[i];
} else { } else {
table_scriptFonts[off++] = 0; table_scriptFonts[off++] = 0;
} }
i++;
} }
} }
...@@ -1792,9 +1804,7 @@ public abstract class FontConfiguration { ...@@ -1792,9 +1804,7 @@ public abstract class FontConfiguration {
//(3) sequences elcID -> XXXX[1|5] -> scriptID[] //(3) sequences elcID -> XXXX[1|5] -> scriptID[]
head[INDEX_sequences] = (short)(head[INDEX_elcIDs] + table_elcIDs.length); head[INDEX_sequences] = (short)(head[INDEX_elcIDs] + table_elcIDs.length);
table_sequences = new short[elcIDs.size() * NUM_FONTS]; table_sequences = new short[elcIDs.size() * NUM_FONTS];
iterator = sequences.entrySet().iterator(); for (Entry<Short, short[]> entry : sequences.entrySet()) {
while (iterator.hasNext()) {
Entry<Short, short[]> entry = (Entry <Short, short[]>)iterator.next();
//table_sequences[entry.getKey().intValue()] = (short)-off; //table_sequences[entry.getKey().intValue()] = (short)-off;
int k = entry.getKey().intValue(); int k = entry.getKey().intValue();
short[] v = entry.getValue(); short[] v = entry.getValue();
...@@ -1827,31 +1837,24 @@ public abstract class FontConfiguration { ...@@ -1827,31 +1837,24 @@ public abstract class FontConfiguration {
//(6)componentFontNameID -> filenameID //(6)componentFontNameID -> filenameID
head[INDEX_filenames] = (short)(head[INDEX_componentFontNameIDs] + table_componentFontNameIDs.length); head[INDEX_filenames] = (short)(head[INDEX_componentFontNameIDs] + table_componentFontNameIDs.length);
table_filenames = new short[table_componentFontNameIDs.length]; table_filenames = new short[table_componentFontNameIDs.length];
for (int i = 0; i < table_filenames.length; i++) { Arrays.fill(table_filenames, (short) -1);
table_filenames[i] = -1;
} for (Entry<Short, Short> entry : filenames.entrySet()) {
iterator = filenames.entrySet().iterator(); table_filenames[entry.getKey()] = entry.getValue();
while (iterator.hasNext()) {
Entry<Short, Short> entry = (Entry <Short, Short>)iterator.next();
table_filenames[entry.getKey().shortValue()] = entry.getValue().shortValue();
} }
//(7)scriptID-> awtfontpath //(7)scriptID-> awtfontpath
//the paths are stored as scriptID -> stringID in awtfontpahts //the paths are stored as scriptID -> stringID in awtfontpahts
head[INDEX_awtfontpaths] = (short)(head[INDEX_filenames] + table_filenames.length); head[INDEX_awtfontpaths] = (short)(head[INDEX_filenames] + table_filenames.length);
table_awtfontpaths = new short[table_scriptIDs.length]; table_awtfontpaths = new short[table_scriptIDs.length];
iterator = awtfontpaths.entrySet().iterator(); for (Entry<Short, Short> entry : awtfontpaths.entrySet()) {
while (iterator.hasNext()) { table_awtfontpaths[entry.getKey()] = entry.getValue();
Entry<Short, Short> entry = (Entry <Short, Short>)iterator.next();
table_awtfontpaths[entry.getKey().shortValue()] = entry.getValue().shortValue();
} }
//(8)exclusions //(8)exclusions
head[INDEX_exclusions] = (short)(head[INDEX_awtfontpaths] + table_awtfontpaths.length); head[INDEX_exclusions] = (short)(head[INDEX_awtfontpaths] + table_awtfontpaths.length);
table_exclusions = new short[scriptIDs.size()]; table_exclusions = new short[scriptIDs.size()];
iterator = exclusions.entrySet().iterator(); for (Entry<Short, int[]> entry : exclusions.entrySet()) {
while (iterator.hasNext()) {
Entry<Short, int[]> entry = (Entry <Short, int[]>)iterator.next();
int[] exI = entry.getValue(); int[] exI = entry.getValue();
char[] exC = new char[exI.length * 2]; char[] exC = new char[exI.length * 2];
int j = 0; int j = 0;
...@@ -1859,17 +1862,15 @@ public abstract class FontConfiguration { ...@@ -1859,17 +1862,15 @@ public abstract class FontConfiguration {
exC[j++] = (char) (exI[i] >> 16); exC[j++] = (char) (exI[i] >> 16);
exC[j++] = (char) (exI[i] & 0xffff); exC[j++] = (char) (exI[i] & 0xffff);
} }
table_exclusions[entry.getKey().shortValue()] = getStringID(new String (exC)); table_exclusions[entry.getKey()] = getStringID(new String (exC));
} }
//(9)proportionals //(9)proportionals
head[INDEX_proportionals] = (short)(head[INDEX_exclusions] + table_exclusions.length); head[INDEX_proportionals] = (short)(head[INDEX_exclusions] + table_exclusions.length);
table_proportionals = new short[proportionals.size() * 2]; table_proportionals = new short[proportionals.size() * 2];
iterator = proportionals.entrySet().iterator();
int j = 0; int j = 0;
while (iterator.hasNext()) { for (Entry<Short, Short> entry : proportionals.entrySet()) {
Entry<Short, Short> entry = (Entry <Short, Short>)iterator.next(); table_proportionals[j++] = entry.getKey();
table_proportionals[j++] = entry.getKey().shortValue(); table_proportionals[j++] = entry.getValue();
table_proportionals[j++] = entry.getValue().shortValue();
} }
//(10) see (1) for info, the only difference is "xxx.motif" //(10) see (1) for info, the only difference is "xxx.motif"
...@@ -1878,22 +1879,18 @@ public abstract class FontConfiguration { ...@@ -1878,22 +1879,18 @@ public abstract class FontConfiguration {
len = table_scriptIDs.length + scriptFontsMotif.size() * 20; len = table_scriptIDs.length + scriptFontsMotif.size() * 20;
table_scriptFontsMotif = new short[len]; table_scriptFontsMotif = new short[len];
iterator = scriptAllfontsMotif.entrySet().iterator(); for (Entry<Short, Short> entry : scriptAllfontsMotif.entrySet()) {
while (iterator.hasNext()) {
Entry<Short, Short> entry = (Entry <Short, Short>)iterator.next();
table_scriptFontsMotif[entry.getKey().intValue()] = table_scriptFontsMotif[entry.getKey().intValue()] =
(short)entry.getValue().shortValue(); (short)entry.getValue();
} }
off = table_scriptIDs.length; off = table_scriptIDs.length;
iterator = scriptFontsMotif.entrySet().iterator(); for (Entry<Short, Short[]> entry : scriptFontsMotif.entrySet()) {
while (iterator.hasNext()) {
Entry<Short, Short[]> entry = (Entry <Short, Short[]>)iterator.next();
table_scriptFontsMotif[entry.getKey().intValue()] = (short)-off; table_scriptFontsMotif[entry.getKey().intValue()] = (short)-off;
Short[] v = entry.getValue(); Short[] v = entry.getValue();
int i = 0; int i = 0;
while (i < 20) { while (i < 20) {
if (v[i] != null) { if (v[i] != null) {
table_scriptFontsMotif[off++] = v[i].shortValue(); table_scriptFontsMotif[off++] = v[i];
} else { } else {
table_scriptFontsMotif[off++] = 0; table_scriptFontsMotif[off++] = 0;
} }
...@@ -1907,12 +1904,10 @@ public abstract class FontConfiguration { ...@@ -1907,12 +1904,10 @@ public abstract class FontConfiguration {
//(11)short[] alphabeticSuffix //(11)short[] alphabeticSuffix
head[INDEX_alphabeticSuffix] = (short)(head[INDEX_scriptFontsMotif] + table_scriptFontsMotif.length); head[INDEX_alphabeticSuffix] = (short)(head[INDEX_scriptFontsMotif] + table_scriptFontsMotif.length);
table_alphabeticSuffix = new short[alphabeticSuffix.size() * 2]; table_alphabeticSuffix = new short[alphabeticSuffix.size() * 2];
iterator = alphabeticSuffix.entrySet().iterator();
j = 0; j = 0;
while (iterator.hasNext()) { for (Entry<Short, Short> entry : alphabeticSuffix.entrySet()) {
Entry<Short, Short> entry = (Entry <Short, Short>)iterator.next(); table_alphabeticSuffix[j++] = entry.getKey();
table_alphabeticSuffix[j++] = entry.getKey().shortValue(); table_alphabeticSuffix[j++] = entry.getValue();
table_alphabeticSuffix[j++] = entry.getValue().shortValue();
} }
//(15)short[] fallbackScriptIDs; just put the ID in head //(15)short[] fallbackScriptIDs; just put the ID in head
......
...@@ -137,41 +137,43 @@ void getALSAVersion(char* buffer, int len) { ...@@ -137,41 +137,43 @@ void getALSAVersion(char* buffer, int len) {
file = fopen(ALSA_VERSION_PROC_FILE, "r"); file = fopen(ALSA_VERSION_PROC_FILE, "r");
ALSAVersionString[0] = 0; ALSAVersionString[0] = 0;
if (file) { if (file) {
fgets(ALSAVersionString, ALSAVersionString_LENGTH, file); if (NULL != fgets(ALSAVersionString, ALSAVersionString_LENGTH, file)) {
// parse for version number // parse for version number
totalLen = strlen(ALSAVersionString); totalLen = strlen(ALSAVersionString);
inVersionString = FALSE; inVersionString = FALSE;
len = 0; len = 0;
curr = 0; curr = 0;
while (curr < totalLen) { while (curr < totalLen) {
if (!inVersionString) { if (!inVersionString) {
// is this char the beginning of a version string ? // is this char the beginning of a version string ?
if (ALSAVersionString[curr] >= '0' if (ALSAVersionString[curr] >= '0'
&& ALSAVersionString[curr] <= '9') { && ALSAVersionString[curr] <= '9') {
inVersionString = TRUE; inVersionString = TRUE;
}
} }
} if (inVersionString) {
if (inVersionString) { // the version string ends with white space
// the version string ends with white space if (ALSAVersionString[curr] <= 32) {
if (ALSAVersionString[curr] <= 32) { break;
break; }
} if (curr != len) {
if (curr != len) { // copy this char to the beginning of the string
// copy this char to the beginning of the string ALSAVersionString[len] = ALSAVersionString[curr];
ALSAVersionString[len] = ALSAVersionString[curr]; }
len++;
} }
len++; curr++;
} }
curr++; // remove trailing dots
} while ((len > 0) && (ALSAVersionString[len - 1] == '.')) {
// remove trailing dots len--;
while ((len > 0) && (ALSAVersionString[len - 1] == '.')) { }
len--; // null terminate
ALSAVersionString[len] = 0;
} }
// null terminate fclose(file);
ALSAVersionString[len] = 0; hasGottenALSAVersion = TRUE;
} }
hasGottenALSAVersion = TRUE;
} }
strncpy(buffer, ALSAVersionString, len); strncpy(buffer, ALSAVersionString, len);
} }
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include "PlatformMidi.h" #include "PlatformMidi.h"
#include "PLATFORM_API_LinuxOS_ALSA_MidiUtils.h" #include "PLATFORM_API_LinuxOS_ALSA_MidiUtils.h"
#if defined(i586)
#include <sys/utsname.h>
#endif
/* /*
* Helper methods * Helper methods
...@@ -73,9 +76,38 @@ char* MIDI_IN_GetErrorStr(INT32 err) { ...@@ -73,9 +76,38 @@ char* MIDI_IN_GetErrorStr(INT32 err) {
return (char*) getErrorStr(err); return (char*) getErrorStr(err);
} }
INT32 MIDI_IN_GetNumDevices() { INT32 MIDI_IN_GetNumDevices() {
/* Workaround for 6842956: 32bit app on 64bit linux
* gets assertion failure trying to open midiIn ports.
* Untill the issue is fixed in ALSA
* (https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4807)
* report no midi in devices in the configuration.
*/
#if defined(i586)
static int jre32onlinux64 = -1;
if (jre32onlinux64 < 0) {
jre32onlinux64 = 0;
/* The workaround may be disabled setting "JAVASOUND_ENABLE_MIDIIN"
* environment variable.
*/
if (getenv("JAVASOUND_ENABLE_MIDIIN") == NULL) {
struct utsname u;
jre32onlinux64 = 0;
if (uname(&u) == 0) {
if (strstr(u.machine, "64") != NULL) {
TRACE0("jre32 on linux64 detected - report no midiIn devices\n");
jre32onlinux64 = 1;
}
}
}
}
if (jre32onlinux64) {
return 0;
}
#endif
TRACE0("MIDI_IN_GetNumDevices()\n"); TRACE0("MIDI_IN_GetNumDevices()\n");
return getMidiDeviceCount(SND_RAWMIDI_STREAM_INPUT); return getMidiDeviceCount(SND_RAWMIDI_STREAM_INPUT);
} }
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -372,7 +372,7 @@ INT32 openMidiDevice(snd_rawmidi_stream_t direction, INT32 deviceIndex, ...@@ -372,7 +372,7 @@ INT32 openMidiDevice(snd_rawmidi_stream_t direction, INT32 deviceIndex,
snd_rawmidi_t* native_handle; snd_rawmidi_t* native_handle;
snd_midi_event_t* event_parser = NULL; snd_midi_event_t* event_parser = NULL;
int err; int err;
UINT32 deviceID; UINT32 deviceID = 0;
char devicename[100]; char devicename[100];
#ifdef ALSA_MIDI_USE_PLUGHW #ifdef ALSA_MIDI_USE_PLUGHW
int usePlugHw = 1; int usePlugHw = 1;
......
/* /*
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -127,7 +127,7 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre ...@@ -127,7 +127,7 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
int ret; int ret;
int sampleSizeInBytes, significantBits, isSigned, isBigEndian, enc; int sampleSizeInBytes, significantBits, isSigned, isBigEndian, enc;
int origSampleSizeInBytes, origSignificantBits; int origSampleSizeInBytes, origSignificantBits;
int channels, minChannels, maxChannels; unsigned int channels, minChannels, maxChannels;
int rate, bitIndex; int rate, bitIndex;
for (bitIndex = 0; bitIndex <= MAX_BIT_INDEX; bitIndex++) handledBits[bitIndex] = FALSE; for (bitIndex = 0; bitIndex <= MAX_BIT_INDEX; bitIndex++) handledBits[bitIndex] = FALSE;
...@@ -152,7 +152,6 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre ...@@ -152,7 +152,6 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
} }
} }
snd_pcm_hw_params_get_format_mask(hwParams, formatMask); snd_pcm_hw_params_get_format_mask(hwParams, formatMask);
#ifdef ALSA_PCM_NEW_HW_PARAMS_API
if (ret == 0) { if (ret == 0) {
ret = snd_pcm_hw_params_get_channels_min(hwParams, &minChannels); ret = snd_pcm_hw_params_get_channels_min(hwParams, &minChannels);
if (ret != 0) { if (ret != 0) {
...@@ -165,13 +164,6 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre ...@@ -165,13 +164,6 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
ERROR1("snd_pcm_hw_params_get_channels_max returned error %d\n", ret); ERROR1("snd_pcm_hw_params_get_channels_max returned error %d\n", ret);
} }
} }
#else
minChannels = snd_pcm_hw_params_get_channels_min(hwParams);
maxChannels = snd_pcm_hw_params_get_channels_max(hwParams);
if (minChannels > maxChannels) {
ERROR2("MinChannels=%d, maxChannels=%d\n", minChannels, maxChannels);
}
#endif
// since we queried the hw: device, for many soundcards, it will only // since we queried the hw: device, for many soundcards, it will only
// report the maximum number of channels (which is the only way to talk // report the maximum number of channels (which is the only way to talk
...@@ -222,7 +214,7 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre ...@@ -222,7 +214,7 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
} else { } else {
for (channels = minChannels; channels <= maxChannels; channels++) { for (channels = minChannels; channels <= maxChannels; channels++) {
DAUDIO_AddAudioFormat(creator, significantBits, DAUDIO_AddAudioFormat(creator, significantBits,
(channels < 0)?-1:(sampleSizeInBytes * channels), sampleSizeInBytes * channels,
channels, rate, channels, rate,
enc, isSigned, isBigEndian); enc, isSigned, isBigEndian);
} }
...@@ -254,7 +246,7 @@ typedef struct tag_AlsaPcmInfo { ...@@ -254,7 +246,7 @@ typedef struct tag_AlsaPcmInfo {
snd_pcm_sw_params_t* swParams; snd_pcm_sw_params_t* swParams;
int bufferSizeInBytes; int bufferSizeInBytes;
int frameSize; // storage size in Bytes int frameSize; // storage size in Bytes
int periods; unsigned int periods;
snd_pcm_uframes_t periodSize; snd_pcm_uframes_t periodSize;
#ifdef GET_POSITION_METHOD2 #ifdef GET_POSITION_METHOD2
// to be used exclusively by getBytePosition! // to be used exclusively by getBytePosition!
...@@ -305,8 +297,8 @@ int setHWParams(AlsaPcmInfo* info, ...@@ -305,8 +297,8 @@ int setHWParams(AlsaPcmInfo* info,
int channels, int channels,
int bufferSizeInFrames, int bufferSizeInFrames,
snd_pcm_format_t format) { snd_pcm_format_t format) {
unsigned int rrate; unsigned int rrate, periodTime, periods;
int ret, dir, periods, periodTime; int ret, dir;
snd_pcm_uframes_t alsaBufferSizeInFrames = (snd_pcm_uframes_t) bufferSizeInFrames; snd_pcm_uframes_t alsaBufferSizeInFrames = (snd_pcm_uframes_t) bufferSizeInFrames;
/* choose all parameters */ /* choose all parameters */
...@@ -335,12 +327,8 @@ int setHWParams(AlsaPcmInfo* info, ...@@ -335,12 +327,8 @@ int setHWParams(AlsaPcmInfo* info,
} }
/* set the stream rate */ /* set the stream rate */
rrate = (int) (sampleRate + 0.5f); rrate = (int) (sampleRate + 0.5f);
#ifdef ALSA_PCM_NEW_HW_PARAMS_API
dir = 0; dir = 0;
ret = snd_pcm_hw_params_set_rate_near(info->handle, info->hwParams, &rrate, &dir); ret = snd_pcm_hw_params_set_rate_near(info->handle, info->hwParams, &rrate, &dir);
#else
ret = snd_pcm_hw_params_set_rate_near(info->handle, info->hwParams, rrate, 0);
#endif
if (ret < 0) { if (ret < 0) {
ERROR2("Rate %dHz not available for playback: %s\n", (int) (sampleRate+0.5f), snd_strerror(ret)); ERROR2("Rate %dHz not available for playback: %s\n", (int) (sampleRate+0.5f), snd_strerror(ret));
return FALSE; return FALSE;
...@@ -350,12 +338,7 @@ int setHWParams(AlsaPcmInfo* info, ...@@ -350,12 +338,7 @@ int setHWParams(AlsaPcmInfo* info,
return FALSE; return FALSE;
} }
/* set the buffer time */ /* set the buffer time */
#ifdef ALSA_PCM_NEW_HW_PARAMS_API
ret = snd_pcm_hw_params_set_buffer_size_near(info->handle, info->hwParams, &alsaBufferSizeInFrames); ret = snd_pcm_hw_params_set_buffer_size_near(info->handle, info->hwParams, &alsaBufferSizeInFrames);
#else
ret = snd_pcm_hw_params_set_buffer_size_near(info->handle, info->hwParams, alsaBufferSizeInFrames);
#endif
if (ret < 0) { if (ret < 0) {
ERROR2("Unable to set buffer size to %d frames: %s\n", ERROR2("Unable to set buffer size to %d frames: %s\n",
(int) alsaBufferSizeInFrames, snd_strerror(ret)); (int) alsaBufferSizeInFrames, snd_strerror(ret));
...@@ -366,12 +349,7 @@ int setHWParams(AlsaPcmInfo* info, ...@@ -366,12 +349,7 @@ int setHWParams(AlsaPcmInfo* info,
if (bufferSizeInFrames > 1024) { if (bufferSizeInFrames > 1024) {
dir = 0; dir = 0;
periodTime = DEFAULT_PERIOD_TIME; periodTime = DEFAULT_PERIOD_TIME;
#ifdef ALSA_PCM_NEW_HW_PARAMS_API
ret = snd_pcm_hw_params_set_period_time_near(info->handle, info->hwParams, &periodTime, &dir); ret = snd_pcm_hw_params_set_period_time_near(info->handle, info->hwParams, &periodTime, &dir);
#else
periodTime = snd_pcm_hw_params_set_period_time_near(info->handle, info->hwParams, periodTime, &dir);
ret = periodTime;
#endif
if (ret < 0) { if (ret < 0) {
ERROR2("Unable to set period time to %d: %s\n", DEFAULT_PERIOD_TIME, snd_strerror(ret)); ERROR2("Unable to set period time to %d: %s\n", DEFAULT_PERIOD_TIME, snd_strerror(ret));
return FALSE; return FALSE;
...@@ -380,12 +358,7 @@ int setHWParams(AlsaPcmInfo* info, ...@@ -380,12 +358,7 @@ int setHWParams(AlsaPcmInfo* info,
/* set the period count for very small buffer sizes to 2 */ /* set the period count for very small buffer sizes to 2 */
dir = 0; dir = 0;
periods = 2; periods = 2;
#ifdef ALSA_PCM_NEW_HW_PARAMS_API
ret = snd_pcm_hw_params_set_periods_near(info->handle, info->hwParams, &periods, &dir); ret = snd_pcm_hw_params_set_periods_near(info->handle, info->hwParams, &periods, &dir);
#else
periods = snd_pcm_hw_params_set_periods_near(info->handle, info->hwParams, periods, &dir);
ret = periods;
#endif
if (ret < 0) { if (ret < 0) {
ERROR2("Unable to set period count to %d: %s\n", /*periods*/ 2, snd_strerror(ret)); ERROR2("Unable to set period count to %d: %s\n", /*periods*/ 2, snd_strerror(ret));
return FALSE; return FALSE;
...@@ -421,12 +394,6 @@ int setSWParams(AlsaPcmInfo* info) { ...@@ -421,12 +394,6 @@ int setSWParams(AlsaPcmInfo* info) {
ERROR1("Unable to set avail min for playback: %s\n", snd_strerror(ret)); ERROR1("Unable to set avail min for playback: %s\n", snd_strerror(ret));
return FALSE; return FALSE;
} }
/* align all transfers to 1 sample */
ret = snd_pcm_sw_params_set_xfer_align(info->handle, info->swParams, 1);
if (ret < 0) {
ERROR1("Unable to set transfer align: %s\n", snd_strerror(ret));
return FALSE;
}
/* write the parameters to the playback device */ /* write the parameters to the playback device */
ret = snd_pcm_sw_params(info->handle, info->swParams); ret = snd_pcm_sw_params(info->handle, info->swParams);
if (ret < 0) { if (ret < 0) {
...@@ -448,7 +415,6 @@ void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource, ...@@ -448,7 +415,6 @@ void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource,
int ret = 0; int ret = 0;
AlsaPcmInfo* info = NULL; AlsaPcmInfo* info = NULL;
/* snd_pcm_uframes_t is 64 bit on 64-bit systems */ /* snd_pcm_uframes_t is 64 bit on 64-bit systems */
snd_pcm_uframes_t alsaPeriodSize = 0;
snd_pcm_uframes_t alsaBufferSizeInFrames = 0; snd_pcm_uframes_t alsaBufferSizeInFrames = 0;
...@@ -484,21 +450,13 @@ void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource, ...@@ -484,21 +450,13 @@ void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource,
bufferSizeInBytes / frameSize, bufferSizeInBytes / frameSize,
format)) { format)) {
info->frameSize = frameSize; info->frameSize = frameSize;
#ifdef ALSA_PCM_NEW_HW_PARAMS_API ret = snd_pcm_hw_params_get_period_size(info->hwParams, &info->periodSize, &dir);
ret = snd_pcm_hw_params_get_period_size(info->hwParams, &alsaPeriodSize, &dir);
info->periodSize = (int) alsaPeriodSize;
if (ret < 0) { if (ret < 0) {
ERROR1("ERROR: snd_pcm_hw_params_get_period: %s\n", snd_strerror(ret)); ERROR1("ERROR: snd_pcm_hw_params_get_period: %s\n", snd_strerror(ret));
} }
snd_pcm_hw_params_get_periods(info->hwParams, &(info->periods), &dir); snd_pcm_hw_params_get_periods(info->hwParams, &(info->periods), &dir);
snd_pcm_hw_params_get_buffer_size(info->hwParams, &alsaBufferSizeInFrames); snd_pcm_hw_params_get_buffer_size(info->hwParams, &alsaBufferSizeInFrames);
info->bufferSizeInBytes = (int) alsaBufferSizeInFrames * frameSize; info->bufferSizeInBytes = (int) alsaBufferSizeInFrames * frameSize;
#else
info->periodSize = snd_pcm_hw_params_get_period_size(info->hwParams, &dir);
info->periods = snd_pcm_hw_params_get_periods(info->hwParams, &dir);
info->bufferSizeInBytes = snd_pcm_hw_params_get_buffer_size(info->hwParams) * frameSize;
ret = 0;
#endif
TRACE3(" DAUDIO_Open: period size = %d frames, periods = %d. Buffer size: %d bytes.\n", TRACE3(" DAUDIO_Open: period size = %d frames, periods = %d. Buffer size: %d bytes.\n",
(int) info->periodSize, info->periods, info->bufferSizeInBytes); (int) info->periodSize, info->periods, info->bufferSizeInBytes);
} }
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
// define this with a later version of ALSA than 0.9.0rc3 // define this with a later version of ALSA than 0.9.0rc3
// (starting from 1.0.0 it became default behaviour)
#define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_HW_PARAMS_API
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include "Utilities.h" #include "Utilities.h"
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -380,7 +380,7 @@ void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) { ...@@ -380,7 +380,7 @@ void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
void* controls[10]; void* controls[10];
int numControls; int numControls;
char* portName; char* portName;
int isPlayback; int isPlayback = 0;
int isMono; int isMono;
int isStereo; int isStereo;
char* type; char* type;
......
...@@ -188,5 +188,6 @@ UTC-02:920,920::GMT-0200: ...@@ -188,5 +188,6 @@ UTC-02:920,920::GMT-0200:
UTC-11:921,921::GMT-1100: UTC-11:921,921::GMT-1100:
Ulaanbaatar Standard Time:922,922::Asia/Ulaanbaatar: Ulaanbaatar Standard Time:922,922::Asia/Ulaanbaatar:
Venezuela Standard Time:923,923::America/Caracas: Venezuela Standard Time:923,923::America/Caracas:
Western Brazilian Standard Time:924,924:BR:America/Rio_Branco: Magadan Standard Time:924,924::Asia/Magadan:
Armenian Standard Time:925,925:AM:Asia/Yerevan: Western Brazilian Standard Time:925,925:BR:America/Rio_Branco:
Armenian Standard Time:926,926:AM:Asia/Yerevan:
...@@ -60,48 +60,51 @@ public class ISO8601ZoneTest { ...@@ -60,48 +60,51 @@ public class ISO8601ZoneTest {
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
}; };
// badData[][0] - format
// badData[][1] - (bad) text to be parsed
// badData[][2] - subtext at the end of which a parse error is detected
static final String[][] badData = { static final String[][] badData = {
{ "X", "1" }, { "X", "1", "1" },
{ "X", "+1" }, { "X", "+1", "+1" },
{ "X", "-2" }, { "X", "-2", "-2" },
{ "X", "-24" }, { "X", "-24", "-2" },
{ "X", "+24" }, { "X", "+24", "+2" },
{ "XX", "9" }, { "XX", "9", "9" },
{ "XX", "23" }, { "XX", "23", "2" },
{ "XX", "234" }, { "XX", "234", "2" },
{ "XX", "3456" }, { "XX", "3456", "3" },
{ "XX", "23456" }, { "XX", "23456", "2" },
{ "XX", "+1" }, { "XX", "+1", "+1" },
{ "XX", "-12" }, { "XX", "-12", "-12" },
{ "XX", "+123" }, { "XX", "+123", "+123" },
{ "XX", "-12:34" }, { "XX", "-12:34", "-12" },
{ "XX", "+12:34" }, { "XX", "+12:34", "+12" },
{ "XX", "-2423" }, { "XX", "-2423", "-2" },
{ "XX", "+2423" }, { "XX", "+2423", "+2" },
{ "XX", "-1260" }, { "XX", "-1260", "-126" },
{ "XX", "+1260" }, { "XX", "+1260", "+126" },
{ "XXX", "9" }, { "XXX", "9", "9" },
{ "XXX", "23" }, { "XXX", "23", "2" },
{ "XXX", "234" }, { "XXX", "234", "2" },
{ "XXX", "3456" }, { "XXX", "3456", "3" },
{ "XXX", "23456" }, { "XXX", "23456", "2" },
{ "XXX", "2:34" }, { "XXX", "2:34", "2" },
{ "XXX", "12:4" }, { "XXX", "12:4", "1" },
{ "XXX", "12:34" }, { "XXX", "12:34", "1" },
{ "XXX", "-1" }, { "XXX", "-1", "-1" },
{ "XXX", "+1" }, { "XXX", "+1", "+1" },
{ "XXX", "-12" }, { "XXX", "-12", "-12" },
{ "XXX", "+12" }, { "XXX", "+12", "+12" },
{ "XXX", "-123" }, { "XXX", "-123", "-12" },
{ "XXX", "+123" }, { "XXX", "+123", "+12" },
{ "XXX", "-1234" }, { "XXX", "-1234", "-12" },
{ "XXX", "+1234" }, { "XXX", "+1234", "+12" },
{ "XXX", "+24:23" }, { "XXX", "+24:23", "+2" },
{ "XXX", "+12:60" }, { "XXX", "+12:60", "+12:6" },
{ "XXX", "+1:23" }, { "XXX", "+1:23", "+1" },
{ "XXX", "+12:3" }, { "XXX", "+12:3", "+12:3" },
}; };
static String[] badFormats = { static String[] badFormats = {
...@@ -110,6 +113,8 @@ public class ISO8601ZoneTest { ...@@ -110,6 +113,8 @@ public class ISO8601ZoneTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
TimeZone tz = TimeZone.getDefault(); TimeZone tz = TimeZone.getDefault();
Locale loc = Locale.getDefault();
Locale.setDefault(Locale.US);
try { try {
for (int i = 0; i < formatData.length; i++) { for (int i = 0; i < formatData.length; i++) {
...@@ -128,7 +133,7 @@ public class ISO8601ZoneTest { ...@@ -128,7 +133,7 @@ public class ISO8601ZoneTest {
} }
for (String[] d : badData) { for (String[] d : badData) {
badDataParsing(d[0], d[1]); badDataParsing(d[0], d[1], d[2].length());
} }
for (String fmt : badFormats) { for (String fmt : badFormats) {
...@@ -136,6 +141,7 @@ public class ISO8601ZoneTest { ...@@ -136,6 +141,7 @@ public class ISO8601ZoneTest {
} }
} finally { } finally {
TimeZone.setDefault(tz); TimeZone.setDefault(tz);
Locale.setDefault(loc);
} }
} }
...@@ -188,15 +194,24 @@ public class ISO8601ZoneTest { ...@@ -188,15 +194,24 @@ public class ISO8601ZoneTest {
} }
static void badDataParsing(String fmt, String text) { static void badDataParsing(String fmt, String text, int expectedErrorIndex) {
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
try { try {
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
sdf.parse(text); sdf.parse(text);
throw new RuntimeException("didn't throw an exception: fmt=" + fmt throw new RuntimeException("didn't throw an exception: fmt=" + fmt
+ ", text=" + text); + ", text=" + text);
} catch (ParseException e) { } catch (ParseException e) {
// OK // OK
} }
ParsePosition pos = new ParsePosition(0);
Date d = sdf.parse(text, pos);
int errorIndex = pos.getErrorIndex();
if (d != null || errorIndex != expectedErrorIndex) {
throw new RuntimeException("Bad error index=" + errorIndex
+ ", expected=" + expectedErrorIndex
+ ", fmt=" + fmt + ", text=" + text);
}
} }
static void badFormat(String fmt) { static void badFormat(String fmt) {
......
/*
* 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 7003643
* @summary Make sure MessageFormat.toPattern produces correct quoting. (SPI part is tested in PluggableLocale tests.)
*/
import java.text.*;
import java.util.*;
public class Bug7003643 {
private static final int N = 5;
private static final String[] elements = {
"'{'", "'{", "{", "''", "}", "a", "'",
};
public static void main(String[] args) {
Random rand = new Random();
int count = 0;
int max = (int) (Math.pow((double)elements.length, (double)N)/0.52);
while (count < max) {
// Create a random pattern. If the produced pattern is
// valid, then proceed with the round-trip testing.
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++) {
sb.append(elements[rand.nextInt(elements.length)]);
}
String pattern = sb.toString();
MessageFormat mf = null;
try {
mf = new MessageFormat(pattern);
} catch (IllegalArgumentException e) {
// bad pattern data
}
if (mf == null) {
continue;
}
count++;
String res1 = MessageFormat.format(pattern, 123);
String toPattern = mf.toPattern();
String res2 = MessageFormat.format(toPattern, 123);
if (!res1.equals(res2)) {
String s = String.format("Failed%n pattern=\"%s\" => result=\"%s\"%n"
+ " toPattern()=\"%s\" => result=\"%s\"%n",
pattern, res1, toPattern, res2);
throw new RuntimeException(s);
}
}
}
}
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
* @test * @test
* @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613 * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613
* 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951 * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951
* 4147315 4147317 4147552 4335196 4778440 5010672 6475525 6544471 6627549 6786276 * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549
* 6786276
* @summary test Locales * @summary test Locales
*/ */
/* /*
...@@ -895,17 +896,28 @@ test commented out pending API-change approval ...@@ -895,17 +896,28 @@ test commented out pending API-change approval
} }
/** /**
* @bug 4147317 * @bug 4147317 4940539
* java.util.Locale.getISO3Language() works wrong for non ISO-3166 codes. * java.util.Locale.getISO3Language() works wrong for non ISO-639 codes.
* Should throw an exception for unknown locales * Should throw an exception for unknown locales, except they have three
* letter language codes.
*/ */
public void Test4147317() { public void Test4147317() {
// Try with codes that are the wrong length but happen to match text // Try a three letter language code, and check whether it is
// at a valid offset in the mapping table // returned as is.
Locale locale = new Locale("aaa", "CCC"); Locale locale = new Locale("aaa", "CCC");
String result = locale.getISO3Language();
if (!result.equals("aaa")) {
errln("ERROR: getISO3Language() returns: " + result +
" for locale '" + locale + "' rather than returning it as is" );
}
// Try an invalid two letter language code, and check whether it
// throws a MissingResourceException.
locale = new Locale("zz", "CCC");
try { try {
String result = locale.getISO3Language(); result = locale.getISO3Language();
errln("ERROR: getISO3Language() returns: " + result + errln("ERROR: getISO3Language() returns: " + result +
" for locale '" + locale + "' rather than exception" ); " for locale '" + locale + "' rather than exception" );
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -44,6 +44,7 @@ public class DateFormatProviderTest extends ProviderTest { ...@@ -44,6 +44,7 @@ public class DateFormatProviderTest extends ProviderTest {
availableLocalesTest(); availableLocalesTest();
objectValidityTest(); objectValidityTest();
extendedVariantTest(); extendedVariantTest();
messageFormatTest();
} }
void availableLocalesTest() { void availableLocalesTest() {
...@@ -118,4 +119,48 @@ public class DateFormatProviderTest extends ProviderTest { ...@@ -118,4 +119,48 @@ public class DateFormatProviderTest extends ProviderTest {
} }
} }
} }
private static final String[] TYPES = {
"date",
"time"
};
private static final String[] MODIFIERS = {
"",
"short",
"medium", // Same as DEFAULT
"long",
"full"
};
void messageFormatTest() {
for (Locale target : providerloc) {
for (String type : TYPES) {
for (String modifier : MODIFIERS) {
String pattern, expected;
if (modifier.equals("")) {
pattern = String.format("%s={0,%s}", type, type);
} else {
pattern = String.format("%s={0,%s,%s}", type, type, modifier);
}
if (modifier.equals("medium")) {
// medium is default.
expected = String.format("%s={0,%s}", type, type);
} else {
expected = pattern;
}
MessageFormat mf = new MessageFormat(pattern, target);
Format[] fmts = mf.getFormats();
if (fmts[0] instanceof SimpleDateFormat) {
continue;
}
String toPattern = mf.toPattern();
if (!toPattern.equals(expected)) {
throw new RuntimeException("messageFormatTest: got '" + toPattern
+ "', expected '" + expected + "'");
}
}
}
}
}
} }
# #
# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
#!/bin/sh #!/bin/sh
# #
# @test # @test
# @bug 4052440 # @bug 4052440 7003643
# @summary DateFormatProvider tests # @summary DateFormatProvider tests
# @run shell ExecTest.sh foo DateFormatProviderTest true # @run shell ExecTest.sh foo DateFormatProviderTest true
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,6 +29,8 @@ import java.util.*; ...@@ -29,6 +29,8 @@ import java.util.*;
import sun.util.*; import sun.util.*;
import sun.util.resources.*; import sun.util.resources.*;
import com.foo.FooNumberFormat;
public class NumberFormatProviderTest extends ProviderTest { public class NumberFormatProviderTest extends ProviderTest {
com.foo.NumberFormatProviderImpl nfp = new com.foo.NumberFormatProviderImpl(); com.foo.NumberFormatProviderImpl nfp = new com.foo.NumberFormatProviderImpl();
...@@ -43,6 +45,7 @@ public class NumberFormatProviderTest extends ProviderTest { ...@@ -43,6 +45,7 @@ public class NumberFormatProviderTest extends ProviderTest {
NumberFormatProviderTest() { NumberFormatProviderTest() {
availableLocalesTest(); availableLocalesTest();
objectValidityTest(); objectValidityTest();
messageFormatTest();
} }
void availableLocalesTest() { void availableLocalesTest() {
...@@ -72,14 +75,10 @@ public class NumberFormatProviderTest extends ProviderTest { ...@@ -72,14 +75,10 @@ public class NumberFormatProviderTest extends ProviderTest {
} }
// result object // result object
String resultCur = String resultCur = getPattern(NumberFormat.getCurrencyInstance(target));
((DecimalFormat)NumberFormat.getCurrencyInstance(target)).toPattern(); String resultInt = getPattern(NumberFormat.getIntegerInstance(target));
String resultInt = String resultNum = getPattern(NumberFormat.getNumberInstance(target));
((DecimalFormat)NumberFormat.getIntegerInstance(target)).toPattern(); String resultPer = getPattern(NumberFormat.getPercentInstance(target));
String resultNum =
((DecimalFormat)NumberFormat.getNumberInstance(target)).toPattern();
String resultPer =
((DecimalFormat)NumberFormat.getPercentInstance(target)).toPattern();
// provider's object (if any) // provider's object (if any)
String providersCur = null; String providersCur = null;
...@@ -87,21 +86,21 @@ public class NumberFormatProviderTest extends ProviderTest { ...@@ -87,21 +86,21 @@ public class NumberFormatProviderTest extends ProviderTest {
String providersNum = null; String providersNum = null;
String providersPer = null; String providersPer = null;
if (providerloc.contains(target)) { if (providerloc.contains(target)) {
DecimalFormat dfCur = (DecimalFormat)nfp.getCurrencyInstance(target); NumberFormat dfCur = nfp.getCurrencyInstance(target);
if (dfCur != null) { if (dfCur != null) {
providersCur = dfCur.toPattern(); providersCur = getPattern(dfCur);
} }
DecimalFormat dfInt = (DecimalFormat)nfp.getIntegerInstance(target); NumberFormat dfInt = nfp.getIntegerInstance(target);
if (dfInt != null) { if (dfInt != null) {
providersInt = dfInt.toPattern(); providersInt = getPattern(dfInt);
} }
DecimalFormat dfNum = (DecimalFormat)nfp.getNumberInstance(target); NumberFormat dfNum = nfp.getNumberInstance(target);
if (dfNum != null) { if (dfNum != null) {
providersNum = dfNum.toPattern(); providersNum = getPattern(dfNum);
} }
DecimalFormat dfPer = (DecimalFormat)nfp.getPercentInstance(target); NumberFormat dfPer = nfp.getPercentInstance(target);
if (dfPer != null) { if (dfPer != null) {
providersPer = dfPer.toPattern(); providersPer = getPattern(dfPer);
} }
} }
...@@ -174,4 +173,35 @@ public class NumberFormatProviderTest extends ProviderTest { ...@@ -174,4 +173,35 @@ public class NumberFormatProviderTest extends ProviderTest {
} }
} }
} }
private static String getPattern(NumberFormat nf) {
if (nf instanceof DecimalFormat) {
return ((DecimalFormat)nf).toPattern();
}
if (nf instanceof FooNumberFormat) {
return ((FooNumberFormat)nf).toPattern();
}
return null;
}
private static final String[] NUMBER_PATTERNS = {
"num={0,number}",
"num={0,number,currency}",
"num={0,number,percent}",
"num={0,number,integer}"
};
void messageFormatTest() {
for (Locale target : providerloc) {
for (String pattern : NUMBER_PATTERNS) {
MessageFormat mf = new MessageFormat(pattern, target);
String toPattern = mf.toPattern();
if (!pattern.equals(toPattern)) {
throw new RuntimeException("MessageFormat.toPattern: got '"
+ toPattern
+ "', expected '" + pattern + "'");
}
}
}
}
} }
# #
# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
#!/bin/sh #!/bin/sh
# #
# @test # @test
# @bug 4052440 # @bug 4052440 7003643
# @summary NumberFormatProvider tests # @summary NumberFormatProvider tests
# @run shell ExecTest.sh foo NumberFormatProviderTest true # @run shell ExecTest.sh foo NumberFormatProviderTest true
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -42,7 +42,7 @@ public class DateFormatProviderImpl extends DateFormatProvider { ...@@ -42,7 +42,7 @@ public class DateFormatProviderImpl extends DateFormatProvider {
static String[] datePattern = { static String[] datePattern = {
"yyyy'\u5e74'M'\u6708'd'\u65e5'", // full date pattern "yyyy'\u5e74'M'\u6708'd'\u65e5'", // full date pattern
"yyyy/MM/dd", // long date pattern "yyyy/MMM/dd", // long date pattern
"yyyy/MM/dd", // medium date pattern "yyyy/MM/dd", // medium date pattern
"yy/MM/dd" // short date pattern "yy/MM/dd" // short date pattern
}; };
...@@ -68,7 +68,7 @@ public class DateFormatProviderImpl extends DateFormatProvider { ...@@ -68,7 +68,7 @@ public class DateFormatProviderImpl extends DateFormatProvider {
public DateFormat getDateInstance(int style, Locale locale) { public DateFormat getDateInstance(int style, Locale locale) {
for (int i = 0; i < avail.length; i ++) { for (int i = 0; i < avail.length; i ++) {
if (Utils.supportsLocale(avail[i], locale)) { if (Utils.supportsLocale(avail[i], locale)) {
return new SimpleDateFormat(datePattern[style]+dialect[i], locale); return new FooDateFormat(datePattern[style]+dialect[i], locale);
} }
} }
throw new IllegalArgumentException("locale is not supported: "+locale); throw new IllegalArgumentException("locale is not supported: "+locale);
...@@ -77,7 +77,7 @@ public class DateFormatProviderImpl extends DateFormatProvider { ...@@ -77,7 +77,7 @@ public class DateFormatProviderImpl extends DateFormatProvider {
public DateFormat getTimeInstance(int style, Locale locale) { public DateFormat getTimeInstance(int style, Locale locale) {
for (int i = 0; i < avail.length; i ++) { for (int i = 0; i < avail.length; i ++) {
if (Utils.supportsLocale(avail[i], locale)) { if (Utils.supportsLocale(avail[i], locale)) {
return new SimpleDateFormat(timePattern[style]+dialect[i], locale); return new FooDateFormat(timePattern[style]+dialect[i], locale);
} }
} }
throw new IllegalArgumentException("locale is not supported: "+locale); throw new IllegalArgumentException("locale is not supported: "+locale);
...@@ -86,7 +86,7 @@ public class DateFormatProviderImpl extends DateFormatProvider { ...@@ -86,7 +86,7 @@ public class DateFormatProviderImpl extends DateFormatProvider {
public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) { public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) {
for (int i = 0; i < avail.length; i ++) { for (int i = 0; i < avail.length; i ++) {
if (Utils.supportsLocale(avail[i], locale)) { if (Utils.supportsLocale(avail[i], locale)) {
return new SimpleDateFormat( return new FooDateFormat(
datePattern[dateStyle]+" "+timePattern[timeStyle]+dialect[i], locale); datePattern[dateStyle]+" "+timePattern[timeStyle]+dialect[i], locale);
} }
} }
......
/*
* 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.
*/
package com.foo;
import java.text.*;
import java.util.*;
/**
* FooDateFormat provides SimpleDateFormat methods required for the SPI testing.
*/
public class FooDateFormat extends DateFormat {
private SimpleDateFormat sdf;
public FooDateFormat(String pattern, Locale loc) {
sdf = new SimpleDateFormat(pattern, loc);
}
@Override
public StringBuffer format(Date date,
StringBuffer toAppendTo,
FieldPosition fieldPosition) {
return sdf.format(date, toAppendTo, fieldPosition);
}
@Override
public Date parse(String source, ParsePosition pos) {
return sdf.parse(source, pos);
}
@Override
public boolean equals(Object other) {
return other instanceof FooDateFormat
&& sdf.equals(((FooDateFormat)other).sdf);
}
@Override
public int hashCode() {
return sdf.hashCode();
}
}
/*
* 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.
*/
package com.foo;
import java.text.*;
/**
* FooNumberFormat provides DecimalFormat methods required for the SPI testing.
*/
public class FooNumberFormat extends NumberFormat {
private DecimalFormat df;
public FooNumberFormat(String pattern, DecimalFormatSymbols dfs) {
df = new DecimalFormat(pattern, dfs);
}
@Override
public StringBuffer format(double number,
StringBuffer toAppendTo,
FieldPosition pos) {
return df.format(number, toAppendTo, pos);
}
@Override
public StringBuffer format(long number,
StringBuffer toAppendTo,
FieldPosition pos) {
return df.format(number, toAppendTo, pos);
}
@Override
public Number parse(String source, ParsePosition parsePosition) {
return df.parse(source, parsePosition);
}
@Override
public boolean equals(Object other) {
return other instanceof FooNumberFormat
&& df.equals(((FooNumberFormat)other).df);
}
@Override
public int hashCode() {
return df.hashCode();
}
// DecimalFormat specific methods required for testing
public String toPattern() {
return df.toPattern();
}
public DecimalFormatSymbols getDecimalFormatSymbols() {
return df.getDecimalFormatSymbols();
}
public void setDecimalSeparatorAlwaysShown(boolean newValue) {
df.setDecimalSeparatorAlwaysShown(newValue);
}
}
...@@ -28,6 +28,8 @@ FOOFILES_JAVA = \ ...@@ -28,6 +28,8 @@ FOOFILES_JAVA = \
DateFormatSymbolsProviderImpl.java \ DateFormatSymbolsProviderImpl.java \
DecimalFormatSymbolsProviderImpl.java \ DecimalFormatSymbolsProviderImpl.java \
NumberFormatProviderImpl.java \ NumberFormatProviderImpl.java \
FooDateFormat.java \
FooNumberFormat.java \
Utils.java Utils.java
BARFILES_JAVA = \ BARFILES_JAVA = \
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -49,13 +49,15 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -49,13 +49,15 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
static String[] patterns = { static String[] patterns = {
"#,##0.###{0};-#,##0.###{1}", // decimal pattern "#,##0.###{0};-#,##0.###{1}", // decimal pattern
"#{0};(#){1}", // integer pattern
"\u00A4#,##0{0};-\u00A4#,##0{1}", // currency pattern "\u00A4#,##0{0};-\u00A4#,##0{1}", // currency pattern
"#,##0%{0}" // percent pattern "#,##0%{0}" // percent pattern
}; };
// Constants used by factory methods to specify a style of format. // Constants used by factory methods to specify a style of format.
static final int NUMBERSTYLE = 0; static final int NUMBERSTYLE = 0;
static final int CURRENCYSTYLE = 1; static final int INTEGERSTYLE = 1;
static final int PERCENTSTYLE = 2; static final int CURRENCYSTYLE = 2;
static final int PERCENTSTYLE = 3;
public Locale[] getAvailableLocales() { public Locale[] getAvailableLocales() {
return avail; return avail;
...@@ -68,10 +70,10 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -68,10 +70,10 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
MessageFormat.format(patterns[CURRENCYSTYLE], MessageFormat.format(patterns[CURRENCYSTYLE],
dialect[i], dialect[i],
dialect[i]); dialect[i]);
DecimalFormat df = new DecimalFormat(pattern, FooNumberFormat nf = new FooNumberFormat(pattern,
DecimalFormatSymbols.getInstance(locale)); DecimalFormatSymbols.getInstance(locale));
adjustForCurrencyDefaultFractionDigits(df); adjustForCurrencyDefaultFractionDigits(nf);
return df; return nf;
} }
} }
throw new IllegalArgumentException("locale is not supported: "+locale); throw new IllegalArgumentException("locale is not supported: "+locale);
...@@ -81,15 +83,15 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -81,15 +83,15 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
for (int i = 0; i < avail.length; i ++) { for (int i = 0; i < avail.length; i ++) {
if (Utils.supportsLocale(avail[i], locale)) { if (Utils.supportsLocale(avail[i], locale)) {
String pattern = String pattern =
MessageFormat.format(patterns[NUMBERSTYLE], MessageFormat.format(patterns[INTEGERSTYLE],
dialect[i], dialect[i],
dialect[i]); dialect[i]);
DecimalFormat df = new DecimalFormat(pattern, FooNumberFormat nf = new FooNumberFormat(pattern,
DecimalFormatSymbols.getInstance(locale)); DecimalFormatSymbols.getInstance(locale));
df.setMaximumFractionDigits(0); nf.setMaximumFractionDigits(0);
df.setDecimalSeparatorAlwaysShown(false); nf.setDecimalSeparatorAlwaysShown(false);
df.setParseIntegerOnly(true); nf.setParseIntegerOnly(true);
return df; return nf;
} }
} }
throw new IllegalArgumentException("locale is not supported: "+locale); throw new IllegalArgumentException("locale is not supported: "+locale);
...@@ -102,7 +104,7 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -102,7 +104,7 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
MessageFormat.format(patterns[NUMBERSTYLE], MessageFormat.format(patterns[NUMBERSTYLE],
dialect[i], dialect[i],
dialect[i]); dialect[i]);
return new DecimalFormat(pattern, return new FooNumberFormat(pattern,
DecimalFormatSymbols.getInstance(locale)); DecimalFormatSymbols.getInstance(locale));
} }
} }
...@@ -115,7 +117,7 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -115,7 +117,7 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
String pattern = String pattern =
MessageFormat.format(patterns[PERCENTSTYLE], MessageFormat.format(patterns[PERCENTSTYLE],
dialect[i]); dialect[i]);
return new DecimalFormat(pattern, return new FooNumberFormat(pattern,
DecimalFormatSymbols.getInstance(locale)); DecimalFormatSymbols.getInstance(locale));
} }
} }
...@@ -126,8 +128,8 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -126,8 +128,8 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
* Adjusts the minimum and maximum fraction digits to values that * Adjusts the minimum and maximum fraction digits to values that
* are reasonable for the currency's default fraction digits. * are reasonable for the currency's default fraction digits.
*/ */
void adjustForCurrencyDefaultFractionDigits(DecimalFormat df) { void adjustForCurrencyDefaultFractionDigits(FooNumberFormat nf) {
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); DecimalFormatSymbols dfs = nf.getDecimalFormatSymbols();
Currency currency = dfs.getCurrency(); Currency currency = dfs.getCurrency();
if (currency == null) { if (currency == null) {
try { try {
...@@ -138,15 +140,15 @@ public class NumberFormatProviderImpl extends NumberFormatProvider { ...@@ -138,15 +140,15 @@ public class NumberFormatProviderImpl extends NumberFormatProvider {
if (currency != null) { if (currency != null) {
int digits = currency.getDefaultFractionDigits(); int digits = currency.getDefaultFractionDigits();
if (digits != -1) { if (digits != -1) {
int oldMinDigits = df.getMinimumFractionDigits(); int oldMinDigits = nf.getMinimumFractionDigits();
// Common patterns are "#.##", "#.00", "#". // Common patterns are "#.##", "#.00", "#".
// Try to adjust all of them in a reasonable way. // Try to adjust all of them in a reasonable way.
if (oldMinDigits == df.getMaximumFractionDigits()) { if (oldMinDigits == nf.getMaximumFractionDigits()) {
df.setMinimumFractionDigits(digits); nf.setMinimumFractionDigits(digits);
df.setMaximumFractionDigits(digits); nf.setMaximumFractionDigits(digits);
} else { } else {
df.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); nf.setMinimumFractionDigits(Math.min(digits, oldMinDigits));
df.setMaximumFractionDigits(digits); nf.setMaximumFractionDigits(digits);
} }
} }
} }
......
/*
* 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 4847375
* @summary JFileChooser Create New Folder button is disabled incorrectly
* @author Pavel Porvatov
*/
import sun.awt.OSInfo;
import sun.awt.shell.ShellFolder;
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.Method;
public class bug4847375 {
private final String newFolderToolTipText;
private final String lookAndFeel;
public static void main(String[] args) throws Exception {
if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
System.out.println("The test is suitable only for Windows OS. Skipped.");
return;
}
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new bug4847375("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
new bug4847375("javax.swing.plaf.metal.MetalLookAndFeel");
}
});
}
private static Object[][] DIRECTORIES = new Object[][]{
{"getDesktop", Boolean.TRUE},
{"getDrives", Boolean.FALSE}, // My computer
{"getRecent", Boolean.TRUE},
{"getNetwork", Boolean.FALSE},
{"getPersonal", Boolean.TRUE},
};
private bug4847375(String lookAndFeel) {
this.lookAndFeel = lookAndFeel;
try {
UIManager.setLookAndFeel(lookAndFeel);
} catch (Exception e) {
fail("Cannot set LookAndFeel", e);
}
JFileChooser fileChooser = new JFileChooser();
// Find button NewFolder
newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText", fileChooser.getLocale());
if (newFolderToolTipText == null || newFolderToolTipText.length() == 0) {
fail("Cannot find NewFolderButton in FileChooser (tooltip doesn't exist)");
return;
}
JButton newFolderButton = findNewFolderButton(fileChooser);
if (newFolderButton == null) {
fail("Cannot find NewFolderButton in FileChooser");
return;
}
for (Object[] objects : DIRECTORIES) {
String getterName = (String) objects[0];
Boolean enabledNewFolder = (Boolean) objects[1];
fileChooser.setCurrentDirectory(getWin32Folder(getterName));
if (newFolderButton.isEnabled() != enabledNewFolder) {
fail("Enabled state of NewFolderButton should be " + enabledNewFolder +
" for Win32ShellFolderManager2." + getterName + "()");
}
}
}
private JButton findNewFolderButton(Container container) {
JButton result = null;
for (int i = 0; i < container.getComponentCount(); i++) {
Component c = container.getComponent(i);
if (c instanceof JButton && newFolderToolTipText.equals(((JButton) c).getToolTipText())) {
if (result != null) {
fail("Two or more NewFolderButton found in FileChooser");
}
result = (JButton) c;
}
if (c instanceof Container) {
JButton button = findNewFolderButton((Container) c);
if (result == null) {
result = button;
} else {
if (button != null) {
fail("Two or more NewFolderButton found in FileChooser");
}
}
}
}
return result;
}
private ShellFolder getWin32Folder(String getterName) {
try {
Class win32ShellFolderManager2 = Class.forName("sun.awt.shell.Win32ShellFolderManager2");
Method method = win32ShellFolderManager2.getDeclaredMethod(getterName);
method.setAccessible(true);
return (ShellFolder) method.invoke(null);
} catch (Exception e) {
fail("Cannot call '" + getterName + "' in the Win32ShellFolderManager2 class", e);
return null;
}
}
private void fail(String s) {
throw new RuntimeException("Test failed: " + s);
}
private void fail(String s, Throwable e) {
throw new RuntimeException("Test failed for LookAndFeel " + lookAndFeel + ": " + s, e);
}
}
...@@ -40,11 +40,13 @@ public class bug6542335 { ...@@ -40,11 +40,13 @@ public class bug6542335 {
private static MyScrollBarUI ui; private static MyScrollBarUI ui;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Robot robot = new Robot(); final Robot robot = new Robot();
robot.setAutoDelay(10); robot.setAutoDelay(10);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
final Rectangle[] thumbBounds = new Rectangle[1];
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(new Runnable() {
public void run() { public void run() {
final JFrame frame = new JFrame("bug6542335"); final JFrame frame = new JFrame("bug6542335");
...@@ -63,25 +65,39 @@ public class bug6542335 { ...@@ -63,25 +65,39 @@ public class bug6542335 {
rangeModel.setValue(50); rangeModel.setValue(50);
sb.setModel(rangeModel); sb.setModel(rangeModel);
frame.add(sb); frame.add(sb, BorderLayout.NORTH);
frame.setSize(200, 100); frame.setSize(200, 100);
frame.setVisible(true); frame.setVisible(true);
thumbBounds[0] = new Rectangle(ui.getThumbBounds());
} }
}); });
Rectangle thumbBounds = new Rectangle(ui.getThumbBounds());
toolkit.realSync(); toolkit.realSync();
Point l = sb.getLocationOnScreen();
robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight()/2); SwingUtilities.invokeAndWait(new Runnable() {
robot.mousePress(InputEvent.BUTTON1_MASK); public void run() {
robot.mouseRelease(InputEvent.BUTTON1_MASK); Point l = sb.getLocationOnScreen();
robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
});
toolkit.realSync(); toolkit.realSync();
if (!thumbBounds.equals(ui.getThumbBounds())) { SwingUtilities.invokeAndWait(new Runnable() {
throw new RuntimeException("Test failed"); public void run() {
} Rectangle newThumbBounds = ui.getThumbBounds();
if (!thumbBounds[0].equals(newThumbBounds)) {
throw new RuntimeException("Test failed.\nOld bounds: " + thumbBounds[0] +
"\nNew bounds: " + newThumbBounds);
}
}
});
} }
static class MyScrollBarUI extends BasicScrollBarUI { static class MyScrollBarUI extends BasicScrollBarUI {
......
/*
* 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 6532833
@summary PIT: Metal LAF - The right side border is not shown for the Spinner after the removing the buttons
@author Pavel Porvatov
*/
import javax.swing.*;
import java.awt.*;
public class bug6532833 {
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JSpinner[] spinners = new JSpinner[2];
for (int i = 0; i < spinners.length; i++) {
JSpinner spinner = new JSpinner();
spinner.setValue(2010);
Component arrowUp = spinner.getComponent(0);
Component arrowDown = spinner.getComponent(1);
LayoutManager layout = spinner.getLayout();
layout.removeLayoutComponent(arrowUp);
layout.removeLayoutComponent(arrowDown);
if (i == 1) {
spinner.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
}
spinners[i] = spinner;
}
// Do layout of spinners components
JFrame frame = new JFrame();
for (JSpinner spinner : spinners) {
frame.getContentPane().add(spinner);
}
frame.pack();
for (JSpinner spinner : spinners) {
Insets insets = spinner.getInsets();
if (spinner.getWidth() != insets.left + insets.right + spinner.getEditor().getWidth()) {
throw new RuntimeException("Spinner editor width is invalid");
}
}
frame.dispose();
}
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册