Mercurial > hg > icedtea8-forest > jdk
changeset 12899:824988d089dd jdk8u152-b03
Merge
author | asaha |
---|---|
date | Fri, 14 Apr 2017 09:44:21 -0700 |
parents | f7a7f85c9513 (current diff) 4728c13e97f1 (diff) |
children | 5534221c23fc |
files | src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java |
diffstat | 25 files changed, 1075 insertions(+), 214 deletions(-) [+] |
line wrap: on
line diff
--- a/make/data/tzdata/VERSION Tue Apr 04 11:57:35 2017 -0700 +++ b/make/data/tzdata/VERSION Fri Apr 14 09:44:21 2017 -0700 @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2017a +tzdata2017b
--- a/make/data/tzdata/africa Tue Apr 04 11:57:35 2017 -0700 +++ b/make/data/tzdata/africa Fri Apr 14 09:44:21 2017 -0700 @@ -443,18 +443,25 @@ # See Africa/Johannesburg. # Liberia -# From Paul Eggert (2006-03-22): -# In 1972 Liberia was the last country to switch -# from a UTC offset that was not a multiple of 15 or 20 minutes. -# Howse reports that it was in honor of their president's birthday. -# Shank & Pottenger report the date as May 1, whereas Howse reports Jan; -# go with Shanks & Pottenger. -# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and -# Whitman each report -0:44:30; go with the more precise figure. +# +# From Paul Eggert (2017-03-02): +# +# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30. +# +# In 1972 Liberia was the last country to switch from a UTC offset +# that was not a multiple of 15 or 20 minutes. The 1972 change was on +# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of: +# Presidential Papers: First year of the administration of +# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972. +# Monrovia: Executive Mansion. +# +# Use the abbreviation "MMT" before 1972, as the more-accurate numeric +# abbreviation "-004430" would be one byte over the POSIX limit. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Monrovia -0:43:08 - LMT 1882 -0:43:08 - MMT 1919 Mar # Monrovia Mean Time - -0:44:30 - -004430 1972 May + -0:44:30 - MMT 1972 Jan 7 # approximately MMT 0:00 - GMT ###############################################################################
--- a/make/data/tzdata/iso3166.tab Tue Apr 04 11:57:35 2017 -0700 +++ b/make/data/tzdata/iso3166.tab Fri Apr 14 09:44:21 2017 -0700 @@ -32,8 +32,8 @@ # All text uses UTF-8 encoding. The columns of the table are as follows: # # 1. ISO 3166-1 alpha-2 country code, current as of -# ISO 3166-1 Newsletter VI-16 (2013-07-11). See: Updates on ISO 3166 -# http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm +# ISO 3166-1 N905 (2016-11-15). See: Updates on ISO 3166-1 +# http://isotc.iso.org/livelink/livelink/Open/16944257 # 2. The usual English name for the coded region, # chosen so that alphabetic sorting of subsets produces helpful lists. # This is not the same as the English name in the ISO 3166 tables.
--- a/make/data/tzdata/northamerica Tue Apr 04 11:57:35 2017 -0700 +++ b/make/data/tzdata/northamerica Fri Apr 14 09:44:21 2017 -0700 @@ -3162,6 +3162,12 @@ # http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/ # http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/ +# From Steffen Thorsen (2017-03-12): +# We have received 4 mails from different people telling that Haiti +# has started DST again today, and this source seems to confirm that, +# I have not been able to find a more authoritative source: +# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Haiti 1983 only - May 8 0:00 1:00 D Rule Haiti 1984 1987 - Apr lastSun 0:00 1:00 D @@ -3174,6 +3180,8 @@ Rule Haiti 2005 2006 - Oct lastSun 0:00 0 S Rule Haiti 2012 2015 - Mar Sun>=8 2:00 1:00 D Rule Haiti 2012 2015 - Nov Sun>=1 2:00 0 S +Rule Haiti 2017 max - Mar Sun>=8 2:00 1:00 D +Rule Haiti 2017 max - Nov Sun>=1 2:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Port-au-Prince -4:49:20 - LMT 1890 -4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Tue Apr 04 11:57:35 2017 -0700 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Fri Apr 14 09:44:21 2017 -0700 @@ -214,6 +214,7 @@ private boolean isFullScreenAnimationOn; private volatile boolean isIconifyAnimationActive; + private volatile boolean isZoomed; private Window target; private LWWindowPeer peer; @@ -501,11 +502,7 @@ if (undecorated) { return this.normalBounds != null; } - AtomicBoolean ref = new AtomicBoolean(); - execute(ptr -> { - ref.set(CWrapper.NSWindow.isZoomed(ptr)); - }); - return ref.get(); + return isZoomed; } private void maximize() { @@ -978,6 +975,11 @@ protected void deliverMoveResizeEvent(int x, int y, int width, int height, boolean byUser) { + AtomicBoolean ref = new AtomicBoolean(); + execute(ptr -> { + ref.set(CWrapper.NSWindow.isZoomed(ptr)); + }); + isZoomed = ref.get(); checkZoom(); final Rectangle oldB = nativeBounds;
--- a/src/macosx/native/sun/awt/CPrinterJob.m Tue Apr 04 11:57:35 2017 -0700 +++ b/src/macosx/native/sun/awt/CPrinterJob.m Fri Apr 14 09:44:21 2017 -0700 @@ -361,9 +361,11 @@ static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z"); static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I"); + static JNF_MEMBER_CACHE(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I"); + static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I"); - static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;"); + static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;"); NSMutableDictionary* printingDictionary = [dst dictionary]; @@ -372,32 +374,34 @@ jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object) [printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate]; - jint jNumPages = JNFCallIntMethod(env, srcPageable, jm_getNumberOfPages); // AWT_THREADING Safe (!appKit) - if (jNumPages != java_awt_print_Pageable_UNKNOWN_NUMBER_OF_PAGES) - { - jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib); - if (selectID ==0) { - [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages]; - } else if (selectID == 2) { - // In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether - // NSPrintAllPages is YES or NO - [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages]; - [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly]; - } else { + jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib); + jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage); + jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage); + if (selectID ==0) { + [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages]; + } else if (selectID == 2) { + // In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether + // NSPrintAllPages is YES or NO + [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages]; + [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly]; + } else { + jint minPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMinPage); + jint maxPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMaxPage); + + // for PD_SELECTION or PD_NOSELECTION, check from/to page + // to determine which radio button to select + if (fromPage > minPage || toPage < maxPage) { [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages]; + } else { + [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages]; } + } - jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage); - jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage); - // setting fromPage and toPage will not be shown in the dialog if printing All pages - [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; - [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; - } - else - { - [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages]; - } - jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); + // setting fromPage and toPage will not be shown in the dialog if printing All pages + [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; + [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; + + jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat, (jint)0); if (page != NULL) { javaPageFormatToNSPrintInfo(env, NULL, page, dst); }
--- a/src/macosx/native/sun/awt/QuartzSurfaceData.m Tue Apr 04 11:57:35 2017 -0700 +++ b/src/macosx/native/sun/awt/QuartzSurfaceData.m Fri Apr 14 09:44:21 2017 -0700 @@ -72,7 +72,7 @@ // given a UInt32 color, it tries to find that find the corresponding CGColorRef in the hash cache. If the CGColorRef // doesn't exist or there is a collision, it creates a new one CGColorRef and put's in the cache. Then, -// it sets with current fill/stroke color for the the CGContext passed in (qsdo->cgRef). +// it sets with current fill/stroke color for the CGContext passed in (qsdo->cgRef). void setCachedColor(QuartzSDOps *qsdo, UInt32 color) { static const CGFloat kColorConversionMultiplier = 1.0f/255.0f; @@ -286,26 +286,19 @@ for (i = 0; i < num_locations; i++) { locations[i] = gradientInfo->fractionsdata[i]; -//fprintf(stderr, "locations[%d] %f\n", i, locations[i]); } for (i = 0; i < component_size; i++) { components[i] = gradientInfo->colordata[i]; -//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n", -// i, components[i], i, gradientInfo->colordata[i]); } CGContextSaveGState(cgRef); gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations); -//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n", -// gradientInfo->start.x, gradientInfo->start.y); -//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n", -// gradientInfo->end.x, gradientInfo->end.y); if (qsdo->isEvenOddFill) { CGContextEOClip(cgRef); } else { CGContextClip(cgRef); } CGContextDrawLinearGradient(cgRef, gradient, gradientInfo->start, gradientInfo->end, kCGGradientDrawsAfterEndLocation); - + CGContextRestoreGState(cgRef); CGColorSpaceRelease(colorspace); CGGradientRelease(gradient); @@ -334,25 +327,17 @@ for (i = 0; i < num_locations; i++) { locations[i] = gradientInfo->fractionsdata[i]; -//fprintf(stderr, "locations[%d] %f\n", i, locations[i]); } for (i = 0; i < component_size; i++) { components[i] = gradientInfo->colordata[i]; -//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n", -// i, components[i], i, gradientInfo->colordata[i]); } CGContextSaveGState(cgRef); gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations); -//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n", -// gradientInfo->start.x, gradientInfo->start.y); -//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n", -// gradientInfo->end.x, gradientInfo->end.y); if (qsdo->isEvenOddFill) { CGContextEOClip(cgRef); } else { CGContextClip(cgRef); } -//fprintf(stderr, "gradientInfo->startRadius %f, gradientInfo->endRadius %f\n",startRadius,endRadius); CGContextDrawRadialGradient(cgRef, gradient, gradientInfo->start, 0, gradientInfo->end, endRadius, kCGGradientDrawsAfterEndLocation); CGContextRestoreGState(cgRef); @@ -944,55 +929,41 @@ if (colorArray != NULL) { jint length = (*env)->GetArrayLength(env, colorArray); -//fprintf(stderr, "length %d\n", length); jint* jcolorData = (jint*)(*env)->GetPrimitiveArrayCritical(env, colorArray, NULL); - CGFloat* colors= (CGFloat*)calloc(0, sizeof(CGFloat)*length); - int i = 0; + qsdo->gradientInfo->colordata = (CGFloat*)malloc(sizeof(CGFloat)*4*length); + memset(qsdo->gradientInfo->colordata, 0, sizeof(CGFloat)*4*length); if (jcolorData != NULL) { - jint ival; - for (ival=0; ival<length; ival++) + int i; + for (i=0; i<length; i++) { - colors[ival] = (CGFloat)jcolorData[ival]; + qsdo->gradientInfo->colordata[i*4] = ((jcolorData[i]>>16)&0xff)*kColorConversionMultiplier; + + qsdo->gradientInfo->colordata[i*4+1] = ((jcolorData[i]>>8)&0xff)*kColorConversionMultiplier; + + qsdo->gradientInfo->colordata[i*4+2] = ((jcolorData[i]>>0)&0xff)*kColorConversionMultiplier; + + qsdo->gradientInfo->colordata[i*4+3] = ((jcolorData[i]>>24)&0xff)*kColorConversionMultiplier; } } (*env)->ReleasePrimitiveArrayCritical(env, colorArray, jcolorData, 0); - qsdo->gradientInfo->colordata = (CGFloat*)calloc(0, sizeof(CGFloat)*4*length); - for (i = 0; i < length; i++) - { - jint c1 = colors[i]; -//fprintf(stderr, "c1 %x\n", c1); - qsdo->gradientInfo->colordata[i*4] = ((c1>>16)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4, qsdo->gradientInfo->colordata[i*4]); - - qsdo->gradientInfo->colordata[i*4+1] = ((c1>>8)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+1, qsdo->gradientInfo->colordata[i*4+1]); - - qsdo->gradientInfo->colordata[i*4+2] = ((c1>>0)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+2, qsdo->gradientInfo->colordata[i*4+2]); - - qsdo->gradientInfo->colordata[i*4+3] = ((c1>>24)&0xff)*kColorConversionMultiplier; -//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+3, qsdo->gradientInfo->colordata[i*4+3]); - } - free(colors); } jobject fractionsArray = ((*env)->GetObjectArrayElement(env, qsdo->javaGraphicsStatesObjects, sun_java2d_OSXSurfaceData_kFractionsArrayIndex)); if (fractionsArray != NULL) { jint length = (*env)->GetArrayLength(env, fractionsArray); -//fprintf(stderr, "fractions length %d\n", length); qsdo->gradientInfo->fractionsLength = length; jfloat* jfractionsData = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, fractionsArray, NULL); if (jfractionsData != NULL) { + int i; qsdo->gradientInfo->fractionsdata = (CGFloat *)malloc(sizeof(CGFloat) *length); - jint i; + memset(qsdo->gradientInfo->fractionsdata, 0, sizeof(CGFloat)*length); for (i=0; i<length; i++) { qsdo->gradientInfo->fractionsdata[i] = jfractionsData[i]; -//fprintf(stderr, "jfrationsData[%d] %f, qsdo->gradientInfo->fractionsdata[%d] = %f\n", i, jfractionsData[i], i, qsdo->gradientInfo->fractionsdata[i]); } (*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, jfractionsData, 0); }
--- a/src/share/classes/java/time/chrono/Era.java Tue Apr 04 11:57:35 2017 -0700 +++ b/src/share/classes/java/time/chrono/Era.java Fri Apr 14 09:44:21 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -310,8 +310,8 @@ * The parameters control the style of the returned text and the locale. * <p> * If no textual mapping is found then the {@link #getValue() numeric value} is returned. - * <p> - * This default implementation is suitable for all implementations. + * + * @apiNote This default implementation is suitable for most implementations. * * @param style the style of the text required, not null * @param locale the locale to use, not null
--- a/src/share/classes/java/time/chrono/JapaneseEra.java Tue Apr 04 11:57:35 2017 -0700 +++ b/src/share/classes/java/time/chrono/JapaneseEra.java Fri Apr 14 09:44:21 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -73,11 +73,13 @@ import java.io.Serializable; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.format.TextStyle; import java.time.temporal.ChronoField; import java.time.temporal.TemporalField; import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Arrays; +import java.util.Locale; import java.util.Objects; import sun.util.calendar.CalendarDate; @@ -125,8 +127,8 @@ */ public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8)); - // the number of defined JapaneseEra constants. - // There could be an extra era defined in its configuration. + // The number of predefined JapaneseEra constants. + // There may be a supplemental era defined by the property. private static final int N_ERA_CONSTANTS = HEISEI.getValue() + ERA_OFFSET; /** @@ -236,6 +238,23 @@ return Arrays.copyOf(KNOWN_ERAS, KNOWN_ERAS.length); } + /** + * {@inheritDoc} + * + * @param style {@inheritDoc} + * @param locale {@inheritDoc} + */ + @Override + public String getDisplayName(TextStyle style, Locale locale) { + // If this JapaneseEra is a supplemental one, obtain the name from + // the era definition. + if (getValue() > N_ERA_CONSTANTS - ERA_OFFSET) { + Objects.requireNonNull(locale, "locale"); + return style.asNormal() == TextStyle.NARROW ? getAbbreviation() : getName(); + } + return Era.super.getDisplayName(style, locale); + } + //----------------------------------------------------------------------- /** * Obtains an instance of {@code JapaneseEra} from a date. @@ -337,11 +356,7 @@ //----------------------------------------------------------------------- String getAbbreviation() { - int index = ordinal(getValue()); - if (index == 0) { - return ""; - } - return ERA_CONFIG[index].getAbbreviation(); + return ERA_CONFIG[ordinal(getValue())].getAbbreviation(); } String getName() {
--- a/src/share/classes/javax/swing/text/html/parser/Parser.java Tue Apr 04 11:57:35 2017 -0700 +++ b/src/share/classes/javax/swing/text/html/parser/Parser.java Fri Apr 14 09:44:21 2017 -0700 @@ -2021,8 +2021,11 @@ } /* To account for extra read()'s that happened */ - for (int j = 0; j < i; j++) { - addString(charsToAdd[j]); + if (i > 0) { + for (int j = 0; j < i; j++) { + addString(charsToAdd[j]); + } + continue; } switch (ch) { case -1:
--- a/src/share/classes/sun/print/RasterPrinterJob.java Tue Apr 04 11:57:35 2017 -0700 +++ b/src/share/classes/sun/print/RasterPrinterJob.java Fri Apr 14 09:44:21 2017 -0700 @@ -843,14 +843,6 @@ } } - protected PageFormat getPageFormatFromAttributes() { - if (attributes == null || attributes.isEmpty()) { - return null; - } - return attributeToPageFormat(getPrintService(), this.attributes); - } - - /** * Presents the user a dialog for changing properties of the * print job interactively.
--- a/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java Tue Apr 04 11:57:35 2017 -0700 +++ b/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java Fri Apr 14 09:44:21 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, 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 @@ -31,6 +31,8 @@ import java.util.Set; import java.util.TreeMap; import java.util.spi.CalendarNameProvider; +import sun.util.calendar.CalendarSystem; +import sun.util.calendar.Era; /** * Concrete implementation of the {@link java.util.spi.CalendarDataProvider @@ -67,7 +69,21 @@ if (field == DAY_OF_WEEK || field == YEAR) { --value; } - if (value < 0 || value >= strings.length) { + if (value < 0 || value > strings.length) { + return null; + } else if (value == strings.length) { + if (field == ERA && "japanese".equals(calendarType)) { + // get the supplemental era, if any, specified through + // the property "jdk.calendar.japanese.supplemental.era" + // which is always the last element. + Era[] jeras = CalendarSystem.forName("japanese").getEras(); + if (jeras.length == value) { + Era supEra = jeras[value - 1]; // 0-based index + return style == LONG ? + supEra.getName() : + supEra.getAbbreviation(); + } + } return null; } name = strings[value];
--- a/src/solaris/native/java/lang/java_props_macosx.c Tue Apr 04 11:57:35 2017 -0700 +++ b/src/solaris/native/java/lang/java_props_macosx.c Fri Apr 14 09:44:21 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -23,10 +23,10 @@ * questions. */ -#include <dlfcn.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> +#include <objc/objc-runtime.h> #include <Security/AuthSession.h> #include <CoreFoundation/CoreFoundation.h> @@ -35,16 +35,6 @@ #include "java_props_macosx.h" - -// need dlopen/dlsym trick to avoid pulling in JavaRuntimeSupport before libjava.dylib is loaded -static void *getJRSFramework() { - static void *jrsFwk = NULL; - if (jrsFwk == NULL) { - jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL); - } - return jrsFwk; -} - char *getPosixLocale(int cat) { char *lc = setlocale(cat, NULL); if ((lc == NULL) || (strcmp(lc, "C") == 0)) { @@ -56,48 +46,106 @@ #define LOCALEIDLENGTH 128 char *getMacOSXLocale(int cat) { + const char* retVal = NULL; + switch (cat) { case LC_MESSAGES: { - void *jrsFwk = getJRSFramework(); - if (jrsFwk == NULL) return NULL; + // get preferred language code + CFArrayRef languages = CFLocaleCopyPreferredLanguages(); + if (languages == NULL) { + return NULL; + } + if (CFArrayGetCount(languages) <= 0) { + CFRelease(languages); + return NULL; + } - char *(*JRSCopyPrimaryLanguage)() = dlsym(jrsFwk, "JRSCopyPrimaryLanguage"); - char *primaryLanguage = JRSCopyPrimaryLanguage ? JRSCopyPrimaryLanguage() : NULL; - if (primaryLanguage == NULL) return NULL; + CFStringRef primaryLanguage = (CFStringRef)CFArrayGetValueAtIndex(languages, 0); + if (primaryLanguage == NULL) { + CFRelease(languages); + return NULL; + } + char languageString[LOCALEIDLENGTH]; + if (CFStringGetCString(primaryLanguage, languageString, + LOCALEIDLENGTH, CFStringGetSystemEncoding()) == false) { + CFRelease(languages); + return NULL; + } + CFRelease(languages); - char *(*JRSCopyCanonicalLanguageForPrimaryLanguage)(char *) = dlsym(jrsFwk, "JRSCopyCanonicalLanguageForPrimaryLanguage"); - char *canonicalLanguage = JRSCopyCanonicalLanguageForPrimaryLanguage ? JRSCopyCanonicalLanguageForPrimaryLanguage(primaryLanguage) : NULL; - free (primaryLanguage); + retVal = languageString; - return canonicalLanguage; + // Special case for Portuguese in Brazil: + // The language code needs the "_BR" region code (to distinguish it + // from Portuguese in Portugal), but this is missing when using the + // "Portuguese (Brazil)" language. + // If language is "pt" and the current locale is pt_BR, return pt_BR. + char localeString[LOCALEIDLENGTH]; + if (strcmp(retVal, "pt") == 0 && + CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()), + localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding()) && + strcmp(localeString, "pt_BR") == 0) { + retVal = localeString; + } } break; default: { char localeString[LOCALEIDLENGTH]; - if (CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()), - localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding())) { - return strdup(localeString); + if (!CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()), + localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding())) { + return NULL; } + retVal = localeString; } break; } + if (retVal != NULL) { + // Language IDs use the language designators and (optional) region + // and script designators of BCP 47. So possible formats are: + // + // "en" (language designator only) + // "haw" (3-letter lanuage designator) + // "en-GB" (language with alpha-2 region designator) + // "es-419" (language with 3-digit UN M.49 area code) + // "zh-Hans" (language with ISO 15924 script designator) + // "zh-Hans-US" (language with ISO 15924 script designator and region) + // "zh-Hans-419" (language with ISO 15924 script designator and UN M.49) + // + // In the case of region designators (alpha-2 and/or UN M.49), we convert + // to our locale string format by changing '-' to '_'. That is, if + // the '-' is followed by fewer than 4 chars. + char* scriptOrRegion = strchr(retVal, '-'); + if (scriptOrRegion != NULL) { + int length = strlen(scriptOrRegion); + if (length > 5) { + // Region and script both exist. Honor the script for now + scriptOrRegion[5] = '\0'; + } else if (length < 5) { + *scriptOrRegion = '_'; + + assert((length == 3 && + // '-' followed by a 2 character region designator + isalpha(scriptOrRegion[1]) && + isalpha(scriptOrRegion[2])) || + (length == 4 && + // '-' followed by a 3-digit UN M.49 area code + isdigit(scriptOrRegion[1]) && + isdigit(scriptOrRegion[2]) && + isdigit(scriptOrRegion[3]))); + } + } + + return strdup(retVal); + } return NULL; } char *setupMacOSXLocale(int cat) { char * ret = getMacOSXLocale(cat); - if (cat == LC_MESSAGES && ret != NULL) { - void *jrsFwk = getJRSFramework(); - if (jrsFwk != NULL) { - void (*JRSSetDefaultLocalization)(char *) = dlsym(jrsFwk, "JRSSetDefaultLocalization"); - if (JRSSetDefaultLocalization) JRSSetDefaultLocalization(ret); - } - } - if (ret == NULL) { return getPosixLocale(cat); } else { @@ -124,26 +172,57 @@ return 0; } +// 10.9 SDK does not include the NSOperatingSystemVersion struct. +// For now, create our own +typedef struct { + NSInteger majorVersion; + NSInteger minorVersion; + NSInteger patchVersion; +} OSVerStruct; + void setOSNameAndVersion(java_props_t *sprops) { - /* Don't rely on JRSCopyOSName because there's no guarantee the value will - * remain the same, or even if the JRS functions will continue to be part of - * Mac OS X. So hardcode os_name, and fill in os_version if we can. - */ + // Hardcode os_name, and fill in os_version sprops->os_name = strdup("Mac OS X"); - void *jrsFwk = getJRSFramework(); - if (jrsFwk != NULL) { - char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion"); - if (copyOSVersion != NULL) { - sprops->os_version = copyOSVersion(); - return; + char* osVersionCStr = NULL; + // Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function, + // but it's not in the 10.9 SDK. So, call it via objc_msgSend_stret. + if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) { + OSVerStruct (*procInfoFn)(id rec, SEL sel) = (OSVerStruct(*)(id, SEL))objc_msgSend_stret; + OSVerStruct osVer = procInfoFn([NSProcessInfo processInfo], + @selector(operatingSystemVersion)); + NSString *nsVerStr; + if (osVer.patchVersion == 0) { // Omit trailing ".0" + nsVerStr = [NSString stringWithFormat:@"%ld.%ld", + (long)osVer.majorVersion, (long)osVer.minorVersion]; + } else { + nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld", + (long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion]; + } + // Copy out the char* + osVersionCStr = strdup([nsVerStr UTF8String]); + } + // Fallback if running on pre-10.9 Mac OS + if (osVersionCStr == NULL) { + NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile : + @"/System/Library/CoreServices/SystemVersion.plist"]; + if (version != NULL) { + NSString *nsVerStr = [version objectForKey : @"ProductVersion"]; + if (nsVerStr != NULL) { + osVersionCStr = strdup([nsVerStr UTF8String]); + } } } - sprops->os_version = strdup("Unknown"); + if (osVersionCStr == NULL) { + osVersionCStr = strdup("Unknown"); + } + sprops->os_version = osVersionCStr; } -static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) { +static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, + CFStringRef inHostKey, CFStringRef inPortKey, + CFStringRef *outProxyHost, int *ioProxyPort) { /* See if the proxy is enabled. */ CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey); if (cf_enabled == NULL) {
--- a/src/solaris/native/java/lang/java_props_md.c Tue Apr 04 11:57:35 2017 -0700 +++ b/src/solaris/native/java/lang/java_props_md.c Fri Apr 14 09:44:21 2017 -0700 @@ -91,46 +91,6 @@ return 0; } -/* This function sets an environment variable using envstring. - * The format of envstring is "name=value". - * If the name has already existed, it will append value to the name. - */ -static void -setPathEnvironment(char *envstring) -{ - char name[20], *value, *current; - - value = strchr(envstring, '='); /* locate name and value separator */ - - if (! value) - return; /* not a valid environment setting */ - - /* copy first part as environment name */ - strncpy(name, envstring, value - envstring); - name[value-envstring] = '\0'; - - value++; /* set value point to value of the envstring */ - - current = getenv(name); - if (current) { - if (! strstr(current, value)) { - /* value is not found in current environment, append it */ - char *temp = malloc(strlen(envstring) + strlen(current) + 2); - strcpy(temp, name); - strcat(temp, "="); - strcat(temp, current); - strcat(temp, ":"); - strcat(temp, value); - putenv(temp); - } - /* else the value has already been set, do nothing */ - } - else { - /* environment variable is not found */ - putenv(envstring); - } -} - #ifndef P_tmpdir #define P_tmpdir "/var/tmp" #endif @@ -615,16 +575,6 @@ sprops.path_separator = ":"; sprops.line_separator = "\n"; -#if !defined(_ALLBSD_SOURCE) - /* Append CDE message and resource search path to NLSPATH and - * XFILESEARCHPATH, in order to pick localized message for - * FileSelectionDialog window (Bug 4173641). - */ - setPathEnvironment("NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat"); - setPathEnvironment("XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt"); -#endif - - #ifdef MACOSX setProxyProperties(&sprops); #endif
--- a/src/solaris/native/java/lang/locale_str.h Tue Apr 04 11:57:35 2017 -0700 +++ b/src/solaris/native/java/lang/locale_str.h Fri Apr 14 09:44:21 2017 -0700 @@ -135,6 +135,16 @@ "sr_SP", "sr_YU", "tchinese", "zh_TW", #endif +#ifdef MACOSX + "sr-Latn", "sr_CS", // Mappings as done by old Apple JRS code + "tk", "tk-Cyrl", + "tt-Latn", "tt-Cyrl", + "uz", "uz_UZ", + "uz-Arab", "uz_UZ", + "uz-Latn", "uz_UZ", + "zh-Hans", "zh_CN", + "zh-Hant", "zh_TW", +#endif "", "", };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Window/WindowDeadlockTest/WindowDeadlockTest.java Fri Apr 14 09:44:21 2017 -0700 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2017, 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 8176490 + * @summary Tests that there is no hang or deadlock when the visibility + * of parent and child windows is changed. + * @library ../../regtesthelpers + * @build Util + * @run main/timeout=20 WindowDeadlockTest + */ + +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Robot; + +import test.java.awt.regtesthelpers.Util; + +public class WindowDeadlockTest { + public static void main(String[] args) throws Exception { + Robot robot = Util.createRobot(); + + Frame main = new Frame("Main"); + main.setBounds(0, 0, 200, 100); + main.setVisible(true); + + Dialog first = new Dialog(main, "First"); + first.setBounds(250, 0, 200, 100); + first.setVisible(true); + + Dialog second = new Dialog(first, "Second"); + second.setBounds(0, 150, 200, 100); + second.setVisible(true); + + Util.waitForIdle(robot); + robot.delay(2000); + + Dialog third = new Dialog(first, "Third", false); + third.setBounds(250, 150, 200, 100); + third.setVisible(true); + first.setVisible(false); // the hang takes place here + + Util.waitForIdle(robot); + robot.delay(2000); + + third.dispose(); + second.dispose(); + first.dispose(); + main.dispose(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java Fri Apr 14 09:44:21 2017 -0700 @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2017, 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 8167102 + @summary PrintRequestAttributeSet breaks page size set using PageFormat + @run main/manual WrongPaperPrintingTest + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.Size2DSyntax; +import javax.print.attribute.standard.Chromaticity; +import javax.print.attribute.standard.MediaSize; +import javax.print.attribute.standard.MediaSizeName; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.Timer; +import javax.swing.WindowConstants; + +public class WrongPaperPrintingTest implements Printable { + private static final CountDownLatch testEndedSignal = new CountDownLatch(1); + private static final int testTimeout = 300000; + private static volatile String testFailureMsg; + private static volatile boolean testPassed; + private static volatile boolean testFinished; + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> createAndShowTestDialog()); + + try { + if (!testEndedSignal.await(testTimeout, TimeUnit.MILLISECONDS)) { + throw new RuntimeException(String.format( + "Test timeout '%d ms' elapsed.", testTimeout)); + } + if (!testPassed) { + String failureMsg = testFailureMsg; + if ((failureMsg != null) && (!failureMsg.trim().isEmpty())) { + throw new RuntimeException(failureMsg); + } else { + throw new RuntimeException("Test failed."); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException(ie); + } finally { + testFinished = true; + } + } + + private static void doTest() { + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + aset.add(Chromaticity.MONOCHROME); + + MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5); + float[] size = isoA5Size.getSize(Size2DSyntax.INCH); + Paper paper = new Paper(); + paper.setSize(size[0] * 72.0, size[1] * 72.0); + paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0); + PageFormat pf = new PageFormat(); + pf.setPaper(paper); + + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(new WrongPaperPrintingTest(), job.validatePage(pf)); + if (job.printDialog()) { + try { + job.print(aset); + } catch (PrinterException pe) { + throw new RuntimeException(pe); + } + } + } + + private static void pass() { + testPassed = true; + testEndedSignal.countDown(); + } + + private static void fail(String failureMsg) { + testFailureMsg = failureMsg; + testPassed = false; + testEndedSignal.countDown(); + } + + private static String convertMillisToTimeStr(int millis) { + if (millis < 0) { + return "00:00:00"; + } + int hours = millis / 3600000; + int minutes = (millis - hours * 3600000) / 60000; + int seconds = (millis - hours * 3600000 - minutes * 60000) / 1000; + return String.format("%02d:%02d:%02d", hours, minutes, seconds); + } + + private static void createAndShowTestDialog() { + String description = + " To run this test it is required to have a virtual PDF\r\n" + + " printer or any other printer supporting A5 paper size.\r\n" + + "\r\n" + + " 1. Verify that NOT A5 paper size is set as default for the\r\n" + + " printer to be used.\r\n" + + " 2. Click on \"Start Test\" button.\r\n" + + " 3. In the shown print dialog select the printer and click\r\n" + + " on \"Print\" button.\r\n" + + " 4. Verify that a page with a drawn rectangle is printed on\r\n" + + " a paper of A5 size which is (5.8 x 8.3 in) or\r\n" + + " (148 x 210 mm).\r\n" + + "\r\n" + + " If the printed page size is correct, click on \"PASS\"\r\n" + + " button, otherwise click on \"FAIL\" button."; + + final JDialog dialog = new JDialog(); + dialog.setTitle("WrongPaperPrintingTest"); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + dialog.dispose(); + fail("Main dialog was closed."); + } + }); + + final JLabel testTimeoutLabel = new JLabel(String.format( + "Test timeout: %s", convertMillisToTimeStr(testTimeout))); + final long startTime = System.currentTimeMillis(); + final Timer timer = new Timer(0, null); + timer.setDelay(1000); + timer.addActionListener((e) -> { + int leftTime = testTimeout - (int)(System.currentTimeMillis() - startTime); + if ((leftTime < 0) || testFinished) { + timer.stop(); + dialog.dispose(); + } + testTimeoutLabel.setText(String.format( + "Test timeout: %s", convertMillisToTimeStr(leftTime))); + }); + timer.start(); + + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + final JButton failButton = new JButton("FAIL"); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + new Thread(() -> { + try { + doTest(); + + SwingUtilities.invokeLater(() -> { + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + } catch (Throwable t) { + t.printStackTrace(); + dialog.dispose(); + fail("Exception occurred in a thread executing the test."); + } + }).start(); + }); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail("Size of a printed page is wrong."); + }); + + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel labelPanel = new JPanel(new FlowLayout()); + labelPanel.add(testTimeoutLabel); + mainPanel.add(labelPanel, BorderLayout.NORTH); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + + dialog.pack(); + dialog.setVisible(true); + } + + @Override + public int print(Graphics g, PageFormat pf, int pageIndex) + throws PrinterException { + if (pageIndex == 0) { + g.setColor(Color.RED); + g.drawRect((int)pf.getImageableX(), (int)pf.getImageableY(), + (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); + return Printable.PAGE_EXISTS; + } else { + return Printable.NO_SUCH_PAGE; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/print/PrinterJob/DlgAttrsBug.java Fri Apr 14 09:44:21 2017 -0700 @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2016, 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 8061258 + * @summary PrinterJob's native Print Dialog does not reflect + * specified Copies or Page Ranges + * @run main/manual DlgAttrsBug + */ +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.Copies; +import javax.print.attribute.standard.PageRanges; +import javax.print.attribute.standard.DialogTypeSelection; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + + +public class DlgAttrsBug implements Printable { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(DlgAttrsBug::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print Dialog does not " + + "reflect Copies or Page Ranges"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void printTest() { + PrinterJob job = PrinterJob.getPrinterJob(); + if (job.getPrintService() == null) { + System.out.println("No printers. Test cannot continue"); + return; + } + job.setPrintable(new DlgAttrsBug()); + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + aset.add(new Copies(5)); + aset.add(new PageRanges(3,4)); + aset.add(DialogTypeSelection.NATIVE); + job.printDialog(aset); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Visual inspection of print dialog is required.\n" + + " A print dialog will be shown.\n " + + " Please verify Copies 5 is selected.\n" + + " Also verify, Page Range is selected with " + + " from page 3 and to Page 4.\n" + + " If ok, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + } + + public int print(Graphics g, PageFormat pf, int pi) + throws PrinterException { + System.out.println("pi = " + pi); + if (pi >= 5) { + return NO_SUCH_PAGE; + } + g.drawString("Page : " + (pi+1), 200, 200); + return PAGE_EXISTS; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/Calendar/SupplementalJapaneseEraTest.java Fri Apr 14 09:44:21 2017 -0700 @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2017, 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 8054214 8173423 8177776 + * @summary Create an equivalent test case for JDK9's SupplementalJapaneseEraTest + * @library /lib/testlibrary + * @run testng SupplementalJapaneseEraTest + */ + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; +import java.text.SimpleDateFormat; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.JapaneseDate; +import java.time.chrono.JapaneseEra; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import static java.util.GregorianCalendar.*; +import java.util.Locale; +import java.util.Properties; +import java.util.TimeZone; + +import jdk.testlibrary.ProcessTools; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class SupplementalJapaneseEraTest { + private static final Locale WAREKI_LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese"); + private static final String NEW_ERA_NAME = "NewEra"; + private static final String NEW_ERA_ABBR = "N.E."; + private static final int NEW_ERA_YEAR = 200; + private static final int NEW_ERA_MONTH = FEBRUARY; + private static final int NEW_ERA_DAY = 11; + private static int errors = 0; + + @BeforeTest + public void prepareTestJDK() throws IOException { + Path src = Paths.get(System.getProperty("test.jdk")).toAbsolutePath(); + Path dst = Paths.get("testjava").toAbsolutePath(); + Files.walkFileTree(src, new CopyFileVisitor(src, dst)); + } + + @Test + public void invokeTestJDK() throws Throwable { + assertTrue(ProcessTools.executeCommand( + Paths.get("testjava", "bin", "java").toAbsolutePath().toString(), + "-cp", + System.getProperty("test.classes"), + "SupplementalJapaneseEraTest") + .getExitValue() == 0); + } + + public static void main(String[] args) { + testProperty(); + + if (errors != 0) { + throw new RuntimeException("test failed"); + } + } + + // copied from JDK9's test + private static void testProperty() { + Calendar jcal = new Calendar.Builder() + .setCalendarType("japanese") + .setFields(YEAR, 1, DAY_OF_YEAR, 1) + .build(); + Date firstDayOfEra = jcal.getTime(); + + jcal.set(ERA, jcal.get(ERA) - 1); // previous era + jcal.set(YEAR, 1); + jcal.set(DAY_OF_YEAR, 1); + Calendar cal = new GregorianCalendar(); + cal.setTimeInMillis(jcal.getTimeInMillis()); + cal.add(YEAR, 199); + int year = cal.get(YEAR); + + SimpleDateFormat sdf; + String expected, got; + + // test long era name + sdf = new SimpleDateFormat("GGGG y-MM-dd", WAREKI_LOCALE); + got = sdf.format(firstDayOfEra); + expected = NEW_ERA_NAME + " 1-02-11"; + if (!expected.equals(got)) { + System.err.printf("GGGG y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); + errors++; + } + + // test era abbreviation + sdf = new SimpleDateFormat("G y-MM-dd", WAREKI_LOCALE); + got = sdf.format(firstDayOfEra); + expected = NEW_ERA_ABBR+" 1-02-11"; + if (!expected.equals(got)) { + System.err.printf("G y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); + errors++; + } + + // confirm the gregorian year + sdf = new SimpleDateFormat("y", Locale.US); + int y = Integer.parseInt(sdf.format(firstDayOfEra)); + if (y != year) { + System.err.printf("Gregorian year: got=%d, expected=%d%n", y, year); + errors++; + } + + // test java.time.chrono.JapaneseEra + JapaneseDate jdate = JapaneseDate.of(year, 2, 11); + got = jdate.toString(); + expected = "Japanese " + NEW_ERA_NAME + " 1-02-11"; + if (!expected.equals(got)) { + System.err.printf("JapaneseDate: got=\"%s\", expected=\"%s\"%n", got, expected); + errors++; + } + JapaneseEra jera = jdate.getEra(); + got = jera.getDisplayName(TextStyle.FULL, Locale.US); + if (!NEW_ERA_NAME.equals(got)) { + System.err.printf("JapaneseEra (FULL): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_NAME); + errors++; + } + got = jera.getDisplayName(TextStyle.SHORT, Locale.US); + if (!NEW_ERA_NAME.equals(got)) { + System.err.printf("JapaneseEra (SHORT): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_NAME); + errors++; + } + got = jera.getDisplayName(TextStyle.NARROW, Locale.US); + if (!NEW_ERA_ABBR.equals(got)) { + System.err.printf("JapaneseEra (NARROW): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); + errors++; + } + got = jera.getDisplayName(TextStyle.NARROW_STANDALONE, Locale.US); + if (!NEW_ERA_ABBR.equals(got)) { + System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); + errors++; + } + + // test long/abbreviated names with java.time.format + got = new DateTimeFormatterBuilder() + .appendPattern("GGGG") + .appendLiteral(" ") + .appendPattern("G") + .toFormatter(Locale.US) + .withChronology(JapaneseChronology.INSTANCE) + .format(jdate); + expected = NEW_ERA_NAME + " " + NEW_ERA_ABBR; + if (!expected.equals(got)) { + System.err.printf("java.time formatter long/abbr names: got=\"%s\", expected=\"%s\"%n", got, expected); + errors++; + } + } + + private static class CopyFileVisitor extends SimpleFileVisitor<Path> { + private final Path copyFrom; + private final Path copyTo; + private final Path calProps = Paths.get("calendars.properties"); + private final String JA_CAL_KEY = "calendar.japanese.eras"; + + public CopyFileVisitor(Path copyFrom, Path copyTo) { + this.copyFrom = copyFrom; + this.copyTo = copyTo; + } + + @Override + public FileVisitResult preVisitDirectory(Path file, + BasicFileAttributes attrs) throws IOException { + Path relativePath = copyFrom.relativize(file); + Path destination = copyTo.resolve(relativePath); + if (!destination.toFile().exists()) { + Files.createDirectories(destination); + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + if (!file.toFile().isFile()) { + return FileVisitResult.CONTINUE; + } + Path relativePath = copyFrom.relativize(file); + Path destination = copyTo.resolve(relativePath); + if (relativePath.getFileName().equals(calProps)) { + modifyCalendarProperties(file, destination); + } else { + Files.copy(file, destination, StandardCopyOption.COPY_ATTRIBUTES); + } + return FileVisitResult.CONTINUE; + } + + private void modifyCalendarProperties(Path src, Path dst) throws IOException { + Properties p = new Properties(); + try (BufferedReader br = Files.newBufferedReader(src)) { + p.load(br); + } + + String eras = p.getProperty(JA_CAL_KEY); + if (eras != null) { + p.setProperty(JA_CAL_KEY, + eras + + "; name=" + SupplementalJapaneseEraTest.NEW_ERA_NAME + + ",abbr=" + SupplementalJapaneseEraTest.NEW_ERA_ABBR + + ",since=" + since()); + } + try (BufferedWriter bw = Files.newBufferedWriter(dst)) { + p.store(bw, "test calendars.properties for supplemental Japanese era"); + } + } + + private long since() { + return new Calendar.Builder() + .setCalendarType("japanese") + .setTimeZone(TimeZone.getTimeZone("GMT")) + .setDate(SupplementalJapaneseEraTest.NEW_ERA_YEAR, + SupplementalJapaneseEraTest.NEW_ERA_MONTH, + SupplementalJapaneseEraTest.NEW_ERA_DAY) + .build() + .getTimeInMillis(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/text/html/parser/Parser/HtmlCommentTagParseTest/HtmlCommentTagParseTest.java Fri Apr 14 09:44:21 2017 -0700 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2017, 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. +*/ + +import javax.swing.*; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; +import java.io.*; +import java.lang.reflect.InvocationTargetException; + +/* @test + @bug 8177450 + @summary javax.swing.text.html.parser.Parser parseScript ignores a character after commend end + @author Mikhail Cherkasov + @run main HtmlCommentTagParseTest +*/ +public class HtmlCommentTagParseTest { + private static volatile boolean failed = false; + public static void main(String[] args) throws IOException, InvocationTargetException, InterruptedException { + SwingUtilities.invokeAndWait(() -> { + MyParser cb = new MyParser(); + HTMLEditorKit htmlKit = new HTMLEditorKit(); + HTMLDocument htmlDoc = (HTMLDocument) + htmlKit.createDefaultDocument(); + FileReader reader = null; + try { + reader = new FileReader(getDirURL() + "test.html"); + htmlDoc.getParser().parse(reader, cb, true); + if(failed) { + throw new RuntimeException("Test failed"); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } + private static String getDirURL() { + return new File(System.getProperty("test.src", ".")).getAbsolutePath() + + File.separator; + } + + private static class MyParser extends HTMLEditorKit.ParserCallback { + @Override + public void handleError(String errorMsg, int pos) { + failed = errorMsg.contains("eof.script"); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/text/html/parser/Parser/HtmlCommentTagParseTest/test.html Fri Apr 14 09:44:21 2017 -0700 @@ -0,0 +1,5 @@ +<html> +<body> +<script><!-- --></script> +</body> +</html> \ No newline at end of file
--- a/test/sun/util/calendar/zi/tzdata/VERSION Tue Apr 04 11:57:35 2017 -0700 +++ b/test/sun/util/calendar/zi/tzdata/VERSION Fri Apr 14 09:44:21 2017 -0700 @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2017a +tzdata2017b
--- a/test/sun/util/calendar/zi/tzdata/africa Tue Apr 04 11:57:35 2017 -0700 +++ b/test/sun/util/calendar/zi/tzdata/africa Fri Apr 14 09:44:21 2017 -0700 @@ -443,18 +443,25 @@ # See Africa/Johannesburg. # Liberia -# From Paul Eggert (2006-03-22): -# In 1972 Liberia was the last country to switch -# from a UTC offset that was not a multiple of 15 or 20 minutes. -# Howse reports that it was in honor of their president's birthday. -# Shank & Pottenger report the date as May 1, whereas Howse reports Jan; -# go with Shanks & Pottenger. -# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and -# Whitman each report -0:44:30; go with the more precise figure. +# +# From Paul Eggert (2017-03-02): +# +# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30. +# +# In 1972 Liberia was the last country to switch from a UTC offset +# that was not a multiple of 15 or 20 minutes. The 1972 change was on +# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of: +# Presidential Papers: First year of the administration of +# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972. +# Monrovia: Executive Mansion. +# +# Use the abbreviation "MMT" before 1972, as the more-accurate numeric +# abbreviation "-004430" would be one byte over the POSIX limit. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Monrovia -0:43:08 - LMT 1882 -0:43:08 - MMT 1919 Mar # Monrovia Mean Time - -0:44:30 - -004430 1972 May + -0:44:30 - MMT 1972 Jan 7 # approximately MMT 0:00 - GMT ###############################################################################
--- a/test/sun/util/calendar/zi/tzdata/iso3166.tab Tue Apr 04 11:57:35 2017 -0700 +++ b/test/sun/util/calendar/zi/tzdata/iso3166.tab Fri Apr 14 09:44:21 2017 -0700 @@ -32,8 +32,8 @@ # All text uses UTF-8 encoding. The columns of the table are as follows: # # 1. ISO 3166-1 alpha-2 country code, current as of -# ISO 3166-1 Newsletter VI-16 (2013-07-11). See: Updates on ISO 3166 -# http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm +# ISO 3166-1 N905 (2016-11-15). See: Updates on ISO 3166-1 +# http://isotc.iso.org/livelink/livelink/Open/16944257 # 2. The usual English name for the coded region, # chosen so that alphabetic sorting of subsets produces helpful lists. # This is not the same as the English name in the ISO 3166 tables.
--- a/test/sun/util/calendar/zi/tzdata/northamerica Tue Apr 04 11:57:35 2017 -0700 +++ b/test/sun/util/calendar/zi/tzdata/northamerica Fri Apr 14 09:44:21 2017 -0700 @@ -3162,6 +3162,12 @@ # http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/ # http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/ +# From Steffen Thorsen (2017-03-12): +# We have received 4 mails from different people telling that Haiti +# has started DST again today, and this source seems to confirm that, +# I have not been able to find a more authoritative source: +# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Haiti 1983 only - May 8 0:00 1:00 D Rule Haiti 1984 1987 - Apr lastSun 0:00 1:00 D @@ -3174,6 +3180,8 @@ Rule Haiti 2005 2006 - Oct lastSun 0:00 0 S Rule Haiti 2012 2015 - Mar Sun>=8 2:00 1:00 D Rule Haiti 2012 2015 - Nov Sun>=1 2:00 0 S +Rule Haiti 2017 max - Mar Sun>=8 2:00 1:00 D +Rule Haiti 2017 max - Nov Sun>=1 2:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Port-au-Prince -4:49:20 - LMT 1890 -4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT