diff --git a/make/data/tzdata/VERSION b/make/data/tzdata/VERSION index 8ab96a77e71215f15dee92049dbed3fa6ae8047f..1c96650f23131a13d06063228f25f003d5c2e951 100644 --- a/make/data/tzdata/VERSION +++ b/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2014a +tzdata2014b diff --git a/make/data/tzdata/africa b/make/data/tzdata/africa index 82d14a4a14d11c3325fbf1bcf52f2fd2a82cb90e..3198e1cc2094c44feac1e99a7e87eddde747960e 100644 --- a/make/data/tzdata/africa +++ b/make/data/tzdata/africa @@ -891,7 +891,10 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # Another source (specifying the time for start and end in the decree): # http://www.lemag.ma/Heure-d-ete-au-Maroc-jusqu-au-27-octobre_a75620.html -# From Paul Eggert (2013-10-03): +# From Sebastien Willemijns (2014-03-18): +# http://www.afriquinfos.com/articles/2014/3/18/maroc-heure-dete-avancez-tous-horloges-247891.asp + +# From Paul Eggert (2014-03-19): # To estimate what the Moroccan government will do in future years, # transition dates for 2014 through 2038 were determined by running # the following program under GNU Emacs 24.3: diff --git a/make/data/tzdata/antarctica b/make/data/tzdata/antarctica index f30cf747f10780b792d0dd25fdff1854c89940bd..e31bada94fb711b41f7bfba27d655c662d9b614e 100644 --- a/make/data/tzdata/antarctica +++ b/make/data/tzdata/antarctica @@ -253,24 +253,41 @@ Zone Antarctica/Syowa 0 - zzz 1957 Jan 29 # year-round base # Scott Base, Ross Island, since 1957-01. # See Pacific/Auckland. -# -# These rules for New Zealand are stolen from the 'australasia' file. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NZAQ 1974 only - Nov 3 2:00s 1:00 D -Rule NZAQ 1975 1988 - Oct lastSun 2:00s 1:00 D -Rule NZAQ 1989 only - Oct 8 2:00s 1:00 D -Rule NZAQ 1990 2006 - Oct Sun>=1 2:00s 1:00 D -Rule NZAQ 1975 only - Feb 23 2:00s 0 S -Rule NZAQ 1976 1989 - Mar Sun>=1 2:00s 0 S -Rule NZAQ 1990 2007 - Mar Sun>=15 2:00s 0 S -Rule NZAQ 2007 max - Sep lastSun 2:00s 1:00 D -Rule NZAQ 2008 max - Apr Sun>=1 2:00s 0 S # Norway - territories # Bouvet (never inhabited) # # claims # Peter I Island (never inhabited) +# +# year-round base +# Troll, Queen Maud Land, -720041+0023206, since 2005-02-12 +# +# From Paul-Inge Flakstad (2014-03-10): +# I recently had a long dialog about this with the developer of timegenie.com. +# In the absence of specific dates, he decided to choose some likely ones: +# GMT +1 - From March 1 to the last Sunday in March +# GMT +2 - From the last Sunday in March until the last Sunday in October +# GMT +1 - From the last Sunday in October until November 7 +# GMT +0 - From November 7 until March 1 +# The dates for switching to and from UTC+0 will probably not be absolutely +# correct, but they should be quite close to the actual dates. +# +# From Paul Eggert (2014-03-21): +# The CET-switching Troll rules require zic from tzcode 2014b or later, so as +# suggested by Bengt-Inge Larsson comment them out for now, and approximate +# with only UTC and CEST. Uncomment them when 2014b is more prevalent. +# +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +#Rule Troll 2005 max - Mar 1 1:00u 1:00 CET +Rule Troll 2005 max - Mar lastSun 1:00u 2:00 CEST +#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 CET +#Rule Troll 2004 max - Nov 7 1:00u 0:00 UTC +# Remove the following line when uncommenting the above '#Rule' lines. +Rule Troll 2004 max - Oct lastSun 1:00u 0:00 UTC +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone Antarctica/Troll 0 - zzz 2005 Feb 12 + 0:00 Troll %s # Poland - year-round base # Arctowski, King George Island, -620945-0582745, since 1977 diff --git a/make/data/tzdata/australasia b/make/data/tzdata/australasia index a0e8b5a2ce97edbf13e8d684723ab649f0b53047..94c9adb912c599e62ad8c29e7f4422135bec1a05 100644 --- a/make/data/tzdata/australasia +++ b/make/data/tzdata/australasia @@ -786,14 +786,29 @@ Zone Pacific/Funafuti 11:56:52 - LMT 1901 # Johnston # -# From Paul Eggert (2013-09-03): +# From Paul Eggert (2014-03-11): +# Sometimes Johnston kept Hawaii time, and sometimes it was an hour behind. +# Details are uncertain. We have no data for Johnston after 1970, so +# treat it like Hawaii for now. +# # In his memoirs of June 6th to October 4, 1945 # (2005), Herbert C. Bach writes, # "We started our letdown to Kwajalein Atoll and landed there at 5:00 AM # Johnston time, 1:30 AM Kwajalein time." This was in June 1945, and # confirms that Johnston kept the same time as Honolulu in summer 1945. -# We have no better information, so for now, assume this has been true -# indefinitely into the past. +# +# From Lyle McElhaney (2014-03-11): +# [W]hen JI was being used for that [atomic bomb] testing, the time being used +# was not Hawaiian time but rather the same time being used on the ships, +# which had a GMT offset of -11 hours. This apparently applied to at least the +# time from Operation Newsreel (Hardtack I/Teak shot, 1958-08-01) to the last +# Operation Fishbowl shot (Tightrope, 1962-11-04).... [See] Herman Hoerlin, +# "The United States High-Altitude Test Experience: A Review Emphasizing the +# Impact on the Environment", Los Alamos LA-6405, Oct 1976 +# . +# See the table on page 4 where he lists GMT and local times for the tests; a +# footnote for the JI tests reads that local time is "JI time = Hawaii Time +# Minus One Hour". # # See 'northamerica' for Pacific/Johnston. diff --git a/make/data/tzdata/europe b/make/data/tzdata/europe index 585e64d14fa713a22cae5be7bf2bb7025cc02d0f..2b0c5613e6098a5aaea07f68e2e5afabfe93daad 100644 --- a/make/data/tzdata/europe +++ b/make/data/tzdata/europe @@ -2986,7 +2986,11 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 # Assume it happened in March by not changing the clocks. 3:00 Russia MSK/MSD 1997 3:00 - MSK 1997 Mar lastSun 1:00u - 2:00 EU EE%sT +# From Alexander Krivenyshev (2014-03-17): +# time change at 2:00 (2am) on March 30, 2014 +# http://vz.ru/news/2014/3/17/677464.html + 2:00 EU EE%sT 2014 Mar 30 2:00 + 4:00 - MSK # Vatican City # See Europe/Rome. diff --git a/make/data/tzdata/leapseconds b/make/data/tzdata/leapseconds index faf5319d408b2f152d72b442ed27bcad95c73d9d..b423135b942d092c4a8f24eaac19f3c8db1bf021 100644 --- a/make/data/tzdata/leapseconds +++ b/make/data/tzdata/leapseconds @@ -20,7 +20,7 @@ # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. - +# # Allowance for leapseconds added to each timezone file. # This file is in the public domain. diff --git a/make/data/tzdata/zone.tab b/make/data/tzdata/zone.tab index b34cdb0dc7da153e903d33b908e637d34a897dbf..7cec627fd95862053bc8c9cd5e991a1309a42f6d 100644 --- a/make/data/tzdata/zone.tab +++ b/make/data/tzdata/zone.tab @@ -74,6 +74,7 @@ AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I +AQ -720041+0023206 Antarctica/Troll Troll Station, Queen Maud Land AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF) AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN) @@ -366,6 +367,7 @@ RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad RU +5545+03735 Europe/Moscow Moscow+00 - west Russia RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea RU +5312+05009 Europe/Samara Moscow+00 - Samara, Udmurtia +RU +4457+03406 Europe/Simferopol Moscow+00 - Crimea RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk @@ -421,7 +423,6 @@ TZ -0648+03917 Africa/Dar_es_Salaam UA +5026+03031 Europe/Kiev most locations UA +4837+02218 Europe/Uzhgorod Ruthenia UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk -UA +4457+03406 Europe/Simferopol central Crimea UG +0019+03225 Africa/Kampala UM +1645-16931 Pacific/Johnston Johnston Atoll UM +2813-17722 Pacific/Midway Midway Islands diff --git a/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java index 39c4acce321d95b8be321ee7bbdfd14d96ab2ee6..cfa3b08d3be18edf9fa1eb52c60145c662838666 100644 --- a/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -1266,64 +1266,70 @@ public class AquaFileChooserUI extends FileChooserUI { /** * Data model for a type-face selection combo-box. */ - protected class FilterComboBoxModel extends DefaultListModel implements ComboBoxModel, PropertyChangeListener { - int selectedIndex = -1; - + protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, + PropertyChangeListener { + protected FileFilter[] filters; protected FilterComboBoxModel() { super(); - final FileFilter filters[] = getFileChooser().getChoosableFileFilters(); - for (int i = 0; i < filters.length; i++) { - this.add(i, filters[i]); - } + filters = getFileChooser().getChoosableFileFilters(); } - public void propertyChange(final PropertyChangeEvent e) { - final String prop = e.getPropertyName(); - if (prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { - this.clear(); - final FileFilter filters[] = (FileFilter[])e.getNewValue(); - - for (int i = 0; i < filters.length; i++) { - this.add(i, filters[i]); - } - + public void propertyChange(PropertyChangeEvent e) { + String prop = e.getPropertyName(); + if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { + filters = (FileFilter[]) e.getNewValue(); fireContentsChanged(this, -1, -1); } else if (prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY) { - final FileFilter currentFilter = (FileFilter)e.getNewValue(); - FileFilter filters[] = getFileChooser().getChoosableFileFilters(); - - boolean found = false; - if (currentFilter != null) { - for (final FileFilter element : filters) { - if (element == currentFilter) { - found = true; - } - } - if (found == false) { - getFileChooser().addChoosableFileFilter(currentFilter); - } - } - - filters = getFileChooser().getChoosableFileFilters(); - setSelectedItem(e.getNewValue()); + fireContentsChanged(this, -1, -1); } } - public void setSelectedItem(final Object filter) { - if (filter != null) { - selectedIndex = this.indexOf(filter); + public void setSelectedItem(Object filter) { + if(filter != null) { + getFileChooser().setFileFilter((FileFilter) filter); fireContentsChanged(this, -1, -1); } } public Object getSelectedItem() { - final Object returnValue = null; + // Ensure that the current filter is in the list. + // NOTE: we shouldnt' have to do this, since JFileChooser adds + // the filter to the choosable filters list when the filter + // is set. Lets be paranoid just in case someone overrides + // setFileFilter in JFileChooser. + FileFilter currentFilter = getFileChooser().getFileFilter(); + boolean found = false; + if(currentFilter != null) { + for (FileFilter filter : filters) { + if (filter == currentFilter) { + found = true; + } + } + if(found == false) { + getFileChooser().addChoosableFileFilter(currentFilter); + } + } + return getFileChooser().getFileFilter(); + } - if (this.size() > 0) { - if ((selectedIndex != -1) && (selectedIndex < size())) { return this.get(selectedIndex); } + public int getSize() { + if(filters != null) { + return filters.length; + } else { + return 0; } + } - return returnValue; + public FileFilter getElementAt(int index) { + if(index > getSize() - 1) { + // This shouldn't happen. Try to recover gracefully. + return getFileChooser().getFileFilter(); + } + if(filters != null) { + return filters[index]; + } else { + return null; + } } } diff --git a/src/macosx/classes/com/apple/laf/AquaIcon.java b/src/macosx/classes/com/apple/laf/AquaIcon.java index e40d066ac22654148cf4ab2821c68931730a543a..4af5599b600c7dbbdd837b8a7549ad5a9707b32a 100644 --- a/src/macosx/classes/com/apple/laf/AquaIcon.java +++ b/src/macosx/classes/com/apple/laf/AquaIcon.java @@ -44,7 +44,8 @@ public class AquaIcon { } static UIResource getIconFor(final JRSUIControlSpec spec, final int width, final int height) { - return new CachableJRSUIIcon(width, height) { + return new ScalingJRSUIIcon(width, height) { + @Override public void initIconPainter(final AquaPainter painter) { spec.initIconPainter(painter); } @@ -128,35 +129,12 @@ public class AquaIcon { if (image != null) return image; if (!GraphicsEnvironment.isHeadless()) { - image = getOptimizedImage(); + image = createImage(); } return image; } - private Image getOptimizedImage() { - final Image img = createImage(); - // TODO: no RuntimeOptions for now - //if (RuntimeOptions.getRenderer(null) != RuntimeOptions.Sun) return img; - return getProgressiveOptimizedImage(img, getIconWidth(), getIconHeight()); - } - - static Image getProgressiveOptimizedImage(final Image img, final int w, final int h) { - if (img == null) return null; - - final int halfImgW = img.getWidth(null) / 2; - final int halfImgH = img.getHeight(null) / 2; - if (w * 2 > halfImgW && h * 2 > halfImgH) return img; - - final BufferedImage halfImage = new BufferedImage(halfImgW, halfImgH, BufferedImage.TYPE_INT_ARGB); - final Graphics g = halfImage.getGraphics(); - ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g.drawImage(img, 0, 0, halfImgW, halfImgH, null); - g.dispose(); - - return getProgressiveOptimizedImage(halfImage, w, h); - } - abstract Image createImage(); public boolean hasIconRef() { @@ -189,24 +167,50 @@ public class AquaIcon { } - static abstract class CachableJRSUIIcon extends CachingScalingIcon implements UIResource { - public CachableJRSUIIcon(final int width, final int height) { - super(width, height); + static abstract class ScalingJRSUIIcon implements Icon, UIResource { + final int width; + final int height; + + public ScalingJRSUIIcon(final int width, final int height) { + this.width = width; + this.height = height; } - Image createImage() { - final AquaPainter painter = AquaPainter.create(JRSUIState.getInstance()); + @Override + public void paintIcon(final Component c, Graphics g, + final int x, final int y) { + if (GraphicsEnvironment.isHeadless()) { + return; + } + + g = g.create(); + + if (g instanceof Graphics2D) { + // improves icon rendering quality in Quartz + ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY); + } + + final AquaPainter painter = + AquaPainter.create(JRSUIState.getInstance()); initIconPainter(painter); - final BufferedImage img = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB_PRE); - final Graphics g = img.getGraphics(); - g.setClip(new Rectangle(0, 0, getIconWidth(), getIconHeight())); - painter.paint(g, null, 0, 0, getIconWidth(), getIconHeight()); + g.setClip(new Rectangle(x, y, width, height)); + painter.paint(g, c, x, y, width, height); g.dispose(); - return img; } public abstract void initIconPainter(final AquaPainter painter); + + @Override + public int getIconWidth() { + return width; + } + + @Override + public int getIconHeight() { + return height; + } } static class FileIcon extends CachingScalingIcon { diff --git a/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java b/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java index dd0267ce3fca9cbb6d728045c60d07c6b96c399d..5dbefe389dbb107d44563cd8f2ece1b93af9ce96 100644 --- a/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java +++ b/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java @@ -786,8 +786,9 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo } static final RecyclableSingleton RESIZE_ICON = new RecyclableSingleton() { + @Override protected Icon getInstance() { - return new AquaIcon.CachableJRSUIIcon(11, 11) { + return new AquaIcon.ScalingJRSUIIcon(11, 11) { public void initIconPainter(final AquaPainter iconState) { iconState.state.set(Widget.GROW_BOX_TEXTURED); iconState.state.set(WindowType.UTILITY); diff --git a/src/macosx/classes/com/apple/laf/AquaPainter.java b/src/macosx/classes/com/apple/laf/AquaPainter.java index 38884ac7e8f3775bd69c9360a7fc6955a5859b83..a5bc8fb25dd67924c314945f770027612e4ea84c 100644 --- a/src/macosx/classes/com/apple/laf/AquaPainter.java +++ b/src/macosx/classes/com/apple/laf/AquaPainter.java @@ -148,34 +148,44 @@ abstract class AquaPainter { return; } - int scale = 1; - if (g instanceof SunGraphics2D) { - scale = ((SunGraphics2D) g).surfaceData.getDefaultScale(); - } final GraphicsConfiguration config = g.getDeviceConfiguration(); final ImageCache cache = ImageCache.getInstance(); - final int imgW = bounds.width * scale; - final int imgH = bounds.height * scale; + final int width = bounds.width; + final int height = bounds.height; AquaPixelsKey key = new AquaPixelsKey(config, - imgW, imgH, scale, controlState); - BufferedImage img = (BufferedImage) cache.getImage(key); + width, height, bounds, controlState); + Image img = (BufferedImage) cache.getImage(key); if (img == null) { - img = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_ARGB_PRE); + + Image baseImage = createImage(width, height, bounds, control, + controlState); + + img = new MultiResolutionBufferedImage(baseImage, + (rvWidth, rvHeight) -> createImage(rvWidth, rvHeight, + bounds, control, controlState)); + if (!controlState.is(JRSUIConstants.Animating.YES)) { cache.setImage(key, img); } - - final WritableRaster raster = img.getRaster(); - final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer(); - - control.set(controlState); - control.paint(SunWritableRaster.stealData(buffer, 0), - imgW, imgH, 0, 0, bounds.width, bounds.height); - SunWritableRaster.markDirty(buffer); } g.drawImage(img, bounds.x, bounds.y, bounds.width, bounds.height, null); } + + private static Image createImage(int imgW, int imgH, final Rectangle bounds, + final JRSUIControl control, JRSUIState controlState) { + BufferedImage img = new BufferedImage(imgW, imgH, + BufferedImage.TYPE_INT_ARGB_PRE); + + final WritableRaster raster = img.getRaster(); + final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer(); + + control.set(controlState); + control.paint(SunWritableRaster.stealData(buffer, 0), + imgW, imgH, 0, 0, bounds.width, bounds.height); + SunWritableRaster.markDirty(buffer); + return img; + } } private static class AquaPixelsKey implements ImageCache.PixelsKey { @@ -187,17 +197,17 @@ abstract class AquaPainter { private final GraphicsConfiguration config; private final int w; private final int h; - private final int scale; + private final Rectangle bounds; private final JRSUIState state; AquaPixelsKey(final GraphicsConfiguration config, - final int w, final int h, final int scale, + final int w, final int h, final Rectangle bounds, final JRSUIState state) { this.pixelCount = w * h; this.config = config; this.w = w; this.h = h; - this.scale = scale; + this.bounds = bounds; this.state = state; this.hash = hash(); } @@ -210,7 +220,7 @@ abstract class AquaPainter { int hash = config != null ? config.hashCode() : 0; hash = 31 * hash + w; hash = 31 * hash + h; - hash = 31 * hash + scale; + hash = 31 * hash + bounds.hashCode(); hash = 31 * hash + state.hashCode(); return hash; } @@ -225,7 +235,7 @@ abstract class AquaPainter { if (obj instanceof AquaPixelsKey) { AquaPixelsKey key = (AquaPixelsKey) obj; return config == key.config && w == key.w && h == key.h - && scale == key.scale && state.equals(key.state); + && bounds.equals(key.bounds) && state.equals(key.state); } return false; } diff --git a/src/share/classes/java/beans/Introspector.java b/src/share/classes/java/beans/Introspector.java index 61745dd9efa655af4b6deb6eefe5633304623823..427a28ea2b807bf1f559133d7b69ddda84c77a1d 100644 --- a/src/share/classes/java/beans/Introspector.java +++ b/src/share/classes/java/beans/Introspector.java @@ -806,7 +806,7 @@ public class Introspector { } private static boolean isAssignable(Class current, Class candidate) { - return current == null ? candidate == null : current.isAssignableFrom(candidate); + return ((current == null) || (candidate == null)) ? current == candidate : current.isAssignableFrom(candidate); } /** diff --git a/src/share/classes/java/time/Clock.java b/src/share/classes/java/time/Clock.java index cd90822925f78a31259f509877a40e0303784672..b1127848bed04e54abd7748fad48f50c1d8cdd6a 100644 --- a/src/share/classes/java/time/Clock.java +++ b/src/share/classes/java/time/Clock.java @@ -104,7 +104,7 @@ import java.util.TimeZone; * resolution clock if one is available. * * @implSpec - * This abstract class must be implemented with care to ensure other operate correctly. + * This abstract class must be implemented with care to ensure other classes operate correctly. * All implementations that can be instantiated must be final, immutable and thread-safe. *

* The principal methods are defined to allow the throwing of an exception. diff --git a/src/share/classes/java/time/Duration.java b/src/share/classes/java/time/Duration.java index 02b882ca40ea058f02873364d8a2f71478fc2479..c53afe3ebcb466a91e2c6d5ba7b1eb1618b52be1 100644 --- a/src/share/classes/java/time/Duration.java +++ b/src/share/classes/java/time/Duration.java @@ -1326,6 +1326,7 @@ public final class Duration /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/Instant.java b/src/share/classes/java/time/Instant.java index d91e1c865686f4a7941cb4c5bfa2f7a68fe41465..1b944a50c3dea12ef8af45b1dce9e5bcd844bf29 100644 --- a/src/share/classes/java/time/Instant.java +++ b/src/share/classes/java/time/Instant.java @@ -100,11 +100,6 @@ import java.util.Objects; * This class models a single instantaneous point on the time-line. * This might be used to record event time-stamps in the application. *

- * For practicality, the instant is stored with some constraints. - * The measurable time-line is restricted to the number of seconds that can be held - * in a {@code long}. This is greater than the current estimated age of the universe. - * The instant is stored to nanosecond resolution. - *

* The range of an instant requires the storage of a number larger than a {@code long}. * To achieve this, the class stores a {@code long} representing epoch-seconds and an * {@code int} representing nanosecond-of-second, which will always be between 0 and 999,999,999. @@ -1348,6 +1343,7 @@ public final class Instant /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/LocalDate.java b/src/share/classes/java/time/LocalDate.java index c8ee89c87c50c0559403f7d09bad8cff0773a447..17b3b24c0ea7255c248fb47492602e5452205c47 100644 --- a/src/share/classes/java/time/LocalDate.java +++ b/src/share/classes/java/time/LocalDate.java @@ -2053,6 +2053,7 @@ public final class LocalDate /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/LocalDateTime.java b/src/share/classes/java/time/LocalDateTime.java index f9975d82329236d22d17bc4d19944d1c6e4fe57b..86633b8416541c98e6edbabff17f0c1a46f7d363 100644 --- a/src/share/classes/java/time/LocalDateTime.java +++ b/src/share/classes/java/time/LocalDateTime.java @@ -1986,6 +1986,7 @@ public final class LocalDateTime /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/LocalTime.java b/src/share/classes/java/time/LocalTime.java index 08a06317413926d258808b269e845801655ed053..0fcf89d26a34691747b9e61470add329bcfb4742 100644 --- a/src/share/classes/java/time/LocalTime.java +++ b/src/share/classes/java/time/LocalTime.java @@ -838,9 +838,9 @@ public final class LocalTime case NANO_OF_SECOND: return withNano((int) newValue); case NANO_OF_DAY: return LocalTime.ofNanoOfDay(newValue); case MICRO_OF_SECOND: return withNano((int) newValue * 1000); - case MICRO_OF_DAY: return plusNanos((newValue - toNanoOfDay() / 1000) * 1000); + case MICRO_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000); case MILLI_OF_SECOND: return withNano((int) newValue * 1000_000); - case MILLI_OF_DAY: return plusNanos((newValue - toNanoOfDay() / 1000_000) * 1000_000); + case MILLI_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000_000); case SECOND_OF_MINUTE: return withSecond((int) newValue); case SECOND_OF_DAY: return plusSeconds(newValue - toSecondOfDay()); case MINUTE_OF_HOUR: return withMinute((int) newValue); @@ -1638,6 +1638,7 @@ public final class LocalTime /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/MonthDay.java b/src/share/classes/java/time/MonthDay.java index 2339cad53974dd6ec3a9166f4f58fb412a47e67a..5b7844fd468008c381da3146069194d4f4d02d9e 100644 --- a/src/share/classes/java/time/MonthDay.java +++ b/src/share/classes/java/time/MonthDay.java @@ -771,6 +771,7 @@ public final class MonthDay /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/OffsetDateTime.java b/src/share/classes/java/time/OffsetDateTime.java index caecddca0f4ac619fc20ed4dd5d70e871c4bbca9..cd0eff6e56778ad4df9302d79947ffac7fd93034 100644 --- a/src/share/classes/java/time/OffsetDateTime.java +++ b/src/share/classes/java/time/OffsetDateTime.java @@ -1925,6 +1925,7 @@ public final class OffsetDateTime /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/OffsetTime.java b/src/share/classes/java/time/OffsetTime.java index 466cf5ae6393912a09c655e212dce22efb495a92..32a7187d0f50a6c8b87f08b9317fbdf2cc289796 100644 --- a/src/share/classes/java/time/OffsetTime.java +++ b/src/share/classes/java/time/OffsetTime.java @@ -1396,6 +1396,7 @@ public final class OffsetTime /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/Period.java b/src/share/classes/java/time/Period.java index ff6db0885f07cad531db18efbec53634d9ba9852..6087618ef9c2698c5e8e7f08e5e271001a2221d7 100644 --- a/src/share/classes/java/time/Period.java +++ b/src/share/classes/java/time/Period.java @@ -1058,6 +1058,7 @@ public final class Period /** * Defend against malicious streams. * + * @param s the stream to read * @throws java.io.InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/Year.java b/src/share/classes/java/time/Year.java index cc68951351b19bfdec8fb31eba20f337e52b4574..ff8528aef8f48ea9ae43fc980d6e009870fa4258 100644 --- a/src/share/classes/java/time/Year.java +++ b/src/share/classes/java/time/Year.java @@ -1104,6 +1104,7 @@ public final class Year /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/YearMonth.java b/src/share/classes/java/time/YearMonth.java index e5f42100ac0756faf65995d721f95ad84e479525..97f66de2903f1d228c8d61199e1b03817b85fda1 100644 --- a/src/share/classes/java/time/YearMonth.java +++ b/src/share/classes/java/time/YearMonth.java @@ -1230,6 +1230,7 @@ public final class YearMonth /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/ZoneId.java b/src/share/classes/java/time/ZoneId.java index 9b8ebc7267ac2725805cfb305d65b4ac5c6d8c43..16f8bf210c6de8607995d0e70c2887ba4e861748 100644 --- a/src/share/classes/java/time/ZoneId.java +++ b/src/share/classes/java/time/ZoneId.java @@ -624,6 +624,7 @@ public abstract class ZoneId implements Serializable { /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/ZoneOffset.java b/src/share/classes/java/time/ZoneOffset.java index efbdec9a934bd31baaf6d31b7a354905c8fc618a..10bd5446e0b06cc320e9b03a7972720d5c4e0160 100644 --- a/src/share/classes/java/time/ZoneOffset.java +++ b/src/share/classes/java/time/ZoneOffset.java @@ -769,6 +769,7 @@ public final class ZoneOffset /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/ZoneRegion.java b/src/share/classes/java/time/ZoneRegion.java index 5349b305ac79f34b2b446b2a053c7fd21e3a96a2..83f0b43d7752062907eeae2bc0b8df16ef14d783 100644 --- a/src/share/classes/java/time/ZoneRegion.java +++ b/src/share/classes/java/time/ZoneRegion.java @@ -196,6 +196,7 @@ final class ZoneRegion extends ZoneId implements Serializable { /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/ZonedDateTime.java b/src/share/classes/java/time/ZonedDateTime.java index b1342be5e475454eecf92faa6e2cb93981e29aea..752756bb78b9662cfa4b408a89cb7f0227eaaa79 100644 --- a/src/share/classes/java/time/ZonedDateTime.java +++ b/src/share/classes/java/time/ZonedDateTime.java @@ -2225,6 +2225,7 @@ public final class ZonedDateTime /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/AbstractChronology.java b/src/share/classes/java/time/chrono/AbstractChronology.java index 8b3559135a5e2a34c1782cd4c06c0a4ab80601f0..c2e91d7f5f88321cb58fc70eaca4dea66158f18c 100644 --- a/src/share/classes/java/time/chrono/AbstractChronology.java +++ b/src/share/classes/java/time/chrono/AbstractChronology.java @@ -766,6 +766,7 @@ public abstract class AbstractChronology implements Chronology { /** * Defend against malicious streams. * + * @param s the stream to read * @throws java.io.InvalidObjectException always */ private void readObject(ObjectInputStream s) throws ObjectStreamException { diff --git a/src/share/classes/java/time/chrono/ChronoLocalDate.java b/src/share/classes/java/time/chrono/ChronoLocalDate.java index baa7b69348cc7489c2f056661d4e13c47d04144e..6fe6a4578a9fec840e178538ed3b15ebea8d2c61 100644 --- a/src/share/classes/java/time/chrono/ChronoLocalDate.java +++ b/src/share/classes/java/time/chrono/ChronoLocalDate.java @@ -101,19 +101,12 @@ import java.util.Objects; *

When to use this interface

* The design of the API encourages the use of {@code LocalDate} rather than this * interface, even in the case where the application needs to deal with multiple - * calendar systems. The rationale for this is explored in the following documentation. + * calendar systems. *

- * The primary use case where this interface should be used is where the generic - * type parameter {@code } is fully defined as a specific chronology. - * In that case, the assumptions of that chronology are known at development - * time and specified in the code. - *

- * When the chronology is defined in the generic type parameter as ? or otherwise - * unknown at development time, the rest of the discussion below applies. - *

- * To emphasize the point, declaring a method signature, field or variable as this - * interface type can initially seem like the sensible way to globalize an application, - * however it is usually the wrong approach. + * This concept can seem surprising at first, as the natural way to globalize an + * application might initially appear to be to abstract the calendar system. + * However, as explored below, abstracting the calendar system is usually the wrong + * approach, resulting in logic errors and hard to find bugs. * As such, it should be considered an application-wide architectural decision to choose * to use this interface as opposed to {@code LocalDate}. * diff --git a/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java b/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java index 21a8548115e7715ea982ca6fdbf70a9118b6e005..ac5f7b4bfe344ee46aa15b460236c5ce7c055bc8 100644 --- a/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java +++ b/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java @@ -416,6 +416,7 @@ final class ChronoLocalDateTimeImpl /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/ChronoPeriodImpl.java b/src/share/classes/java/time/chrono/ChronoPeriodImpl.java index e0ee43400edda40232a17ae73ebdccc9f2b6c766..911144d5b0484505cfc75cb3c6f0149f9e39527b 100644 --- a/src/share/classes/java/time/chrono/ChronoPeriodImpl.java +++ b/src/share/classes/java/time/chrono/ChronoPeriodImpl.java @@ -376,6 +376,7 @@ final class ChronoPeriodImpl /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws ObjectStreamException { diff --git a/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java b/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java index 79f3423c5b2bae381ad734a3cfa39af9fc95256f..abd21eecaf071bb88fd9b0303208d47334f23e6a 100644 --- a/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java +++ b/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java @@ -340,6 +340,7 @@ final class ChronoZonedDateTimeImpl /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/HijrahChronology.java b/src/share/classes/java/time/chrono/HijrahChronology.java index 821ff9f5012f72926fba982786184908e8a10652..3be442cecb7b624aff5d436251baa0d11a701a52 100644 --- a/src/share/classes/java/time/chrono/HijrahChronology.java +++ b/src/share/classes/java/time/chrono/HijrahChronology.java @@ -1096,6 +1096,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/HijrahDate.java b/src/share/classes/java/time/chrono/HijrahDate.java index 9ab791ce8e59109c845f5f1f2dd8c0f216a506cd..9d5059eba2081a693f3699029344edeeea49f95c 100644 --- a/src/share/classes/java/time/chrono/HijrahDate.java +++ b/src/share/classes/java/time/chrono/HijrahDate.java @@ -654,6 +654,7 @@ public final class HijrahDate /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/IsoChronology.java b/src/share/classes/java/time/chrono/IsoChronology.java index c0936b0f292a0b9a97ab27b79e570b1d663a9b24..f84c1c87671f0a4a814a048cc06609ed637b08b5 100644 --- a/src/share/classes/java/time/chrono/IsoChronology.java +++ b/src/share/classes/java/time/chrono/IsoChronology.java @@ -604,6 +604,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/JapaneseChronology.java b/src/share/classes/java/time/chrono/JapaneseChronology.java index b1dbf53de821ec37ffcc7c62afab47cb5ed291cd..7845088eb7eb392a5a65a5e384ddd80240d6f61c 100644 --- a/src/share/classes/java/time/chrono/JapaneseChronology.java +++ b/src/share/classes/java/time/chrono/JapaneseChronology.java @@ -525,6 +525,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/JapaneseDate.java b/src/share/classes/java/time/chrono/JapaneseDate.java index 5c7e545042ad7f6cbd50fc534e87a8b06a697331..0c1a876eae2e07e82cc9d6b2c3212f0042ae0bd2 100644 --- a/src/share/classes/java/time/chrono/JapaneseDate.java +++ b/src/share/classes/java/time/chrono/JapaneseDate.java @@ -716,6 +716,7 @@ public final class JapaneseDate /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/JapaneseEra.java b/src/share/classes/java/time/chrono/JapaneseEra.java index f31597e02f9f36a51ccd428b3b299458d016cd29..0187565869fb8fa6f18f06f7b514ed8d3cbe43a1 100644 --- a/src/share/classes/java/time/chrono/JapaneseEra.java +++ b/src/share/classes/java/time/chrono/JapaneseEra.java @@ -357,6 +357,7 @@ public final class JapaneseEra /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/MinguoChronology.java b/src/share/classes/java/time/chrono/MinguoChronology.java index f7ee55789fd23c293ccd8f1ab68cd1f8dbc5c2d0..1fda0e415d4cbbb27c847ad5564cdc4ff1105edd 100644 --- a/src/share/classes/java/time/chrono/MinguoChronology.java +++ b/src/share/classes/java/time/chrono/MinguoChronology.java @@ -355,6 +355,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/MinguoDate.java b/src/share/classes/java/time/chrono/MinguoDate.java index 2cb49b6b600927608f4daf1ae00050e848d650a7..ba25c8da018be798bfebe1bf710d17bf4bc1aefd 100644 --- a/src/share/classes/java/time/chrono/MinguoDate.java +++ b/src/share/classes/java/time/chrono/MinguoDate.java @@ -478,6 +478,7 @@ public final class MinguoDate /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java b/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java index 057c3baaefb68d06101b80708015c3d2e19e6afd..87bc10047ecec66b1ee98163f332b7017941067b 100644 --- a/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java +++ b/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java @@ -391,6 +391,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/chrono/ThaiBuddhistDate.java b/src/share/classes/java/time/chrono/ThaiBuddhistDate.java index 9e8b88d3465f583f62f515cf9235b147b5926f68..f403317b11e0bd49b411409db4e9558f046bac2b 100644 --- a/src/share/classes/java/time/chrono/ThaiBuddhistDate.java +++ b/src/share/classes/java/time/chrono/ThaiBuddhistDate.java @@ -478,6 +478,7 @@ public final class ThaiBuddhistDate /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/format/DateTimeFormatter.java b/src/share/classes/java/time/format/DateTimeFormatter.java index 4109d20e590ebbde2d46066fba56a9c8c5cbe576..9f5eba72f9b93923e892ec7b8e7869e5ad2d4446 100644 --- a/src/share/classes/java/time/format/DateTimeFormatter.java +++ b/src/share/classes/java/time/format/DateTimeFormatter.java @@ -344,10 +344,7 @@ import java.util.Set; * Fraction: Outputs the nano-of-second field as a fraction-of-second. * The nano-of-second value has nine digits, thus the count of pattern letters * is from 1 to 9. If it is less than 9, then the nano-of-second value is - * truncated, with only the most significant digits being output. When parsing - * in strict mode, the number of parsed digits must match the count of pattern - * letters. When parsing in lenient mode, the number of parsed digits must be at - * least the count of pattern letters, up to 9 digits. + * truncated, with only the most significant digits being output. *

* Year: The count of letters determines the minimum field width below * which padding is used. If the count of letters is two, then a @@ -1647,12 +1644,13 @@ public final class DateTimeFormatter { * @return a formatter based on this formatter with the requested resolver style, not null */ public DateTimeFormatter withResolverFields(TemporalField... resolverFields) { - Objects.requireNonNull(resolverFields, "resolverFields"); - Set fields = new HashSet<>(Arrays.asList(resolverFields)); + Set fields = null; + if (resolverFields != null) { + fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields))); + } if (Objects.equals(this.resolverFields, fields)) { return this; } - fields = Collections.unmodifiableSet(fields); return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, fields, chrono, zone); } @@ -1696,11 +1694,12 @@ public final class DateTimeFormatter { * @return a formatter based on this formatter with the requested resolver style, not null */ public DateTimeFormatter withResolverFields(Set resolverFields) { - Objects.requireNonNull(resolverFields, "resolverFields"); if (Objects.equals(this.resolverFields, resolverFields)) { return this; } - resolverFields = Collections.unmodifiableSet(new HashSet<>(resolverFields)); + if (resolverFields != null) { + resolverFields = Collections.unmodifiableSet(new HashSet<>(resolverFields)); + } return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone); } diff --git a/src/share/classes/java/time/format/DateTimeFormatterBuilder.java b/src/share/classes/java/time/format/DateTimeFormatterBuilder.java index 9b9d9637a6cd6f1cd5c073fd11c33fb936456bb2..f04d59b23033befade7e455f0f7f7f441000598d 100644 --- a/src/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/src/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -2596,8 +2596,16 @@ public final class DateTimeFormatterBuilder { return value; } - boolean isFixedWidth() { - return subsequentWidth == -1; + /** + * For NumberPrinterParser, the width is fixed depending on the + * minWidth, maxWidth, signStyle and whether subsequent fields are fixed. + * @param context the context + * @return true if the field is fixed width + * @see DateTimeFormatterBuilder#appendValue(java.time.temporal.TemporalField, int) + */ + boolean isFixedWidth(DateTimeParseContext context) { + return subsequentWidth == -1 || + (subsequentWidth > 0 && minWidth == maxWidth && signStyle == SignStyle.NOT_NEGATIVE); } @Override @@ -2626,12 +2634,12 @@ public final class DateTimeFormatterBuilder { return ~position; } } - int effMinWidth = (context.isStrict() || isFixedWidth() ? minWidth : 1); + int effMinWidth = (context.isStrict() || isFixedWidth(context) ? minWidth : 1); int minEndPos = position + effMinWidth; if (minEndPos > length) { return ~position; } - int effMaxWidth = (context.isStrict() || isFixedWidth() ? maxWidth : 9) + Math.max(subsequentWidth, 0); + int effMaxWidth = (context.isStrict() || isFixedWidth(context) ? maxWidth : 9) + Math.max(subsequentWidth, 0); long total = 0; BigInteger totalBig = null; int pos = position; @@ -2866,6 +2874,21 @@ public final class DateTimeFormatterBuilder { this.subsequentWidth + subsequentWidth); } + /** + * For a ReducedPrinterParser, fixed width is false if the mode is strict, + * otherwise it is set as for NumberPrinterParser. + * @param context the context + * @return if the field is fixed width + * @see DateTimeFormatterBuilder#appendValueReduced(java.time.temporal.TemporalField, int, int, int) + */ + @Override + boolean isFixedWidth(DateTimeParseContext context) { + if (context.isStrict() == false) { + return false; + } + return super.isFixedWidth(context); + } + @Override public String toString() { return "ReducedValue(" + field + "," + minWidth + "," + maxWidth + "," + (baseDate != null ? baseDate : baseValue) + ")"; diff --git a/src/share/classes/java/time/format/Parsed.java b/src/share/classes/java/time/format/Parsed.java index 71961003e23a4d8596e281593fb8184389185808..f9878bbb5805e92c80903de57e49d72e80284e28 100644 --- a/src/share/classes/java/time/format/Parsed.java +++ b/src/share/classes/java/time/format/Parsed.java @@ -289,7 +289,7 @@ final class Parsed implements TemporalAccessor { changedCount++; continue outer; // have to restart to avoid concurrent modification } - throw new DateTimeException("Method resolveFields() can only return ChronoZonedDateTime," + + throw new DateTimeException("Method resolve() can only return ChronoZonedDateTime, " + "ChronoLocalDateTime, ChronoLocalDate or LocalTime"); } else if (fieldValues.containsKey(targetField) == false) { changedCount++; diff --git a/src/share/classes/java/time/temporal/TemporalAccessor.java b/src/share/classes/java/time/temporal/TemporalAccessor.java index 081bbbaec32825060da4b4c83a77365ca20b212a..a6133e18837cb56a33b40de786648b63f3b66404 100644 --- a/src/share/classes/java/time/temporal/TemporalAccessor.java +++ b/src/share/classes/java/time/temporal/TemporalAccessor.java @@ -217,7 +217,7 @@ public interface TemporalAccessor { default int get(TemporalField field) { ValueRange range = range(field); if (range.isIntValue() == false) { - throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead"); + throw new UnsupportedTemporalTypeException("Invalid field " + field + " for get() method, use getLong() instead"); } long value = getLong(field); if (range.isValidValue(value) == false) { diff --git a/src/share/classes/java/time/temporal/ValueRange.java b/src/share/classes/java/time/temporal/ValueRange.java index 980203c6d1d580dac565b923dcd69e420afdceb9..4e5c2fdb2f685eb960c14b6ce99d4b591a21f599 100644 --- a/src/share/classes/java/time/temporal/ValueRange.java +++ b/src/share/classes/java/time/temporal/ValueRange.java @@ -344,10 +344,13 @@ public final class ValueRange implements Serializable { /** * Restore the state of an ValueRange from the stream. * Check that the values are valid. + * + * @param s the stream to read * @throws InvalidObjectException if * the smallest minimum is greater than the smallest maximum, * or the smallest maximum is greater than the largest maximum * or the largest minimum is greater than the largest maximum + * @throws ClassNotFoundException if a class cannot be resolved */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException, InvalidObjectException diff --git a/src/share/classes/java/time/temporal/WeekFields.java b/src/share/classes/java/time/temporal/WeekFields.java index 7cf985e1a51eb02e8b2c197cb9b720c97ccb1b05..3aa362cea60c7d8ad6c663f7ad1d97f1bf69bf72 100644 --- a/src/share/classes/java/time/temporal/WeekFields.java +++ b/src/share/classes/java/time/temporal/WeekFields.java @@ -344,8 +344,11 @@ public final class WeekFields implements Serializable { /** * Restore the state of a WeekFields from the stream. * Check that the values are valid. + * + * @param s the stream to read * @throws InvalidObjectException if the serialized object has an invalid * value for firstDayOfWeek or minimalDays. + * @throws ClassNotFoundException if a class cannot be resolved */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException, InvalidObjectException diff --git a/src/share/classes/java/time/zone/ZoneOffsetTransition.java b/src/share/classes/java/time/zone/ZoneOffsetTransition.java index 263f40155cf1efed7f17b4383a26fcb62145f593..1df7c850b26105325b1d625e99e4cca7f28a1aff 100644 --- a/src/share/classes/java/time/zone/ZoneOffsetTransition.java +++ b/src/share/classes/java/time/zone/ZoneOffsetTransition.java @@ -173,6 +173,8 @@ public final class ZoneOffsetTransition //----------------------------------------------------------------------- /** * Defend against malicious streams. + * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java b/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java index f52953ca4c12e9dbaa4e9751cb65ba3fd932b215..db1a055a8b035fe071272c558804bbed10a371a7 100644 --- a/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java +++ b/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java @@ -235,6 +235,7 @@ public final class ZoneOffsetTransitionRule implements Serializable { /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/java/time/zone/ZoneRules.java b/src/share/classes/java/time/zone/ZoneRules.java index 179c006fe304f3b94524772aebaafc16962fd3c2..47190984db10e2514a5589fa62982c9375eeaf9f 100644 --- a/src/share/classes/java/time/zone/ZoneRules.java +++ b/src/share/classes/java/time/zone/ZoneRules.java @@ -319,6 +319,7 @@ public final class ZoneRules implements Serializable { /** * Defend against malicious streams. * + * @param s the stream to read * @throws InvalidObjectException always */ private void readObject(ObjectInputStream s) throws InvalidObjectException { diff --git a/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java b/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java index 283095c3588fe38a6ea5691a4953acbfb3a6d8d7..74db82734168ec37296c9405c95eab4e618cc34a 100644 --- a/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java +++ b/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java @@ -24,6 +24,7 @@ */ package sun.awt.image; +import java.awt.Dimension; import java.awt.Image; import java.awt.Graphics; import java.awt.geom.Dimension2D; @@ -42,6 +43,13 @@ public class MultiResolutionBufferedImage extends BufferedImage private final Dimension2D[] sizes; private int availableInfo; + public MultiResolutionBufferedImage(Image baseImage, + BiFunction mapper) { + this(baseImage, new Dimension[]{new Dimension( + baseImage.getWidth(null), baseImage.getHeight(null)) + }, mapper); + } + public MultiResolutionBufferedImage(Image baseImage, Dimension2D[] sizes, BiFunction mapper) { super(baseImage.getWidth(null), baseImage.getHeight(null), @@ -115,7 +123,7 @@ public class MultiResolutionBufferedImage extends BufferedImage } private static void preload(Image image, int availableInfo) { - if (image instanceof ToolkitImage) { + if (availableInfo != 0 && image instanceof ToolkitImage) { ((ToolkitImage) image).preload(new ImageObserver() { int flags = availableInfo; diff --git a/src/share/classes/sun/util/resources/TimeZoneNames.java b/src/share/classes/sun/util/resources/TimeZoneNames.java index 2aaa1e76dc409004e7a48a790c7623f89cc50ecb..298a233d8509562d8fddb850ba9c441a92242e58 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames.java @@ -570,6 +570,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Syowa Time", "SYOT", "Syowa Summer Time", "SYOST", "Syowa Time", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Coordinated Universal Time", "UTC", + "Central European Summer Time", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Vostok Time", "VOST", "Vostok Summer Time", "VOSST", "Vostok Time", "VOST"}}, @@ -839,7 +842,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { "Samara Time", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java b/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java index 4d25bce3586c9061745723691b5c57ced3f5ea53..ea7ab573a715bd7b418ededa81eb38213c8ab35c 100644 --- a/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java +++ b/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Syowa Zeit", "SYOT", "Syowa Sommerzeit", "SYOST", "Syowa Zeit", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Koordinierte Universalzeit", "UTC", + "Mitteleurop\u00e4ische Sommerzeit", "MESZ", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Vostok Zeit", "VOST", "Vostok Sommerzeit", "VOSST", "Vostok Zeit", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { "Samarische Zeit", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java b/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java index 07d77325a47658c3915cf698c597144a93ea4b67..c35c80963bea7c8fb26afcf464013b3270c79ba2 100644 --- a/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java +++ b/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Hora de Syowa", "SYOT", "Hora de verano de Syowa", "SYOST", "Hora de Syowa", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Hora Universal Coordinada", "UTC", + "Hora de verano de Europa Central", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Hora de Vostok", "VOST", "Hora de verano de Vostok", "VOSST", "Hora de Vostok", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { "Hora de Samara", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java b/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java index d15b90560576e6f4440d4a3a8821bf51b0bdeacf..393e45d45495e76f77981fd23206bfe64204329e 100644 --- a/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java +++ b/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Heure de Syowa", "SYOT", "Heure d'\u00e9t\u00e9 de Syowa", "SYOST", "Heure de Syowa", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Temps universel coordonn\u00e9", "UTC", + "Heure d'\u00e9t\u00e9 d'Europe centrale", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Heure de Vostok", "VOST", "Heure d'\u00e9t\u00e9 de Vostok", "VOSST", "Heure de Vostok", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { "Heure de Samara", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java b/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java index a07be9af4a6961107469215934f9160ca21f0c33..309a7715c7d5fdcb2070a7d76fd036bd5180be36 100644 --- a/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java +++ b/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Ora di Syowa", "SYOT", "Ora estiva di Syowa", "SYOST", "Ora di Syowa", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Tempo universale coordinato", "UTC", + "Ora estiva dell'Europa centrale", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Ora di Vostok", "VOST", "Ora estiva di Vostok", "VOSST", "Ora di Vostok", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { "Ora di Samara", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java b/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java index 5a0f5e7012a1afdbd3b8204192dea186c133f482..23bbcd6c8e0ff961ae47b3de4380bb88ed36f2d2 100644 --- a/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java +++ b/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"\u662d\u548c\u57fa\u5730\u6642\u9593", "SYOT", "\u662d\u548c\u57fa\u5730\u590f\u6642\u9593", "SYOST", "\u662D\u548C\u57FA\u5730\u6642\u9593", "SYOT"}}, + {"Antarctica/Troll", new String[] {"\u5354\u5b9a\u4e16\u754c\u6642", "UTC", + "\u4e2d\u90e8\u30e8\u30fc\u30ed\u30c3\u30d1\u590f\u6642\u9593", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"\u30dc\u30b9\u30c8\u30fc\u30af\u57fa\u5730\u6642\u9593", "VOST", "\u30dc\u30b9\u30c8\u30fc\u30af\u57fa\u5730\u590f\u6642\u9593", "VOSST", "\u30DC\u30B9\u30C8\u30FC\u30AF\u6642\u9593", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { "\u30B5\u30DE\u30E9\u6642\u9593", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java b/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java index 4d9f395fd5580770c5da104656ba9a1a0e642ad8..d1e106e2cd82f9d50c9794c134deb0bc9cee3411 100644 --- a/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java +++ b/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Syowa \uc2dc\uac04", "SYOT", "Syowa \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "SYOST", "\uC1FC\uC640 \uD45C\uC900\uC2DC", "SYOT"}}, + {"Antarctica/Troll", new String[] {"\uc138\uacc4 \ud45c\uc900\uc2dc", "UTC", + "\uc911\uc559 \uc720\ub7fd \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Vostok \uc2dc\uac04", "VOST", "Vostok \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "VOSST", "\uBCF4\uC2A4\uD1A1 \uD45C\uC900\uC2DC", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { "\uC0AC\uB9C8\uB77C \uD45C\uC900\uC2DC", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java b/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java index 07b13ae48ec323bd19a5fca0ee711f6b49555c1e..21852adbb674bf98dcd450afa1468c24696fd711 100644 --- a/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java +++ b/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Fuso hor\u00e1rio de Syowa", "SYOT", "Fuso hor\u00e1rio de ver\u00e3o de Syowa", "SYOST", "Hor\u00E1rio de Syowa", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Tempo universal coordenado", "UTC", + "Fuso hor\u00e1rio de ver\u00e3o da Europa Central", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Fuso hor\u00e1rio de Vostok", "VOST", "Fuso hor\u00e1rio de ver\u00e3o de Vostok", "VOSST", "Hor\u00E1rio de Vostok", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { "Hor\u00E1rio de Samara", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java b/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java index 5dfb716c627a550f50a66c58f2b84410c51ffa2a..dd509e15142410245aadfd16f0eefe33c1f93077 100644 --- a/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java +++ b/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Syowa, normaltid", "SYOT", "Syowa, sommartid", "SYOST", "Syowa-tid", "SYOT"}}, + {"Antarctica/Troll", new String[] {"Koordinerad universell tid", "UTC", + "Centraleuropeisk sommartid", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"Vostok, normaltid", "VOST", "Vostok, sommartid", "VOSST", "Vostok-tid", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { "Samara-tid", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java index 62a946ba4370bcb46b3928fd9d7b0e3b7be8f2b9..e4fca385baa95346f77f54f553d43a11d1bccab9 100644 --- a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java +++ b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"Syowa \u65f6\u95f4", "SYOT", "Syowa \u590f\u4ee4\u65f6", "SYOST", "Syowa \u65F6\u95F4", "SYOT"}}, + {"Antarctica/Troll", new String[] {"\u534f\u8c03\u4e16\u754c\u65f6\u95f4", "UTC", + "\u4e2d\u6b27\u590f\u4ee4\u65f6", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"\u83ab\u65af\u6258\u514b\u65f6\u95f4", "VOST", "\u83ab\u65af\u6258\u514b\u590f\u4ee4\u65f6", "VOSST", "\u83AB\u65AF\u6258\u514B\u65F6\u95F4", "VOST"}}, @@ -838,7 +841,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { "\u6C99\u9A6C\u62C9\u65F6\u95F4", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java index f91da7afb3d45093ca0b5161f0dfd82e68aa6051..20cfa231737b83ece0d1634d837f028a617a6024 100644 --- a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java +++ b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java @@ -570,6 +570,9 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"Antarctica/Syowa", new String[] {"\u5915\u6b50\u74e6 (Syowa) \u6642\u9593", "SYOT", "\u5915\u6b50\u74e6 (Syowa) \u590f\u4ee4\u6642\u9593", "SYOST", "\u5915\u6B50\u74E6 (Syowa) \u6642\u9593", "SYOT"}}, + {"Antarctica/Troll", new String[] {"\u5354\u8abf\u4e16\u754c\u6642\u9593", "UTC", + "\u4e2d\u6b50\u590f\u4ee4\u6642\u9593", "CEST", + "Troll Time", "ATT"}}, {"Antarctica/Vostok", new String[] {"\u4f5b\u65af\u6258 (Vostok) \u6642\u9593", "VOST", "\u4f5b\u65af\u6258 (Vostok) \u590f\u4ee4\u6642\u9593", "VOSST", "\u4F5B\u65AF\u6258 (Vostok) \u6642\u9593", "VOST"}}, @@ -840,7 +843,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { "\u6C99\u99AC\u62C9\u6642\u9593", "SAMT"}}, {"Europe/San_Marino", CET}, {"Europe/Sarajevo", CET}, - {"Europe/Simferopol", EET}, + {"Europe/Simferopol", MSK}, {"Europe/Skopje", CET}, {"Europe/Sofia", EET}, {"Europe/Stockholm", CET}, diff --git a/src/share/native/sun/java2d/opengl/OGLSurfaceData.c b/src/share/native/sun/java2d/opengl/OGLSurfaceData.c index 321f9c5e6cf4cdf90d22b73dc1974a23eb0d7324..83c0b59f324b0e2df89303e8d5adfbd6bd629867 100644 --- a/src/share/native/sun/java2d/opengl/OGLSurfaceData.c +++ b/src/share/native/sun/java2d/opengl/OGLSurfaceData.c @@ -543,7 +543,9 @@ OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, } JNU_SetFieldByName(env, NULL, sdObject, "nativeWidth", "I", width); + if (!((*env)->ExceptionOccurred(env))) { JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height); + } (*env)->DeleteLocalRef(env, sdObject); } diff --git a/src/share/npt/utf.c b/src/share/npt/utf.c index e4695597bd62cbe59958dba0c5f5c292aa0425bb..a3b437d346d46209d09e49898a592065f357f742 100644 --- a/src/share/npt/utf.c +++ b/src/share/npt/utf.c @@ -396,7 +396,7 @@ utf8mToUtf8s(struct UtfInst *ui, jbyte *string, int length, jbyte *newString, in /* ================================================================= */ -#if 1 /* Test program */ +#ifdef COMPILE_WITH_UTF_TEST /* Test program */ /* * Convert any byte array into a printable string. diff --git a/src/solaris/native/java/util/FileSystemPreferences.c b/src/solaris/native/java/util/FileSystemPreferences.c index eb0bf43fec5e0d5dd30c81fdeeeadad76bbfcb94..757f64c34f0de64e4c44f33f474d319e544e7d98 100644 --- a/src/solaris/native/java/util/FileSystemPreferences.c +++ b/src/solaris/native/java/util/FileSystemPreferences.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, 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 @@ -38,12 +38,14 @@ JNIEXPORT jint JNICALL Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission) { - const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); - int result; - result = chmod(fname, permission); - if (result != 0) - result = errno; - JNU_ReleaseStringPlatformChars(env, java_fname, fname); + const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); + int result = -1; + if (fname) { + result = chmod(fname, permission); + if (result != 0) + result = errno; + JNU_ReleaseStringPlatformChars(env, java_fname, fname); + } return (jint) result; } @@ -61,13 +63,16 @@ typedef struct flock64 FLOCK; JNIEXPORT jintArray JNICALL Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission, jboolean shared) { - const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); + const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); int fd, rc; int result[2]; - jintArray javaResult; + jintArray javaResult = NULL; int old_umask; FLOCK fl; + if (!fname) + return javaResult; + fl.l_whence = SEEK_SET; fl.l_len = 0; fl.l_start = 0; @@ -104,7 +109,8 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, } JNU_ReleaseStringPlatformChars(env, java_fname, fname); javaResult = (*env)->NewIntArray(env,2); - (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); + if (javaResult) + (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); return javaResult; } diff --git a/src/solaris/native/sun/awt/awt_Font.c b/src/solaris/native/sun/awt/awt_Font.c index 8a5a380d5ec0af0350e815e379e2508013fedfd3..d76591df16e9228e632020350129d2006e37471f 100644 --- a/src/solaris/native/sun/awt/awt_Font.c +++ b/src/solaris/native/sun/awt/awt_Font.c @@ -540,6 +540,19 @@ awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg) fdata->xfont = fdata->flist[i].xfont; fdata->flist[i].index_length = 1; } else { + /* Free any already allocated storage and fonts */ + int j = i; + for (j = 0; j <= i; j++) { + free((void *)fdata->flist[j].xlfd); + JNU_ReleaseStringPlatformChars(env, NULL, + fdata->flist[j].charset_name); + if (fdata->flist[j].load) { + XFreeFont(awt_display, fdata->flist[j].xfont); + } + } + free((void *)fdata->flist); + free((void *)fdata); + if (errmsg != NULL) { *errmsg = "java/lang" "NullPointerException"; } diff --git a/src/windows/native/sun/font/fontpath.c b/src/windows/native/sun/font/fontpath.c index 21bda1f9271cea1db0f3a102536b5e3f0affe55f..21bf30b08daec3e883199e37b3ac03b93ebf4caf 100644 --- a/src/windows/native/sun/font/fontpath.c +++ b/src/windows/native/sun/font/fontpath.c @@ -152,6 +152,10 @@ static int CALLBACK EnumFontFacesInFamilyProcA( /* printf("FULL=%s\n",lpelfe->elfFullName);fflush(stdout); */ fullname = JNU_NewStringPlatform(env, lpelfe->elfFullName); + if (fullname == NULL) { + (*env)->ExceptionClear(env); + return 1; + } fullnameLC = (*env)->CallObjectMethod(env, fullname, fmi->toLowerCaseMID, fmi->locale); (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname); @@ -242,6 +246,10 @@ static int CALLBACK EnumFontFacesInFamilyProcW( fullname = (*env)->NewString(env, lpelfe->elfFullName, (jsize)wcslen((LPWSTR)lpelfe->elfFullName)); + if (fullname == NULL) { + (*env)->ExceptionClear(env); + return 1; + } fullnameLC = (*env)->CallObjectMethod(env, fullname, fmi->toLowerCaseMID, fmi->locale); (*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname); @@ -287,6 +295,10 @@ static int CALLBACK EnumFamilyNamesA( return 1; } fmi->family = JNU_NewStringPlatform(env,lpelfe->elfLogFont.lfFaceName); + if (fmi->family == NULL) { + (*env)->ExceptionClear(env); + return 1; + } familyLC = (*env)->CallObjectMethod(env, fmi->family, fmi->toLowerCaseMID, fmi->locale); /* check if already seen this family with a different charset */ @@ -296,7 +308,10 @@ static int CALLBACK EnumFamilyNamesA( } fmi->list = (*env)->NewObject(env, fmi->arrayListClass, fmi->arrayListCtr, 4); - + if (fmi->list == NULL) { + (*env)->ExceptionClear(env); + return 1; + } (*env)->CallObjectMethod(env, fmi->familyToFontListMap, fmi->putMID, familyLC, fmi->list); @@ -343,6 +358,10 @@ static int CALLBACK EnumFamilyNamesW( } slen = wcslen(lpelfe->elfLogFont.lfFaceName); fmi->family = (*env)->NewString(env,lpelfe->elfLogFont.lfFaceName, (jsize)slen); + if (fmi->family == NULL) { + (*env)->ExceptionClear(env); + return 1; + } familyLC = (*env)->CallObjectMethod(env, fmi->family, fmi->toLowerCaseMID, fmi->locale); /* check if already seen this family with a different charset */ @@ -352,7 +371,10 @@ static int CALLBACK EnumFamilyNamesW( } fmi->list = (*env)->NewObject(env, fmi->arrayListClass, fmi->arrayListCtr, 4); - + if (fmi->list == NULL) { + (*env)->ExceptionClear(env); + return 1; + } (*env)->CallObjectMethod(env, fmi->familyToFontListMap, fmi->putMID, familyLC, fmi->list); @@ -447,6 +469,10 @@ static void registerFontA(GdiFontMapInfo *fmi, jobject fontToFileMap, JNIEnv *env = fmi->env; size_t dslen = strlen(data); jstring fileStr = JNU_NewStringPlatform(env, data); + if (fileStr == NULL) { + (*env)->ExceptionClear(env); + return; + } /* TTC or ttc means it may be a collection. Need to parse out * multiple font face names separated by " & " @@ -467,6 +493,10 @@ static void registerFontA(GdiFontMapInfo *fmi, jobject fontToFileMap, ptr1 = ptr2+3; } fontStr = JNU_NewStringPlatform(env, ptr1); + if (fontStr == NULL) { + (*env)->ExceptionClear(env); + return; + } fontStr = (*env)->CallObjectMethod(env, fontStr, fmi->toLowerCaseMID, fmi->locale); @@ -481,6 +511,10 @@ static void registerFontA(GdiFontMapInfo *fmi, jobject fontToFileMap, } } else { fontStr = JNU_NewStringPlatform(env, name); + if (fontStr == NULL) { + (*env)->ExceptionClear(env); + return; + } fontStr = (*env)->CallObjectMethod(env, fontStr, fmi->toLowerCaseMID, fmi->locale); (*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID, @@ -496,6 +530,10 @@ static void registerFontW(GdiFontMapInfo *fmi, jobject fontToFileMap, JNIEnv *env = fmi->env; size_t dslen = wcslen(data); jstring fileStr = (*env)->NewString(env, data, (jsize)dslen); + if (fileStr == NULL) { + (*env)->ExceptionClear(env); + return; + } /* TTC or ttc means it may be a collection. Need to parse out * multiple font face names separated by " & " @@ -517,6 +555,10 @@ static void registerFontW(GdiFontMapInfo *fmi, jobject fontToFileMap, ptr1 = ptr2+3; } fontStr = (*env)->NewString(env, ptr1, (jsize)wcslen(ptr1)); + if (fontStr == NULL) { + (*env)->ExceptionClear(env); + return; + } fontStr = (*env)->CallObjectMethod(env, fontStr, fmi->toLowerCaseMID, fmi->locale); @@ -531,6 +573,10 @@ static void registerFontW(GdiFontMapInfo *fmi, jobject fontToFileMap, } } else { fontStr = (*env)->NewString(env, name, (jsize)wcslen(name)); + if (fontStr == NULL) { + (*env)->ExceptionClear(env); + return; + } fontStr = (*env)->CallObjectMethod(env, fontStr, fmi->toLowerCaseMID, fmi->locale); (*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID, diff --git a/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp b/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp index c961451f5041360474ce2b186c741919074a16cd..1ede03bf56cccd89c81ff87fdd5aae5630b25e75 100644 --- a/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp +++ b/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp @@ -33,9 +33,16 @@ #include "awt_BitmapUtil.h" #include "D3DRenderQueue.h" + // REMIND: move to awt_Component.h extern "C" HWND AwtComponent_GetHWnd(JNIEnv *env, jlong pData); +/* This looks weird. but since some AWT headers need to be included, + * we end up with AWT's alloc.h macro definition of ExceptionOccurred. + * The reasons for that re-defintion do not apply to this code, so undef it. + */ +#undef ExceptionOccurred + /** * Initializes nativeWidth/Height fields of the SurfaceData object with * dimensions on the native surface. @@ -55,7 +62,9 @@ void D3DSD_SetNativeDimensions(JNIEnv *env, D3DSDOps *d3dsdo) { } JNU_SetFieldByName(env, NULL, sdObject, "nativeWidth", "I", width); + if (!(env->ExceptionOccurred())) { JNU_SetFieldByName(env, NULL, sdObject, "nativeHeight", "I", height); + } env->DeleteLocalRef(sdObject); } diff --git a/src/windows/native/sun/windows/WPrinterJob.cpp b/src/windows/native/sun/windows/WPrinterJob.cpp index 004eb855d472fc90fa0027daadf98762ef2c4770..b554b391e3b18da8c6b34a0300f0c77903c0300c 100644 --- a/src/windows/native/sun/windows/WPrinterJob.cpp +++ b/src/windows/native/sun/windows/WPrinterJob.cpp @@ -130,6 +130,9 @@ Java_sun_print_Win32PrintServiceLookup_getAllPrinterNames(JNIEnv *env, jstring utf_str; jclass clazz = env->FindClass("java/lang/String"); + if (clazz == NULL) { + return NULL; + } jobjectArray nameArray; try { @@ -240,6 +243,9 @@ Java_sun_print_Win32PrintService_getMediaPrintableArea(JNIEnv *env, LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); + if (printerName == NULL) { + return NULL; + } jfloatArray printableArray = NULL; @@ -262,7 +268,7 @@ Java_sun_print_Win32PrintService_getMediaPrintableArea(JNIEnv *env, if (pDevMode != NULL) { ::GlobalFree(pDevMode); } - + DeleteDC(pdc); ::ClosePrinter(hPrinter); JNU_ReleaseStringPlatformChars(env, printer, printerName); return printableArray; @@ -283,25 +289,21 @@ Java_sun_print_Win32PrintService_getMediaPrintableArea(JNIEnv *env, int resy = GetDeviceCaps(pdc, LOGPIXELSY); printableArray=env->NewFloatArray(4); - if (printableArray == NULL) { - throw std::bad_alloc(); + if (printableArray != NULL) { + jfloat *iPrintables = + env->GetFloatArrayElements(printableArray, NULL); + if (iPrintables != NULL) { + iPrintables[0] = (float)left/resx; + iPrintables[1] = (float)top/resy; + iPrintables[2] = (float)width/resx; + iPrintables[3] = (float)height/resy; + env->ReleaseFloatArrayElements(printableArray, iPrintables, 0); + } } - jboolean isCopy; - jfloat *iPrintables = env->GetFloatArrayElements(printableArray, - &isCopy), - *savePrintables = iPrintables; - - iPrintables[0] = (float)left/resx; - iPrintables[1] = (float)top/resy; - iPrintables[2] = (float)width/resx; - iPrintables[3] = (float)height/resy; - - env->ReleaseFloatArrayElements(printableArray, savePrintables, 0); - GlobalFree(pDevMode); + DeleteDC(pdc); } - DeleteDC(pdc); JNU_ReleaseStringPlatformChars(env, printer, printerName); return printableArray; @@ -309,52 +311,68 @@ Java_sun_print_Win32PrintService_getMediaPrintableArea(JNIEnv *env, CATCH_BAD_ALLOC_RET(NULL); } - -JNIEXPORT jintArray JNICALL -Java_sun_print_Win32PrintService_getAllMediaIDs(JNIEnv *env, - jobject peer, - jstring printer, - jstring port) +jintArray getIDs(JNIEnv *env, jstring printer, jstring port, int dm_id) { - TRY; LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); - jintArray mediasizeArray = NULL; + + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return NULL; + } SAVE_CONTROLWORD - int numSizes = ::DeviceCapabilities(printerName, printerPort, - DC_PAPERS, NULL, NULL); + int numIDs = ::DeviceCapabilities(printerName, printerPort, dm_id, + NULL, NULL); RESTORE_CONTROLWORD - if (numSizes > 0) { - - mediasizeArray = env->NewIntArray(numSizes); - if (mediasizeArray == NULL) { - throw std::bad_alloc(); - } - - jboolean isCopy; - jint *jpcIndices = env->GetIntArrayElements(mediasizeArray, - &isCopy), *saveFormats = jpcIndices; - LPTSTR papersBuf = (LPTSTR)new char[numSizes * sizeof(WORD)]; - if (::DeviceCapabilities(printerName, printerPort, - DC_PAPERS, papersBuf, NULL) != -1) { - RESTORE_CONTROLWORD - WORD *pDmPaperSize = (WORD *)papersBuf; - for (int i = 0; i < numSizes; i++, pDmPaperSize++) { - jpcIndices[i] = *pDmPaperSize; + jintArray idArray = NULL; + if (numIDs > 0) { + idArray = env->NewIntArray(numIDs); + if (idArray != NULL) { + jint *jpcIndices = env->GetIntArrayElements(idArray, NULL); + if (jpcIndices != NULL) { + jint *saveFormats = jpcIndices; + LPTSTR buf = NULL; + try { + buf = (LPTSTR)new char[numIDs * sizeof(WORD)]; + } catch (std::bad_alloc&) { + buf = NULL; + } + if (buf != NULL) { + if (::DeviceCapabilities(printerName, printerPort, + dm_id, buf, NULL) != -1) { + WORD *id = (WORD *)buf; + for (int i = 0; i < numIDs; i++, id++) { + jpcIndices[i] = *id; + } + } + RESTORE_CONTROLWORD + delete[] buf; + } + env->ReleaseIntArrayElements(idArray, saveFormats, 0); + } } - } - delete[] papersBuf; - env->ReleaseIntArrayElements(mediasizeArray, saveFormats, 0); } JNU_ReleaseStringPlatformChars(env, printer, printerName); JNU_ReleaseStringPlatformChars(env, port, printerPort); - return mediasizeArray; + return idArray; +} - CATCH_BAD_ALLOC_RET(NULL); +JNIEXPORT jintArray JNICALL +Java_sun_print_Win32PrintService_getAllMediaIDs(JNIEnv *env, + jobject peer, + jstring printer, + jstring port) +{ + return getIDs(env, printer, port, DC_PAPERS); } @@ -364,47 +382,7 @@ Java_sun_print_Win32PrintService_getAllMediaTrays(JNIEnv *env, jstring printer, jstring port) { - TRY; - - LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, - printer, NULL); - LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); - - jintArray mediaTrayArray = NULL; - - SAVE_CONTROLWORD - int nBins = ::DeviceCapabilities(printerName, printerPort, - DC_BINS, NULL, NULL) ; - RESTORE_CONTROLWORD - if (nBins > 0) { - mediaTrayArray = env->NewIntArray(nBins); - if (mediaTrayArray == NULL) { - throw std::bad_alloc(); - } - - jboolean isCopy; - jint *jpcIndices = env->GetIntArrayElements(mediaTrayArray, - &isCopy), *saveFormats = jpcIndices; - - LPTSTR buf = (LPTSTR)new char[nBins * sizeof(WORD)]; - - if (::DeviceCapabilities(printerName, printerPort, - DC_BINS, buf, NULL) != -1) { - RESTORE_CONTROLWORD - WORD *pBins = (WORD *)buf; - for (int i = 0; i < nBins; i++) { - jpcIndices[i] = *(pBins+i); - } - } - delete[] buf; - env->ReleaseIntArrayElements(mediaTrayArray, saveFormats, 0); - } - - JNU_ReleaseStringPlatformChars(env, printer, printerName); - JNU_ReleaseStringPlatformChars(env, port, printerPort); - return mediaTrayArray; - - CATCH_BAD_ALLOC_RET(NULL); + return getIDs(env, printer, port, DC_BINS); } @@ -414,100 +392,139 @@ Java_sun_print_Win32PrintService_getAllMediaSizes(JNIEnv *env, jstring printer, jstring port) { - TRY; - - LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, - printer, NULL); + LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); - jintArray mediaArray = NULL; + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return NULL; + } SAVE_CONTROLWORD - int nPapers = ::DeviceCapabilities(printerName, printerPort, - DC_PAPERSIZE, NULL, NULL) ; + int nPapers = ::DeviceCapabilities(printerName, printerPort, DC_PAPERSIZE, + NULL, NULL) ; RESTORE_CONTROLWORD - if (nPapers > 0) { - mediaArray = env->NewIntArray(nPapers*2); - if (mediaArray == NULL) { - throw std::bad_alloc(); - } - - jboolean isCopy; - jint *jpcIndices = env->GetIntArrayElements(mediaArray, - &isCopy), *saveFormats = jpcIndices; - LPTSTR buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; // array of POINTs - - if (::DeviceCapabilities(printerName, printerPort, - DC_PAPERSIZE, buf, NULL) != -1) { + jintArray mediaArray = NULL; + jint *saveFormats = NULL; - POINT *pDim = (POINT *)buf; - for (int i = 0; i < nPapers; i++) { - jpcIndices[i*2] = (pDim+i)->x; - jpcIndices[i*2+1] = (pDim+i)->y; + if (nPapers > 0) { + mediaArray = env->NewIntArray(nPapers*2); + if (mediaArray != NULL) { + jint *jpcIndices = env->GetIntArrayElements(mediaArray, NULL); + if (jpcIndices != NULL) { + saveFormats = jpcIndices; + LPTSTR buf = NULL; + try { + buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; + } catch (std::bad_alloc&) { + buf = NULL; + } + if (buf != NULL) { + if (::DeviceCapabilities(printerName, printerPort, + DC_PAPERSIZE, buf, NULL) != -1) { + POINT *pDim = (POINT *)buf; + for (int i = 0; i < nPapers; i++) { + jpcIndices[i*2] = (pDim+i)->x; + jpcIndices[i*2+1] = (pDim+i)->y; + } + } + RESTORE_CONTROLWORD + delete[] buf; + } + env->ReleaseIntArrayElements(mediaArray, saveFormats, 0); + saveFormats = NULL; + } } - } - RESTORE_CONTROLWORD - delete[] buf; - env->ReleaseIntArrayElements(mediaArray, saveFormats, 0); } JNU_ReleaseStringPlatformChars(env, printer, printerName); JNU_ReleaseStringPlatformChars(env, port, printerPort); + if (mediaArray != NULL && saveFormats != NULL) { + env->ReleaseIntArrayElements(mediaArray, saveFormats, 0); + } return mediaArray; - CATCH_BAD_ALLOC_RET(NULL); } jobjectArray getAllDCNames(JNIEnv *env, jobject peer, jstring printer, jstring port, unsigned int dc_id, unsigned int buf_len) { - TRY; - LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, - printer, NULL); + LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return NULL; + } + jstring utf_str; - jclass cls = env->FindClass("java/lang/String"); - jobjectArray names= NULL; + jobjectArray names = NULL; LPTSTR buf = NULL; SAVE_CONTROLWORD int cReturned = ::DeviceCapabilities(printerName, printerPort, dc_id, NULL, NULL); RESTORE_CONTROLWORD - if (cReturned > 0) { + if (cReturned <= 0) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + JNU_ReleaseStringPlatformChars(env, port, printerPort); + return NULL; + } - buf = (LPTSTR)new char[cReturned * buf_len * sizeof(TCHAR)]; - if (buf == NULL) { - throw std::bad_alloc(); - } + try { + buf = (LPTSTR)new char[cReturned * buf_len * sizeof(TCHAR)]; + } catch (std::bad_alloc&) { + buf = NULL; + } + if (buf == NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + JNU_ReleaseStringPlatformChars(env, port, printerPort); + JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); + return NULL; + } - cReturned = ::DeviceCapabilities(printerName, printerPort, - dc_id, buf, NULL); - RESTORE_CONTROLWORD + cReturned = ::DeviceCapabilities(printerName, printerPort, + dc_id, buf, NULL); + RESTORE_CONTROLWORD + + JNU_ReleaseStringPlatformChars(env, printer, printerName); + JNU_ReleaseStringPlatformChars(env, port, printerPort); - if (cReturned > 0) { - names = env->NewObjectArray(cReturned, cls, NULL); - if (names == NULL) { - throw std::bad_alloc(); + if (cReturned > 0) { + jclass cls = env->FindClass("java/lang/String"); + if (cls != NULL) { + names = env->NewObjectArray(cReturned, cls, NULL); + } + if (names == NULL || cls == NULL) { + delete buf; + return names; } for (int i = 0; i < cReturned; i++) { - utf_str = JNU_NewStringPlatform(env, buf+(buf_len*i)); - if (utf_str == NULL) { - throw std::bad_alloc(); + utf_str = JNU_NewStringPlatform(env, buf+(buf_len*i)); + if (utf_str == NULL) { + delete buf; + return names; + } + env->SetObjectArrayElement(names, i, utf_str); + env->DeleteLocalRef(utf_str); } - env->SetObjectArrayElement(names, i, utf_str); - env->DeleteLocalRef(utf_str); - } } delete[] buf; - } - return names; + return names; - CATCH_BAD_ALLOC_RET(NULL); } @@ -540,6 +557,16 @@ Java_sun_print_Win32PrintService_getCopiesSupported(JNIEnv *env, LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return 1; + } + SAVE_CONTROLWORD int numCopies = ::DeviceCapabilities(printerName, printerPort, DC_COPIES, NULL, NULL); @@ -573,48 +600,58 @@ Java_sun_print_Win32PrintService_getAllResolutions(JNIEnv *env, jstring printer, jstring port) { - TRY; - LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); - jintArray resolutionArray = NULL; + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return NULL; + } SAVE_CONTROLWORD int nResolutions = ::DeviceCapabilities(printerName, printerPort, DC_ENUMRESOLUTIONS, NULL, NULL); RESTORE_CONTROLWORD + + jintArray resolutionArray = NULL; if (nResolutions > 0) { resolutionArray = env->NewIntArray(nResolutions*2); - if (resolutionArray == NULL) { - throw std::bad_alloc(); - } - - jboolean isCopy; - jint *jpcIndices = env->GetIntArrayElements(resolutionArray, - &isCopy), *saveFormats = jpcIndices; - - LPTSTR resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2]; // pairs of long - - if (::DeviceCapabilities(printerName, printerPort, - DC_ENUMRESOLUTIONS, resBuf, NULL) != -1) { - - LONG *pResolution = (LONG *)resBuf; - for (int i = 0; i < nResolutions; i++) { - jpcIndices[i*2] = *pResolution++; - jpcIndices[i*2+1] = *pResolution++; - } + if (resolutionArray != NULL) { + jint *jpcIndices = env->GetIntArrayElements(resolutionArray, NULL); + if (jpcIndices != NULL) { + jint *saveFormats = jpcIndices; + LPTSTR resBuf = NULL; + try { + resBuf = (LPTSTR)new char[nResolutions * sizeof(LONG) * 2]; + } catch (std::bad_alloc&) { + resBuf = NULL; + } + if (resBuf != NULL) { + if (::DeviceCapabilities(printerName, printerPort, + DC_ENUMRESOLUTIONS, resBuf, + NULL) != -1) { + LONG *pResolution = (LONG *)resBuf; + for (int i = 0; i < nResolutions; i++) { + jpcIndices[i*2] = *pResolution++; + jpcIndices[i*2+1] = *pResolution++; + } + } + RESTORE_CONTROLWORD + delete[] resBuf; + } + env->ReleaseIntArrayElements(resolutionArray, saveFormats, 0); + } } - RESTORE_CONTROLWORD - delete[] resBuf; - env->ReleaseIntArrayElements(resolutionArray, saveFormats, 0); } JNU_ReleaseStringPlatformChars(env, printer, printerName); JNU_ReleaseStringPlatformChars(env, printer, printerPort); return resolutionArray; - - CATCH_BAD_ALLOC_RET(NULL); } @@ -672,6 +709,7 @@ Java_sun_print_Win32PrintService_getPrinterPort(JNIEnv *env, } catch (std::bad_alloc&) { delete [] buffer; JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); + return NULL; } if (printerPort == NULL) { @@ -692,6 +730,17 @@ Java_sun_print_Win32PrintService_getCapabilities(JNIEnv *env, { LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); + + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return NULL; + } + // 0x1000 is a flag to indicate that getCapabilities has already been called. // 0x0001 is a flag for color support and supported is the default. jint ret = 0x1001; @@ -761,28 +810,41 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, HANDLE hPrinter; LPDEVMODE pDevMode = NULL; - TRY; - LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL); + if (printerName == NULL || printerPort == NULL) { + if (printerName != NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + } + if (printerPort != NULL) { + JNU_ReleaseStringPlatformChars(env, port, printerPort); + } + return NULL; + } + + jint* defIndices = NULL; jintArray defaultArray = env->NewIntArray(NDEFAULT); - if (defaultArray == NULL) { - throw std::bad_alloc(); + if (defaultArray != NULL) { + defIndices = env->GetIntArrayElements(defaultArray, NULL); + } + if (defIndices == NULL) { + JNU_ReleaseStringPlatformChars(env, printer, printerName); + JNU_ReleaseStringPlatformChars(env, port, printerPort); + return NULL; } - jboolean isCopy; - jint *defIndices = env->GetIntArrayElements(defaultArray, - &isCopy), *saveFormats = defIndices; + jint *saveFormats = defIndices; - for (int i=0; iReleaseIntArrayElements(defaultArray, saveFormats, 0); JNU_ReleaseStringPlatformChars(env, printer, printerName); + JNU_ReleaseStringPlatformChars(env, port, printerPort); return defaultArray; } @@ -794,6 +856,7 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, ::ClosePrinter(hPrinter); env->ReleaseIntArrayElements(defaultArray, saveFormats, 0); JNU_ReleaseStringPlatformChars(env, printer, printerName); + JNU_ReleaseStringPlatformChars(env, port, printerPort); return defaultArray; } @@ -863,7 +926,6 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, defIndices[8] = pDevMode->dmColor; } - GlobalFree(pDevMode); ::ClosePrinter(hPrinter); @@ -873,8 +935,6 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, JNU_ReleaseStringPlatformChars(env, port, printerPort); return defaultArray; - - CATCH_BAD_ALLOC_RET(NULL); } @@ -891,6 +951,9 @@ Java_sun_print_Win32PrintService_getJobStatus(JNIEnv *env, int ret=0; LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); + if (printerName == NULL) { + return -1; + } // Start by opening the printer if (!::OpenPrinter(printerName, &hPrinter, NULL)) { @@ -959,13 +1022,15 @@ static jfieldID getIdOfLongField(JNIEnv *env, jobject self, jclass myClass = env->GetObjectClass(self); jfieldID fieldId = env->GetFieldID(myClass, fieldName, "J"); DASSERT(fieldId != 0); - return fieldId; } static inline HANDLE getHPrinter(JNIEnv *env, jobject self) { jfieldID fieldId = getIdOfLongField(env, self, HPRINTER_STR); + if (fieldId == (jfieldID)0) { + return (HANDLE)NULL; + } return (HANDLE)(env->GetLongField(self, fieldId)); } @@ -979,6 +1044,9 @@ Java_sun_print_Win32PrintJob_startPrintRawData(JNIEnv *env, HANDLE hPrinter; DOC_INFO_1 DocInfo; LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env, printer, NULL); + if (printerName == NULL) { + return false; + } DASSERT(jobname != NULL); LPTSTR lpJobName = (LPTSTR)JNU_GetStringPlatformChars(env, jobname, NULL); LPTSTR jname = _tcsdup(lpJobName); @@ -1016,8 +1084,12 @@ Java_sun_print_Win32PrintJob_startPrintRawData(JNIEnv *env, // store handle jfieldID fieldId = getIdOfLongField(env, peer, HPRINTER_STR); - env->SetLongField(peer, fieldId, reinterpret_cast(hPrinter)); - return true; + if (fieldId == (jfieldID)0) { + return false; + } else { + env->SetLongField(peer, fieldId, reinterpret_cast(hPrinter)); + return true; + } } @@ -1039,6 +1111,9 @@ Java_sun_print_Win32PrintJob_printRawData(JNIEnv *env, try { data=(jbyte *)env->GetPrimitiveArrayCritical(dataArray, 0); + if (data == NULL) { + return false; + } // Send the data to the printer. if( ! ::WritePrinter(hPrinter, data, count,(LPDWORD)&dwBytesWritten)) { diff --git a/src/windows/native/sun/windows/awt_Font.cpp b/src/windows/native/sun/windows/awt_Font.cpp index df3fbcbbb12c68bec46a3acdb3bd2aa01f8a2fb7..dfa4b70a7dc767ed673114c5335c63165a925fd4 100644 --- a/src/windows/native/sun/windows/awt_Font.cpp +++ b/src/windows/native/sun/windows/awt_Font.cpp @@ -49,9 +49,12 @@ extern jboolean IsMultiFont(JNIEnv *env, jobject obj) if (obj == NULL) { return JNI_FALSE; } - if (env->EnsureLocalCapacity(2)) + if (env->EnsureLocalCapacity(2)) { + env->ExceptionClear(); return JNI_FALSE; + } jobject peer = env->CallObjectMethod(obj, AwtFont::peerMID); + env->ExceptionClear(); if (peer == NULL) { return JNI_FALSE; } @@ -66,10 +69,12 @@ extern jstring GetTextComponentFontName(JNIEnv *env, jobject font) { DASSERT(font != NULL); if (env->EnsureLocalCapacity(2)) { + env->ExceptionClear(); return NULL; } jobject peer = env->CallObjectMethod(font, AwtFont::peerMID); DASSERT(peer != NULL); + if (peer == NULL) return NULL; jstring textComponentFontName = (jstring) env->GetObjectField(peer, AwtFont::textComponentFontNameID); env->DeleteLocalRef(peer); @@ -191,6 +196,9 @@ AwtFont* AwtFont::GetFont(JNIEnv *env, jobject font, } awtFont = Create(env, font, angle, awScale); + if (awtFont == NULL) { + return NULL; + } env->SetLongField(font, AwtFont::pDataID, reinterpret_cast(awtFont)); @@ -272,6 +280,9 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) if (cfnum > 0) { // Ask peer class for the text component font name jstring jTextComponentFontName = GetTextComponentFontName(env, font); + if (jTextComponentFontName == NULL) { + return NULL; + } LPCWSTR textComponentFontName = JNU_GetStringPlatformChars(env, jTextComponentFontName, NULL); awtFont->m_textInput = -1; @@ -285,6 +296,9 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) AwtFont::nativeNameID); wName = JNU_GetStringPlatformChars(env, nativeName, NULL); DASSERT(wName); + if (wName == NULL) { + wName = L"Arial"; + } //On NT platforms, if the font is not Symbol or Dingbats //use "W" version of Win32 APIs directly, info the FontDescription @@ -321,7 +335,12 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) // Instantiation for English version. jstring fontName = (jstring)env->GetObjectField(font, AwtFont::nameID); + if (fontName != NULL) { wName = JNU_GetStringPlatformChars(env, fontName, NULL); + } + if (wName == NULL) { + wName = L"Arial"; + } WCHAR* wEName; if (!wcscmp(wName, L"Helvetica") || !wcscmp(wName, L"SansSerif")) { @@ -647,6 +666,9 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC, //"useUnicode" field might not be initialized correctly (font in Menu Component, //for example"). AwtFont* awtFont = AwtFont::GetFont(env, font); + if (awtFont == NULL) { + return size; + } if (IsMultiFont(env, font)) { jobject peer = env->CallObjectMethod(font, AwtFont::peerMID); @@ -668,6 +690,9 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC, if (arrayLength == 0) { int length = env->GetStringLength(str); LPCWSTR strW = JNU_GetStringPlatformChars(env, str, NULL); + if (strW == NULL) { + return size; + } VERIFY(::SelectObject(hDC, awtFont->GetHFont())); if (AwtComponent::GetRTLReadingOrder()){ VERIFY(!draw || ::ExtTextOut(hDC, x, y, ETO_RTLREADING, NULL, @@ -692,6 +717,9 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC, } int fdIndex = getFontDescriptorNumber(env, font, fontDescriptor); + if (env->ExceptionCheck()) { + return size; //fdIndex==0 return could be exception or not. + } VERIFY(::SelectObject(hDC, awtFont->GetHFont(fdIndex))); /* @@ -705,10 +733,14 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC, * extend buflen and bad things will happen. */ unsigned char* buffer = NULL; - jboolean unicodeUsed = env->GetBooleanField(fontDescriptor, AwtFont::useUnicodeID); + jboolean unicodeUsed = + env->GetBooleanField(fontDescriptor, AwtFont::useUnicodeID); try { buffer = (unsigned char *) env->GetPrimitiveArrayCritical(convertedBytes, 0); + if (buffer == NULL) { + return size; + } int buflen = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]; @@ -816,8 +848,11 @@ Java_sun_awt_windows_WFontMetrics_charsWidth(JNIEnv *env, jobject self, jchar *strp = new jchar[len]; env->GetCharArrayRegion(str, off, len, strp); jstring jstr = env->NewString(strp, len); - jint result = Java_sun_awt_windows_WFontMetrics_stringWidth(env, self, + jint result = 0; + if (jstr != NULL) { + result = Java_sun_awt_windows_WFontMetrics_stringWidth(env, self, jstr); + } delete [] strp; return result; @@ -850,13 +885,25 @@ Java_sun_awt_windows_WFontMetrics_bytesWidth(JNIEnv *env, jobject self, try { jintArray array = (jintArray)env->GetObjectField(self, AwtFont::widthsID); + if (array == NULL) { + JNU_ThrowNullPointerException(env, "Can't access widths array."); + return NULL; + } pStrBody = (char *)env->GetPrimitiveArrayCritical(str, 0); + if (pStrBody == NULL) { + JNU_ThrowNullPointerException(env, "Can't access str bytes."); + return NULL; + } char *pStr = pStrBody + off; jint *widths = NULL; try { widths = (jint *)env->GetPrimitiveArrayCritical(array, 0); - + if (widths == NULL) { + env->ReleasePrimitiveArrayCritical(str, pStrBody, 0); + JNU_ThrowNullPointerException(env, "Can't access widths."); + return NULL; + } for (; len; len--) { result += widths[*pStr++]; } @@ -915,29 +962,15 @@ Java_sun_awt_windows_WFontMetrics_init(JNIEnv *env, jobject self) JNIEXPORT void JNICALL Java_sun_awt_windows_WFontMetrics_initIDs(JNIEnv *env, jclass cls) { - TRY; - - AwtFont::widthsID = env->GetFieldID(cls, "widths", "[I"); - AwtFont::ascentID = env->GetFieldID(cls, "ascent", "I"); - AwtFont::descentID = env->GetFieldID(cls, "descent", "I"); - AwtFont::leadingID = env->GetFieldID(cls, "leading", "I"); - AwtFont::heightID = env->GetFieldID(cls, "height", "I"); - AwtFont::maxAscentID = env->GetFieldID(cls, "maxAscent", "I"); - AwtFont::maxDescentID = env->GetFieldID(cls, "maxDescent", "I"); - AwtFont::maxHeightID = env->GetFieldID(cls, "maxHeight", "I"); + CHECK_NULL(AwtFont::widthsID = env->GetFieldID(cls, "widths", "[I")); + CHECK_NULL(AwtFont::ascentID = env->GetFieldID(cls, "ascent", "I")); + CHECK_NULL(AwtFont::descentID = env->GetFieldID(cls, "descent", "I")); + CHECK_NULL(AwtFont::leadingID = env->GetFieldID(cls, "leading", "I")); + CHECK_NULL(AwtFont::heightID = env->GetFieldID(cls, "height", "I")); + CHECK_NULL(AwtFont::maxAscentID = env->GetFieldID(cls, "maxAscent", "I")); + CHECK_NULL(AwtFont::maxDescentID = env->GetFieldID(cls, "maxDescent", "I")); + CHECK_NULL(AwtFont::maxHeightID = env->GetFieldID(cls, "maxHeight", "I")); AwtFont::maxAdvanceID = env->GetFieldID(cls, "maxAdvance", "I"); - - DASSERT(AwtFont::widthsID != NULL); - DASSERT(AwtFont::ascentID != NULL); - DASSERT(AwtFont::descentID != NULL); - DASSERT(AwtFont::leadingID != NULL); - DASSERT(AwtFont::heightID != NULL); - DASSERT(AwtFont::maxAscentID != NULL); - DASSERT(AwtFont::maxDescentID != NULL); - DASSERT(AwtFont::maxHeightID != NULL); - DASSERT(AwtFont::maxAdvanceID != NULL); - - CATCH_BAD_ALLOC; } } /* extern "C" */ @@ -952,28 +985,16 @@ extern "C" { JNIEXPORT void JNICALL Java_java_awt_Font_initIDs(JNIEnv *env, jclass cls) { - TRY; - - AwtFont::peerMID = env->GetMethodID(cls, "getPeer", - "()Ljava/awt/peer/FontPeer;"); - AwtFont::pDataID = env->GetFieldID(cls, "pData", "J"); - AwtFont::nameID = env->GetFieldID(cls, "name", "Ljava/lang/String;"); - AwtFont::sizeID = env->GetFieldID(cls, "size", "I"); - AwtFont::styleID = env->GetFieldID(cls, "style", "I"); - + CHECK_NULL(AwtFont::peerMID = env->GetMethodID(cls, "getPeer", + "()Ljava/awt/peer/FontPeer;")); + CHECK_NULL(AwtFont::pDataID = env->GetFieldID(cls, "pData", "J")); + CHECK_NULL(AwtFont::nameID = + env->GetFieldID(cls, "name", "Ljava/lang/String;")); + CHECK_NULL(AwtFont::sizeID = env->GetFieldID(cls, "size", "I")); + CHECK_NULL(AwtFont::styleID = env->GetFieldID(cls, "style", "I")); AwtFont::getFontMID = env->GetStaticMethodID(cls, "getFont", "(Ljava/lang/String;)Ljava/awt/Font;"); - - DASSERT(AwtFont::peerMID != NULL); - DASSERT(AwtFont::pDataID != NULL); - DASSERT(AwtFont::nameID != NULL); - DASSERT(AwtFont::sizeID != NULL); - DASSERT(AwtFont::styleID != NULL); - - DASSERT(AwtFont::getFontMID != NULL); - - CATCH_BAD_ALLOC; } } /* extern "C" */ @@ -988,15 +1009,9 @@ extern "C" { JNIEXPORT void JNICALL Java_java_awt_FontMetrics_initIDs(JNIEnv *env, jclass cls) { - TRY; - - AwtFont::fontID = env->GetFieldID(cls, "font", "Ljava/awt/Font;"); + CHECK_NULL(AwtFont::fontID = + env->GetFieldID(cls, "font", "Ljava/awt/Font;")); AwtFont::getHeightMID = env->GetMethodID(cls, "getHeight", "()I"); - - DASSERT(AwtFont::fontID); - DASSERT(AwtFont::getHeightMID); - - CATCH_BAD_ALLOC; } } /* extern "C" */ @@ -1010,16 +1025,10 @@ extern "C" { JNIEXPORT void JNICALL Java_sun_awt_FontDescriptor_initIDs(JNIEnv *env, jclass cls) { - TRY; - - AwtFont::nativeNameID = env->GetFieldID(cls, "nativeName", - "Ljava/lang/String;"); + CHECK_NULL(AwtFont::nativeNameID = + env->GetFieldID(cls, "nativeName", "Ljava/lang/String;")); AwtFont::useUnicodeID = env->GetFieldID(cls, "useUnicode", "Z"); - DASSERT(AwtFont::nativeNameID != NULL); - DASSERT(AwtFont::useUnicodeID != NULL); - - CATCH_BAD_ALLOC; } } /* extern "C" */ @@ -1034,20 +1043,13 @@ extern "C" { JNIEXPORT void JNICALL Java_sun_awt_PlatformFont_initIDs(JNIEnv *env, jclass cls) { - TRY; - - AwtFont::fontConfigID = env->GetFieldID(cls, "fontConfig", "Lsun/awt/FontConfiguration;"); - AwtFont::componentFontsID = - env->GetFieldID(cls, "componentFonts", "[Lsun/awt/FontDescriptor;"); + CHECK_NULL(AwtFont::fontConfigID = + env->GetFieldID(cls, "fontConfig", "Lsun/awt/FontConfiguration;")); + CHECK_NULL(AwtFont::componentFontsID = + env->GetFieldID(cls, "componentFonts", "[Lsun/awt/FontDescriptor;")); AwtFont::makeConvertedMultiFontStringMID = env->GetMethodID(cls, "makeConvertedMultiFontString", "(Ljava/lang/String;)[Ljava/lang/Object;"); - - DASSERT(AwtFont::makeConvertedMultiFontStringMID != NULL); - DASSERT(AwtFont::componentFontsID != NULL); - DASSERT(AwtFont::fontConfigID != NULL); - - CATCH_BAD_ALLOC; } } /* extern "C" */ @@ -1862,8 +1864,10 @@ Java_sun_awt_windows_WDefaultFontCharset_canConvert(JNIEnv *env, jobject self, static CCombinedSegTableManager tableManager; jstring fontName = (jstring)env->GetObjectField(self, AwtFont::fontNameID); - DASSERT(fontName != NULL); + DASSERT(fontName != NULL); // leave in for debug mode. + CHECK_NULL_RETURN(fontName, FALSE); // in production, just return LPCWSTR fontNameW = JNU_GetStringPlatformChars(env, fontName, NULL); + CHECK_NULL_RETURN(fontNameW, FALSE); CCombinedSegTable* pTable = tableManager.GetTable(fontNameW); JNU_ReleaseStringPlatformChars(env, fontName, fontNameW); return (pTable->In((USHORT) ch) ? JNI_TRUE : JNI_FALSE); diff --git a/src/windows/native/sun/windows/awt_PrintControl.cpp b/src/windows/native/sun/windows/awt_PrintControl.cpp index c9b7bbed91f1a5d012e7440b6c218980086608b0..d3d8b5d7b7dd5654fe26927c591d20d460b35ac0 100644 --- a/src/windows/native/sun/windows/awt_PrintControl.cpp +++ b/src/windows/native/sun/windows/awt_PrintControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -233,107 +233,166 @@ void AwtPrintControl::initIDs(JNIEnv *env, jclass cls) TRY; jclass cls = env->FindClass("sun/awt/windows/WPrinterJob"); + CHECK_NULL(cls); AwtPrintControl::dialogOwnerPeerID = env->GetFieldID(cls, "dialogOwnerPeer", "Ljava/awt/peer/ComponentPeer;"); + DASSERT(AwtPrintControl::dialogOwnerPeerID != NULL); + CHECK_NULL(AwtPrintControl::dialogOwnerPeerID); + AwtPrintControl::getPrintDCID = env->GetMethodID(cls, "getPrintDC", "()J"); + DASSERT(AwtPrintControl::getPrintDCID != NULL); + CHECK_NULL(AwtPrintControl::getPrintDCID); + AwtPrintControl::setPrintDCID = env->GetMethodID(cls, "setPrintDC", "(J)V"); + DASSERT(AwtPrintControl::setPrintDCID != NULL); + CHECK_NULL(AwtPrintControl::setPrintDCID); + AwtPrintControl::getDevmodeID = env->GetMethodID(cls, "getDevMode", "()J"); + DASSERT(AwtPrintControl::getDevmodeID != NULL); + CHECK_NULL(AwtPrintControl::getDevmodeID); + AwtPrintControl::setDevmodeID = env->GetMethodID(cls, "setDevMode", "(J)V"); + DASSERT(AwtPrintControl::setDevmodeID != NULL); + CHECK_NULL(AwtPrintControl::setDevmodeID); + AwtPrintControl::getDevnamesID = env->GetMethodID(cls, "getDevNames", "()J"); + DASSERT(AwtPrintControl::getDevnamesID != NULL); + CHECK_NULL(AwtPrintControl::getDevnamesID); + AwtPrintControl::setDevnamesID = env->GetMethodID(cls, "setDevNames", "(J)V"); + DASSERT(AwtPrintControl::setDevnamesID != NULL); + CHECK_NULL(AwtPrintControl::setDevnamesID); + AwtPrintControl::driverDoesMultipleCopiesID = env->GetFieldID(cls, "driverDoesMultipleCopies", "Z"); + DASSERT(AwtPrintControl::driverDoesMultipleCopiesID != NULL); + CHECK_NULL(AwtPrintControl::driverDoesMultipleCopiesID); + AwtPrintControl::driverDoesCollationID = env->GetFieldID(cls, "driverDoesCollation", "Z"); + DASSERT(AwtPrintControl::driverDoesCollationID != NULL); + CHECK_NULL(AwtPrintControl::driverDoesCollationID); + AwtPrintControl::getCopiesID = env->GetMethodID(cls, "getCopiesAttrib", "()I"); + DASSERT(AwtPrintControl::getCopiesID != NULL); + CHECK_NULL(AwtPrintControl::getCopiesID); + AwtPrintControl::getCollateID = env->GetMethodID(cls, "getCollateAttrib","()I"); + DASSERT(AwtPrintControl::getCollateID != NULL); + CHECK_NULL(AwtPrintControl::getCollateID); + AwtPrintControl::getOrientID = env->GetMethodID(cls, "getOrientAttrib", "()I"); + DASSERT(AwtPrintControl::getOrientID != NULL); + CHECK_NULL(AwtPrintControl::getOrientID); + AwtPrintControl::getFromPageID = env->GetMethodID(cls, "getFromPageAttrib", "()I"); + DASSERT(AwtPrintControl::getFromPageID != NULL); + CHECK_NULL(AwtPrintControl::getFromPageID); + AwtPrintControl::getToPageID = env->GetMethodID(cls, "getToPageAttrib", "()I"); + DASSERT(AwtPrintControl::getToPageID != NULL); + CHECK_NULL(AwtPrintControl::getToPageID); + AwtPrintControl::getMinPageID = env->GetMethodID(cls, "getMinPageAttrib", "()I"); + DASSERT(AwtPrintControl::getMinPageID != NULL); + CHECK_NULL(AwtPrintControl::getMinPageID); + AwtPrintControl::getMaxPageID = env->GetMethodID(cls, "getMaxPageAttrib", "()I"); + DASSERT(AwtPrintControl::getMaxPageID != NULL); + CHECK_NULL(AwtPrintControl::getMaxPageID); + AwtPrintControl::getDestID = env->GetMethodID(cls, "getDestAttrib", "()Z"); + DASSERT(AwtPrintControl::getDestID != NULL); + CHECK_NULL(AwtPrintControl::getDestID); + AwtPrintControl::getQualityID = env->GetMethodID(cls, "getQualityAttrib", "()I"); + DASSERT(AwtPrintControl::getQualityID != NULL); + CHECK_NULL(AwtPrintControl::getQualityID); + AwtPrintControl::getColorID = env->GetMethodID(cls, "getColorAttrib", "()I"); + DASSERT(AwtPrintControl::getColorID != NULL); + CHECK_NULL(AwtPrintControl::getColorID); + AwtPrintControl::getSidesID = env->GetMethodID(cls, "getSidesAttrib", "()I"); + DASSERT(AwtPrintControl::getSidesID != NULL); + CHECK_NULL(AwtPrintControl::getSidesID); + AwtPrintControl::getPrinterID = env->GetMethodID(cls, "getPrinterAttrib", "()Ljava/lang/String;"); + DASSERT(AwtPrintControl::getPrinterID != NULL); + CHECK_NULL(AwtPrintControl::getPrinterID); + AwtPrintControl::getWin32MediaID = env->GetMethodID(cls, "getWin32MediaAttrib", "()[I"); + DASSERT(AwtPrintControl::getWin32MediaID != NULL); + CHECK_NULL(AwtPrintControl::getWin32MediaID); + AwtPrintControl::setWin32MediaID = env->GetMethodID(cls, "setWin32MediaAttrib", "(III)V"); + DASSERT(AwtPrintControl::setWin32MediaID != NULL); + CHECK_NULL(AwtPrintControl::setWin32MediaID); + AwtPrintControl::getWin32MediaTrayID = env->GetMethodID(cls, "getMediaTrayAttrib", "()I"); + DASSERT(AwtPrintControl::getWin32MediaTrayID != NULL); + CHECK_NULL(AwtPrintControl::getWin32MediaTrayID); + AwtPrintControl::setWin32MediaTrayID = env->GetMethodID(cls, "setMediaTrayAttrib", "(I)V"); + DASSERT(AwtPrintControl::setWin32MediaTrayID != NULL); + CHECK_NULL(AwtPrintControl::setWin32MediaTrayID); + AwtPrintControl::getSelectID = env->GetMethodID(cls, "getSelectAttrib", "()I"); + DASSERT(AwtPrintControl::getSelectID != NULL); + CHECK_NULL(AwtPrintControl::getSelectID); + AwtPrintControl::getPrintToFileEnabledID = env->GetMethodID(cls, "getPrintToFileEnabled", "()Z"); + DASSERT(AwtPrintControl::getPrintToFileEnabledID != NULL); + CHECK_NULL(AwtPrintControl::getPrintToFileEnabledID); AwtPrintControl::setNativeAttID = env->GetMethodID(cls, "setNativeAttributes", "(III)V"); + DASSERT(AwtPrintControl::setNativeAttID != NULL); + CHECK_NULL(AwtPrintControl::setNativeAttID); AwtPrintControl::setRangeCopiesID = env->GetMethodID(cls, "setRangeCopiesAttribute", "(IIZI)V"); + DASSERT(AwtPrintControl::setRangeCopiesID != NULL); + CHECK_NULL(AwtPrintControl::setRangeCopiesID); + AwtPrintControl::setResID = env->GetMethodID(cls, "setResolutionDPI", "(II)V"); + DASSERT(AwtPrintControl::setResID != NULL); + CHECK_NULL(AwtPrintControl::setResID); AwtPrintControl::setPrinterID = env->GetMethodID(cls, "setPrinterNameAttrib", "(Ljava/lang/String;)V"); + DASSERT(AwtPrintControl::setPrinterID != NULL); + CHECK_NULL(AwtPrintControl::setPrinterID); AwtPrintControl::setJobAttributesID = env->GetMethodID(cls, "setJobAttributes", "(Ljavax/print/attribute/PrintRequestAttributeSet;IISSSSSSS)V"); - - DASSERT(AwtPrintControl::driverDoesMultipleCopiesID != NULL); - DASSERT(AwtPrintControl::getPrintDCID != NULL); - DASSERT(AwtPrintControl::setPrintDCID != NULL); - DASSERT(AwtPrintControl::getDevmodeID != NULL); - DASSERT(AwtPrintControl::setDevmodeID != NULL); - DASSERT(AwtPrintControl::getDevnamesID != NULL); - DASSERT(AwtPrintControl::setDevnamesID != NULL); - DASSERT(AwtPrintControl::driverDoesCollationID != NULL); - DASSERT(AwtPrintControl::getWin32MediaID != NULL); - DASSERT(AwtPrintControl::setWin32MediaID != NULL); - DASSERT(AwtPrintControl::getWin32MediaTrayID != NULL); - DASSERT(AwtPrintControl::setWin32MediaTrayID != NULL); - DASSERT(AwtPrintControl::setRangeCopiesID != NULL); - DASSERT(AwtPrintControl::setResID != NULL); - DASSERT(AwtPrintControl::setNativeAttID != NULL); - DASSERT(AwtPrintControl::dialogOwnerPeerID != NULL); - DASSERT(AwtPrintControl::getCopiesID != NULL); - DASSERT(AwtPrintControl::getOrientID != NULL); - DASSERT(AwtPrintControl::getPrinterID != NULL); - DASSERT(AwtPrintControl::getCollateID != NULL); - DASSERT(AwtPrintControl::getFromPageID != NULL); - DASSERT(AwtPrintControl::getToPageID != NULL); - DASSERT(AwtPrintControl::getMinPageID != NULL); - DASSERT(AwtPrintControl::getMaxPageID != NULL); - DASSERT(AwtPrintControl::getDestID != NULL); - DASSERT(AwtPrintControl::getQualityID != NULL); - DASSERT(AwtPrintControl::getColorID != NULL); - DASSERT(AwtPrintControl::getSidesID != NULL); - DASSERT(AwtPrintControl::getSelectID != NULL); - DASSERT(AwtPrintControl::getPrintToFileEnabledID != NULL); DASSERT(AwtPrintControl::setJobAttributesID != NULL); - + CHECK_NULL(AwtPrintControl::setJobAttributesID); CATCH_BAD_ALLOC; } @@ -606,6 +665,10 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, LPTSTR getName = (LPTSTR)JNU_GetStringPlatformChars(env, printerName, NULL); + if (getName == NULL) { + env->DeleteLocalRef(printerName); + throw std::bad_alloc(); + } BOOL samePrinter = FALSE; @@ -652,6 +715,7 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, if (portName != NULL) { free(portName); } + env->DeleteLocalRef(printerName); return FALSE; } @@ -664,11 +728,13 @@ BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env, if (portName != NULL) { free(portName); } + env->DeleteLocalRef(printerName); return FALSE; } delete [] buffer; } + env->DeleteLocalRef(printerName); // PrintDlg may change the values of hDevMode and hDevNames so we // re-initialize our saved handles. AwtPrintControl::setPrintHDMode(env, printCtrl, NULL); diff --git a/src/windows/native/sun/windows/awt_PrintDialog.cpp b/src/windows/native/sun/windows/awt_PrintDialog.cpp index d2deb0e82f196cb1eb0e56753a2607de09daf3f4..4c57b189388b14d45d5e54d02249aa48298262c3 100644 --- a/src/windows/native/sun/windows/awt_PrintDialog.cpp +++ b/src/windows/native/sun/windows/awt_PrintDialog.cpp @@ -204,11 +204,24 @@ Java_sun_awt_windows_WPrintDialogPeer__1show(JNIEnv *env, jobject peer) // as peer object is used later on another thread, create a global ref jobject peerGlobalRef = env->NewGlobalRef(peer); DASSERT(peerGlobalRef != NULL); + CHECK_NULL_RETURN(peerGlobalRef, 0); jobject target = env->GetObjectField(peerGlobalRef, AwtObject::targetID); DASSERT(target != NULL); + if (target == NULL) { + env->DeleteGlobalRef(peerGlobalRef); + return 0; + } jobject parent = env->GetObjectField(peerGlobalRef, AwtPrintDialog::parentID); jobject control = env->GetObjectField(target, AwtPrintDialog::controlID); DASSERT(control != NULL); + if (control == NULL) { + env->DeleteGlobalRef(peerGlobalRef); + env->DeleteLocalRef(target); + if (parent != NULL) { + env->DeleteLocalRef(parent); + } + return 0; + } AwtComponent *awtParent = (parent != NULL) ? (AwtComponent *)JNI_GET_PDATA(parent) : NULL; HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL; @@ -217,7 +230,18 @@ Java_sun_awt_windows_WPrintDialogPeer__1show(JNIEnv *env, jobject peer) memset(&pd, 0, sizeof(PRINTDLG)); pd.lStructSize = sizeof(PRINTDLG); pd.lCustData = (LPARAM)peerGlobalRef; - BOOL ret = AwtPrintControl::InitPrintDialog(env, control, pd); + BOOL ret; + try { + ret = AwtPrintControl::InitPrintDialog(env, control, pd); + } catch (std::bad_alloc&) { + env->DeleteGlobalRef(peerGlobalRef); + env->DeleteLocalRef(target); + if (parent != NULL) { + env->DeleteLocalRef(parent); + } + env->DeleteLocalRef(control); + throw; + } if (!ret) { /* Couldn't use the printer, or spooler isn't running * Call Page dialog with ' PD_RETURNDEFAULT' so it doesn't try diff --git a/src/windows/native/sun/windows/awt_new.cpp b/src/windows/native/sun/windows/awt_new.cpp index 306f08d59639c0124880432e498c9072eb83406a..e5adec25b56a4a8dea9d7ba36b02e17f6fbee6b1 100644 --- a/src/windows/native/sun/windows/awt_new.cpp +++ b/src/windows/native/sun/windows/awt_new.cpp @@ -149,7 +149,7 @@ void handle_bad_alloc(void) { if (jvm != NULL) { JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); - if (env != NULL) { + if (env != NULL && !env->ExceptionCheck()) { JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); } } diff --git a/test/java/beans/Introspector/Test8039776.java b/test/java/beans/Introspector/Test8039776.java new file mode 100644 index 0000000000000000000000000000000000000000..f2842b449051feb7f9615e7ad25ce2878ce10ab8 --- /dev/null +++ b/test/java/beans/Introspector/Test8039776.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, 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 java.util.Set; +import java.util.SortedSet; + +import static java.beans.Introspector.getBeanInfo; + +/* + * @test + * @bug 8039776 + * @summary Tests that Introspector does not throw NPE + * @author Sergey Malenkov + */ + +public class Test8039776 { + public static void main(String[] args) throws Exception { + getBeanInfo(Base.class, Object.class); + getBeanInfo(Child.class, Base.class); + getBeanInfo(Child.class, Object.class); + } + + public static class Base { + private SortedSet value; + + public Set getValue() { + return this.value; + } + + public void setValue(SortedSet value) { + this.value = value; + } + } + + public static class Child extends Base { + public Set getValue() { + return super.getValue(); + } + + public void setValue(SortedSet items) { + super.setValue(items); + } + } +} diff --git a/test/java/time/tck/java/time/TCKLocalTime.java b/test/java/time/tck/java/time/TCKLocalTime.java index 704533afca03375600c04e4c2a89adeff6c1351e..f79e8fc41f661cd678080b450865dab9ad752331 100644 --- a/test/java/time/tck/java/time/TCKLocalTime.java +++ b/test/java/time/tck/java/time/TCKLocalTime.java @@ -88,11 +88,10 @@ import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.time.Clock; import java.time.DateTimeException; import java.time.Duration; @@ -120,6 +119,7 @@ import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; @@ -760,7 +760,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - // with() + // with(TemporalAdjuster) //----------------------------------------------------------------------- @Test public void test_with_adjustment() { @@ -779,6 +779,331 @@ public class TCKLocalTime extends AbstractDateTimeTest { TEST_12_30_40_987654321.with((TemporalAdjuster) null); } + //----------------------------------------------------------------------- + // with(TemporalField, long) + //----------------------------------------------------------------------- + private long[] testPoints(long max) { + long[] points = new long[9]; + points[0] = 0; + points[1] = 1; + points[2] = 2; + points[3] = max / 7; + points[4] = (max / 7) * 2; + points[5] = (max / 2); + points[6] = (max / 7) * 6;; + points[7] = max - 2; + points[8] = max - 1; + return points; + } + + // Returns a {@code LocalTime} with the specified nano-of-second. + // The hour, minute and second will be unchanged. + @Test + public void test_with_longTemporalField_nanoOfSecond() { + for (long i : testPoints(1_000_000_000L)) { + LocalTime test = TEST_12_30_40_987654321.with(NANO_OF_SECOND, i); + assertEquals(test.get(NANO_OF_SECOND), i); + assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + } + } + + // Returns a {@code LocalTime} with the specified nano-of-day. + // This completely replaces the time and is equivalent to {@link #ofNanoOfDay(long)}. + @Test + public void test_with_longTemporalField_nanoOfDay() { + for (long i : testPoints(86_400_000_000_000L)) { + LocalTime test = TEST_12_30_40_987654321.with(NANO_OF_DAY, i); + assertEquals(test, LocalTime.ofNanoOfDay(i)); + } + } + + // Returns a {@code LocalTime} with the nano-of-second replaced by the specified + // micro-of-second multiplied by 1,000. + // The hour, minute and second will be unchanged. + @Test + public void test_with_longTemporalField_microOfSecond() { + for (long i : testPoints(1_000_000L)) { + LocalTime test = TEST_12_30_40_987654321.with(MICRO_OF_SECOND, i); + assertEquals(test.get(NANO_OF_SECOND), i * 1_000); + assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + } + } + + // Returns a {@code LocalTime} with the specified micro-of-day. + // This completely replaces the time and is equivalent to using {@link #ofNanoOfDay(long)} + // with the micro-of-day multiplied by 1,000. + @Test + public void test_with_longTemporalField_microOfDay() { + for (long i : testPoints(86_400_000_000L)) { + LocalTime test = TEST_12_30_40_987654321.with(MICRO_OF_DAY, i); + assertEquals(test, LocalTime.ofNanoOfDay(i * 1000)); + } + } + + // Returns a {@code LocalTime} with the nano-of-second replaced by the specified + // milli-of-second multiplied by 1,000,000. + // The hour, minute and second will be unchanged. + @Test + public void test_with_longTemporalField_milliOfSecond() { + for (long i : testPoints(1_000L)) { + LocalTime test = TEST_12_30_40_987654321.with(MILLI_OF_SECOND, i); + assertEquals(test.get(NANO_OF_SECOND), i * 1_000_000); + assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + } + } + + // Returns a {@code LocalTime} with the specified milli-of-day. + // This completely replaces the time and is equivalent to using {@link #ofNanoOfDay(long)} + // with the milli-of-day multiplied by 1,000,000. + @Test + public void test_with_longTemporalField_milliOfDay() { + for (long i : testPoints(86_400_000L)) { + LocalTime test = TEST_12_30_40_987654321.with(MILLI_OF_DAY, i); + assertEquals(test, LocalTime.ofNanoOfDay(i * 1_000_000)); + } + } + + // Returns a {@code LocalTime} with the specified second-of-minute. + // The hour, minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_secondOfMinute() { + for (long i : testPoints(60L)) { + LocalTime test = TEST_12_30_40_987654321.with(SECOND_OF_MINUTE, i); + assertEquals(test.get(SECOND_OF_MINUTE), i); + assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified second-of-day. + // The nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_secondOfDay() { + for (long i : testPoints(24 * 60 * 60)) { + LocalTime test = TEST_12_30_40_987654321.with(SECOND_OF_DAY, i); + assertEquals(test.get(SECOND_OF_DAY), i); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified minute-of-hour. + // The hour, second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_minuteOfHour() { + for (long i : testPoints(60)) { + LocalTime test = TEST_12_30_40_987654321.with(MINUTE_OF_HOUR, i); + assertEquals(test.get(MINUTE_OF_HOUR), i); + assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified minute-of-day. + // The second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_minuteOfDay() { + for (long i : testPoints(24 * 60)) { + LocalTime test = TEST_12_30_40_987654321.with(MINUTE_OF_DAY, i); + assertEquals(test.get(MINUTE_OF_DAY), i); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified hour-of-am-pm. + // The AM/PM, minute-of-hour, second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_hourOfAmPm() { + for (int i = 0; i < 12; i++) { + LocalTime test = TEST_12_30_40_987654321.with(HOUR_OF_AMPM, i); + assertEquals(test.get(HOUR_OF_AMPM), i); + assertEquals(test.get(AMPM_OF_DAY), TEST_12_30_40_987654321.get(AMPM_OF_DAY)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified clock-hour-of-am-pm. + // The AM/PM, minute-of-hour, second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_clockHourOfAmPm() { + for (int i = 1; i <= 12; i++) { + LocalTime test = TEST_12_30_40_987654321.with(CLOCK_HOUR_OF_AMPM, i); + assertEquals(test.get(CLOCK_HOUR_OF_AMPM), i); + assertEquals(test.get(AMPM_OF_DAY), TEST_12_30_40_987654321.get(AMPM_OF_DAY)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified hour-of-day. + // The minute-of-hour, second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_hourOfDay() { + for (int i = 0; i < 24; i++) { + LocalTime test = TEST_12_30_40_987654321.with(HOUR_OF_DAY, i); + assertEquals(test.get(HOUR_OF_DAY), i); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified clock-hour-of-day. + // The minute-of-hour, second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_clockHourOfDay() { + for (int i = 1; i <= 24; i++) { + LocalTime test = TEST_12_30_40_987654321.with(CLOCK_HOUR_OF_DAY, i); + assertEquals(test.get(CLOCK_HOUR_OF_DAY), i); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // Returns a {@code LocalTime} with the specified AM/PM. + // The hour-of-am-pm, minute-of-hour, second-of-minute and nano-of-second will be unchanged. + @Test + public void test_with_longTemporalField_amPmOfDay() { + for (int i = 0; i <= 1; i++) { + LocalTime test = TEST_12_30_40_987654321.with(AMPM_OF_DAY, i); + assertEquals(test.get(AMPM_OF_DAY), i); + assertEquals(test.get(HOUR_OF_AMPM), TEST_12_30_40_987654321.get(HOUR_OF_AMPM)); + assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); + assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); + assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); + } + } + + // The supported fields behave as follows... + // In all cases, if the new value is outside the valid range of values for the field + // then a {@code DateTimeException} will be thrown. + @DataProvider(name = "withTemporalField_outOfRange") + Object[][] data_withTemporalField_outOfRange() { + return new Object[][] { + {NANO_OF_SECOND, time(0, 0, 0, 0), NANO_OF_SECOND.range().getMinimum() - 1}, + {NANO_OF_SECOND, time(0, 0, 0, 0), NANO_OF_SECOND.range().getMaximum() + 1}, + + {NANO_OF_DAY, time(0, 0, 0, 0), NANO_OF_DAY.range().getMinimum() - 1}, + {NANO_OF_DAY, time(0, 0, 0, 0), NANO_OF_DAY.range().getMaximum() + 1}, + + {MICRO_OF_SECOND, time(0, 0, 0, 0), MICRO_OF_SECOND.range().getMinimum() - 1}, + {MICRO_OF_SECOND, time(0, 0, 0, 0), MICRO_OF_SECOND.range().getMaximum() + 1}, + + {MICRO_OF_DAY, time(0, 0, 0, 0), MICRO_OF_DAY.range().getMinimum() - 1}, + {MICRO_OF_DAY, time(0, 0, 0, 0), MICRO_OF_DAY.range().getMaximum() + 1}, + + {MILLI_OF_SECOND, time(0, 0, 0, 0), MILLI_OF_SECOND.range().getMinimum() - 1}, + {MILLI_OF_SECOND, time(0, 0, 0, 0), MILLI_OF_SECOND.range().getMaximum() + 1}, + + {MILLI_OF_DAY, time(0, 0, 0, 0), MILLI_OF_DAY.range().getMinimum() - 1}, + {MILLI_OF_DAY, time(0, 0, 0, 0), MILLI_OF_DAY.range().getMaximum() + 1}, + + {SECOND_OF_MINUTE, time(0, 0, 0, 0), SECOND_OF_MINUTE.range().getMinimum() - 1}, + {SECOND_OF_MINUTE, time(0, 0, 0, 0), SECOND_OF_MINUTE.range().getMaximum() + 1}, + + {SECOND_OF_DAY, time(0, 0, 0, 0), SECOND_OF_DAY.range().getMinimum() - 1}, + {SECOND_OF_DAY, time(0, 0, 0, 0), SECOND_OF_DAY.range().getMaximum() + 1}, + + {MINUTE_OF_HOUR, time(0, 0, 0, 0), MINUTE_OF_HOUR.range().getMinimum() - 1}, + {MINUTE_OF_HOUR, time(0, 0, 0, 0), MINUTE_OF_HOUR.range().getMaximum() + 1}, + + {MINUTE_OF_DAY, time(0, 0, 0, 0), MINUTE_OF_DAY.range().getMinimum() - 1}, + {MINUTE_OF_DAY, time(0, 0, 0, 0), MINUTE_OF_DAY.range().getMaximum() + 1}, + + {HOUR_OF_AMPM, time(0, 0, 0, 0), HOUR_OF_AMPM.range().getMinimum() - 1}, + {HOUR_OF_AMPM, time(0, 0, 0, 0), HOUR_OF_AMPM.range().getMaximum() + 1}, + + {CLOCK_HOUR_OF_AMPM, time(0, 0, 0, 0), CLOCK_HOUR_OF_AMPM.range().getMinimum() - 1}, + {CLOCK_HOUR_OF_AMPM, time(0, 0, 0, 0), CLOCK_HOUR_OF_AMPM.range().getMaximum() + 1}, + + {HOUR_OF_DAY, time(0, 0, 0, 0), HOUR_OF_DAY.range().getMinimum() - 1}, + {HOUR_OF_DAY, time(0, 0, 0, 0), HOUR_OF_DAY.range().getMaximum() + 1}, + + {CLOCK_HOUR_OF_DAY, time(0, 0, 0, 0), CLOCK_HOUR_OF_DAY.range().getMinimum() - 1}, + {CLOCK_HOUR_OF_DAY, time(0, 0, 0, 0), CLOCK_HOUR_OF_DAY.range().getMaximum() + 1}, + + {AMPM_OF_DAY, time(0, 0, 0, 0), AMPM_OF_DAY.range().getMinimum() - 1}, + {AMPM_OF_DAY, time(0, 0, 0, 0), AMPM_OF_DAY.range().getMaximum() + 1}, + }; + } + + @Test(dataProvider = "withTemporalField_outOfRange") + public void test_with_longTemporalField_invalid(TemporalField field, LocalTime base, long newValue) { + try { + base.with(field, newValue); + fail("Field should not be allowed " + field); + } catch (DateTimeException ex) { + // expected + } + } + + // All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. + @Test(expectedExceptions=UnsupportedTemporalTypeException.class) + public void test_with_longTemporalField_otherChronoField() { + TEST_12_30_40_987654321.with(ChronoField.DAY_OF_MONTH, 1); + } + + // If the field is not a {@code ChronoField}, then the result of this method + // is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} + // passing {@code this} as the argument. + @Test + public void test_with_longTemporalField_notChronoField() { + final LocalTime result = LocalTime.of(12, 30); + final LocalTime base = LocalTime.of(15, 45); + TemporalField field = new TemporalField() { + public ValueRange rangeRefinedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException(); + } + public ValueRange range() { + return null; + } + public boolean isTimeBased() { + throw new UnsupportedOperationException(); + } + public boolean isSupportedBy(TemporalAccessor temporal) { + throw new UnsupportedOperationException(); + } + public boolean isDateBased() { + throw new UnsupportedOperationException(); + } + public TemporalUnit getRangeUnit() { + throw new UnsupportedOperationException(); + } + public long getFrom(TemporalAccessor temporal) { + throw new UnsupportedOperationException(); + } + public TemporalUnit getBaseUnit() { + throw new UnsupportedOperationException(); + } + public R adjustInto(R temporal, long newValue) { + assertEquals(temporal, base); + assertEquals(newValue, 12L); + @SuppressWarnings("unchecked") + R r = (R) result; + return r; + } + }; + LocalTime test = base.with(field, 12L); + assertSame(test, result); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_with_longTemporalField_null() { + TEST_12_30_40_987654321.with((TemporalField) null, 1); + } + //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- diff --git a/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java b/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java index 8e2091e98881d08d7edefd96c8a023a0f9eaef3d..9c0a783ec538e89e0b113e523d16286aebc8af52 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java @@ -254,14 +254,20 @@ public class TCKDateTimeFormatter { assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields } - @Test(expectedExceptions = NullPointerException.class) + @Test public void test_resolverFields_Array_null() throws Exception { - DateTimeFormatter.ISO_DATE.withResolverFields((TemporalField[]) null); + DateTimeFormatter f = DateTimeFormatter.ISO_DATE.withResolverFields(MONTH_OF_YEAR); + assertEquals(f.getResolverFields().size(), 1); + f = f.withResolverFields((TemporalField[]) null); + assertEquals(f.getResolverFields(), null); } - @Test(expectedExceptions = NullPointerException.class) + @Test public void test_resolverFields_Set_null() throws Exception { - DateTimeFormatter.ISO_DATE.withResolverFields((Set) null); + DateTimeFormatter f = DateTimeFormatter.ISO_DATE.withResolverFields(MONTH_OF_YEAR); + assertEquals(f.getResolverFields().size(), 1); + f = f.withResolverFields((Set) null); + assertEquals(f.getResolverFields(), null); } //----------------------------------------------------------------------- diff --git a/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java b/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java index 59d2ca15b981758be07d4632b8379f48e32f5e3a..c5a017c911ebadc39bd5370c5215b25c85760879 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java @@ -60,11 +60,14 @@ package tck.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.HOUR_OF_DAY; import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; +import java.text.ParsePosition; import java.time.LocalDate; import java.time.YearMonth; import java.time.ZoneOffset; @@ -73,6 +76,7 @@ import java.time.format.DateTimeFormatterBuilder; import java.time.format.SignStyle; import java.time.format.TextStyle; import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -728,4 +732,150 @@ public class TCKDateTimeFormatterBuilder { return LocalDate.of(y, m, d); } + //----------------------------------------------------------------------- + @Test + public void test_adjacent_strict_firstFixedWidth() throws Exception { + // succeeds because both number elements are fixed width + DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("12309", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 5); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + } + + @Test + public void test_adjacent_strict_firstVariableWidth_success() throws Exception { + // succeeds greedily parsing variable width, then fixed width, to non-numeric Z + DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('Z').toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("12309Z", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 6); + assertEquals(parsed.getLong(HOUR_OF_DAY), 123L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 9L); + } + + @Test + public void test_adjacent_strict_firstVariableWidth_fails() throws Exception { + // fails because literal is a number and variable width parse greedily absorbs it + DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("12309", pp); + assertEquals(pp.getErrorIndex(), 5); + assertEquals(parsed, null); + } + + @Test + public void test_adjacent_lenient() throws Exception { + // succeeds because both number elements are fixed width even in lenient mode + DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("12309", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 5); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + } + + @Test + public void test_adjacent_lenient_firstVariableWidth_success() throws Exception { + // succeeds greedily parsing variable width, then fixed width, to non-numeric Z + DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('Z').toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("12309Z", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 6); + assertEquals(parsed.getLong(HOUR_OF_DAY), 123L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 9L); + } + + @Test + public void test_adjacent_lenient_firstVariableWidth_fails() throws Exception { + // fails because literal is a number and variable width parse greedily absorbs it + DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("12309", pp); + assertEquals(pp.getErrorIndex(), 5); + assertEquals(parsed, null); + } + + //----------------------------------------------------------------------- + @Test + public void test_adjacent_strict_fractionFollows() throws Exception { + // succeeds because hour/min are fixed width + DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 0, 3, false).toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("1230567", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 7); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + assertEquals(parsed.getLong(NANO_OF_SECOND), 567_000_000L); + } + + @Test + public void test_adjacent_strict_fractionFollows_2digit() throws Exception { + // succeeds because hour/min are fixed width + DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 0, 3, false).toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("123056", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 6); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + assertEquals(parsed.getLong(NANO_OF_SECOND), 560_000_000L); + } + + @Test + public void test_adjacent_strict_fractionFollows_0digit() throws Exception { + // succeeds because hour/min are fixed width + DateTimeFormatter f = builder.appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 0, 3, false).toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("1230", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 4); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + } + + @Test + public void test_adjacent_lenient_fractionFollows() throws Exception { + // succeeds because hour/min are fixed width + DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 3, 3, false).toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("1230567", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 7); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + assertEquals(parsed.getLong(NANO_OF_SECOND), 567_000_000L); + } + + @Test + public void test_adjacent_lenient_fractionFollows_2digit() throws Exception { + // succeeds because hour/min are fixed width + DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 3, 3, false).toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("123056", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 6); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + assertEquals(parsed.getLong(NANO_OF_SECOND), 560_000_000L); + } + + @Test + public void test_adjacent_lenient_fractionFollows_0digit() throws Exception { + // succeeds because hour/min are fixed width + DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY, 2).appendValue(MINUTE_OF_HOUR, 2).appendFraction(NANO_OF_SECOND, 3, 3, false).toFormatter(Locale.UK); + ParsePosition pp = new ParsePosition(0); + TemporalAccessor parsed = f.parseUnresolved("1230", pp); + assertEquals(pp.getErrorIndex(), -1); + assertEquals(pp.getIndex(), 4); + assertEquals(parsed.getLong(HOUR_OF_DAY), 12L); + assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L); + } + } diff --git a/test/java/time/test/java/time/format/TestReducedParser.java b/test/java/time/test/java/time/format/TestReducedParser.java index e9df91fdc8e9b391b9a8ef5ea0baaf45ebd067d3..3bf806563e8efd0ba686da14f11a6c0484c97fa0 100644 --- a/test/java/time/test/java/time/format/TestReducedParser.java +++ b/test/java/time/test/java/time/format/TestReducedParser.java @@ -356,7 +356,7 @@ public class TestReducedParser extends AbstractTestPrinterParser { {"yyMMdd", "200703", STRICT, 0, 6, 2020, 7, 3}, {"ddMMyy", "230714", LENIENT, 0, 6, 2014, 7, 23}, {"ddMMyy", "230714", STRICT, 0, 6, 2014, 7, 23}, - {"ddMMyy", "25062001", LENIENT, 0, 8, 2001, 20, 2506}, + {"ddMMyy", "25062001", LENIENT, 0, 8, 2001, 6, 25}, {"ddMMyy", "25062001", STRICT, 0, 6, 2020, 6, 25}, {"ddMMy", "27052002", LENIENT, 0, 8, 2002, 5, 27}, {"ddMMy", "27052002", STRICT, 0, 8, 2002, 5, 27}, diff --git a/test/javax/swing/JCheckBox/8032667/bug8032667.html b/test/javax/swing/JCheckBox/8032667/bug8032667.html new file mode 100644 index 0000000000000000000000000000000000000000..33cc90e77cf624672ab8a716b2530c8b4196dcd8 --- /dev/null +++ b/test/javax/swing/JCheckBox/8032667/bug8032667.html @@ -0,0 +1,36 @@ + + + + + +Verify that scaled components are rendered smoothly to image. + +1. Run the test. +2. Check that Selected and Deselected JCheckBox icons are drawn smoothly. +If so, press PASS, else press FAIL. + + + + + diff --git a/test/javax/swing/JCheckBox/8032667/bug8032667.java b/test/javax/swing/JCheckBox/8032667/bug8032667.java new file mode 100644 index 0000000000000000000000000000000000000000..fda8852e520098beed8144f40740a0b644b11bfe --- /dev/null +++ b/test/javax/swing/JCheckBox/8032667/bug8032667.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2014, 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 java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; +import javax.swing.JApplet; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; + +/* @test + * @bug 8032667 + * @summary [macosx] Components cannot be rendered in HiDPI to BufferedImage + * @run applet/manual=yesno bug8032667.html + */ +public class bug8032667 extends JApplet { + + static final int scale = 2; + static final int width = 130; + static final int height = 50; + static final int scaledWidth = scale * width; + static final int scaledHeight = scale * height; + + @Override + public void init() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + final Image image1 = getImage(getCheckBox("Deselected", false)); + final Image image2 = getImage(getCheckBox("Selected", true)); + + Canvas canvas = new Canvas() { + + @Override + public void paint(Graphics g) { + super.paint(g); + g.drawImage(image1, 0, 0, scaledWidth, scaledHeight, this); + g.drawImage(image2, 0, scaledHeight + 5, + scaledWidth, scaledHeight, this); + } + }; + + getContentPane().add(canvas, BorderLayout.CENTER); + } + }); + } + + static JCheckBox getCheckBox(String text, boolean selected) { + JCheckBox checkBox = new JCheckBox(text); + checkBox.setSelected(selected); + checkBox.setSize(new Dimension(width, height)); + return checkBox; + } + + static Image getImage(JComponent component) { + final BufferedImage image = new BufferedImage( + scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB); + final Graphics g = image.getGraphics(); + ((Graphics2D) g).scale(scale, scale); + component.paint(g); + g.dispose(); + + return image; + } +} diff --git a/test/javax/swing/JCheckBox/8032667/bug8032667_image_diff.java b/test/javax/swing/JCheckBox/8032667/bug8032667_image_diff.java new file mode 100644 index 0000000000000000000000000000000000000000..09e6b623784165200cb2b97410ae596f0dcbe8c9 --- /dev/null +++ b/test/javax/swing/JCheckBox/8032667/bug8032667_image_diff.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2014, 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 java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import sun.awt.OSInfo; + +/* @test + * @bug 8032667 + * @summary [macosx] Components cannot be rendered in HiDPI to BufferedImage + * @run main bug8032667_image_diff + */ +public class bug8032667_image_diff { + + static final int IMAGE_WIDTH = 130; + static final int IMAGE_HEIGHT = 50; + + public static void main(String[] args) throws Exception { + + if(!OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())){ + return; + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + + JCheckBox checkBox = new JCheckBox(); + checkBox.setSelected(true); + checkBox.setSize(new Dimension(IMAGE_WIDTH, IMAGE_HEIGHT)); + + final BufferedImage image1 = getHiDPIImage(checkBox); + final BufferedImage image2 = getScaledImage(checkBox); + + if(equal(image1, image2)){ + throw new RuntimeException("2x image equals to non smooth image"); + } + } + }); + } + + static boolean equal(BufferedImage image1, BufferedImage image2) { + + int w = image1.getWidth(); + int h = image1.getHeight(); + + if (w != image2.getWidth() || h != image2.getHeight()) { + return false; + } + + for (int i = 0; i < w; i++) { + for (int j = 0; j < h; j++) { + int color1 = image1.getRGB(i, j); + int color2 = image2.getRGB(i, j); + + if (color1 != color2) { + return false; + } + } + } + return true; + } + + static BufferedImage getHiDPIImage(JComponent component) { + return getImage(component, 2, IMAGE_WIDTH, IMAGE_HEIGHT); + } + + static BufferedImage getScaledImage(JComponent component) { + Image image1x = getImage(component, 1, IMAGE_WIDTH, IMAGE_HEIGHT); + final BufferedImage image2x = new BufferedImage( + 2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_ARGB); + final Graphics g = image2x.getGraphics(); + ((Graphics2D) g).scale(2, 2); + g.drawImage(image1x, 0, 0, null); + g.dispose(); + return image2x; + } + + static BufferedImage getImage(JComponent component, int scale, int width, int height) { + final BufferedImage image = new BufferedImage( + scale * width, scale * height, BufferedImage.TYPE_INT_ARGB); + final Graphics g = image.getGraphics(); + ((Graphics2D) g).scale(scale, scale); + component.paint(g); + g.dispose(); + return image; + } +} diff --git a/test/javax/swing/JTree/8038113/bug8038113.html b/test/javax/swing/JTree/8038113/bug8038113.html new file mode 100644 index 0000000000000000000000000000000000000000..1eb5480b517b2b6a6bbaed4b995fe53523eae52c --- /dev/null +++ b/test/javax/swing/JTree/8038113/bug8038113.html @@ -0,0 +1,36 @@ + + + + + +Verify that scaled icons are rendered smoothly. + +1. Run the test. +2. Check that Collapsed and Expanded JTree icons are drawn smoothly. +If so, press PASS, else press FAIL. + + + + + diff --git a/test/javax/swing/JTree/8038113/bug8038113.java b/test/javax/swing/JTree/8038113/bug8038113.java new file mode 100644 index 0000000000000000000000000000000000000000..fb094c4a25f7e83af214db3b893abe4580c88231 --- /dev/null +++ b/test/javax/swing/JTree/8038113/bug8038113.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014, 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 java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import javax.swing.Icon; +import javax.swing.JApplet; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.SwingUtilities; +import javax.swing.plaf.basic.BasicTreeUI; + +/* @test + * @bug 8038113 + * @summary [macosx] JTree icon is not rendered in high resolution on Retina + * @run applet/manual=yesno bug8038113.html + */ +public class bug8038113 extends JApplet { + + @Override + public void init() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + final JTree tree = new JTree(); + final BasicTreeUI treeUI = (BasicTreeUI) tree.getUI(); + + final JPanel panel = new JPanel() { + + @Override + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2 = (Graphics2D) g; + g2.setStroke(new BasicStroke(0.5f)); + g2.scale(2, 2); + + int x = 10; + int y = 10; + Icon collapsedIcon = treeUI.getCollapsedIcon(); + Icon expandeIcon = treeUI.getExpandedIcon(); + int w = collapsedIcon.getIconWidth(); + int h = collapsedIcon.getIconHeight(); + collapsedIcon.paintIcon(this, g, x, y); + g.drawRect(x, y, w, h); + + y += 10 + h; + w = expandeIcon.getIconWidth(); + h = expandeIcon.getIconHeight(); + expandeIcon.paintIcon(this, g, x, y); + g.drawRect(x, y, w, h); + + } + }; + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(panel, BorderLayout.CENTER); + } + }); + } +} diff --git a/test/javax/xml/ws/ebcdic/WsImportTest.java b/test/javax/xml/ws/ebcdic/WsImportTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7977cf98730700cbfb99c41c8f20c12daa412733 --- /dev/null +++ b/test/javax/xml/ws/ebcdic/WsImportTest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2014, 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 8038307 + * @summary JAX-WS conformance tests fail when running JCK-devtools-8 suite against RI in EBCDIC emulation mode + * @run main/othervm WsImportTest + */ + +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.BufferedReader; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import static java.nio.file.FileVisitResult.*; + +public class WsImportTest { + + public static void main(String[] args) throws IOException { + + String wsimport = getWsImport(); + String wsdl = getWSDLFilePath("test-service.wsdl"); + + try { + log("Importing wsdl: " + wsdl); + String[] wsargs = { + wsimport, + "-p", + "generated", + "-J-Dfile.encoding=Cp037", + wsdl + }; + + ProcessBuilder pb = new ProcessBuilder(wsargs); + pb.redirectErrorStream(true); + Process p = pb.start(); + logOutput(p); + int result = p.waitFor(); + p.destroy(); + + if (result != 0) { + fail("WsImport failed. TEST FAILED."); + } else { + log("Test PASSED."); + } + + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + deleteGeneratedFiles(); + } + } + + private static void fail(String message) { + throw new RuntimeException(message); + } + + private static void log(String msg) { + System.out.println(msg); + } + + private static void logOutput(Process p) throws IOException { + BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); + String s = r.readLine(); + while (s != null) { + log(s.trim()); + s = r.readLine(); + } + } + + private static void deleteGeneratedFiles() { + Path p = Paths.get("generated"); + if (Files.exists(p)) { + try { + Files.walkFileTree(p, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + + Files.delete(file); + return CONTINUE; + } + @Override + public FileVisitResult postVisitDirectory(Path dir, + IOException exc) throws IOException { + + if (exc == null) { + Files.delete(dir); + return CONTINUE; + } else { + throw exc; + } + } + }); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + } + + private static String getWSDLFilePath(String filename) { + String testSrc = System.getProperty("test.src"); + if (testSrc == null) testSrc = "."; + return Paths.get(testSrc).resolve(filename).toString(); + } + + private static String getWsImport() { + String javaHome = System.getProperty("java.home"); + if (javaHome.endsWith("jre")) { + javaHome = new File(javaHome).getParent(); + } + String wsimport = javaHome + File.separator + "bin" + File.separator + "wsimport"; + if (System.getProperty("os.name").startsWith("Windows")) { + wsimport = wsimport.concat(".exe"); + } + return wsimport; + } +} diff --git a/test/javax/xml/ws/ebcdic/test-service.wsdl b/test/javax/xml/ws/ebcdic/test-service.wsdl new file mode 100644 index 0000000000000000000000000000000000000000..10b2bdbd235194caacd4fe349da42a5c5b923690 --- /dev/null +++ b/test/javax/xml/ws/ebcdic/test-service.wsdl @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/sun/util/calendar/zi/tzdata/VERSION b/test/sun/util/calendar/zi/tzdata/VERSION index 8ab96a77e71215f15dee92049dbed3fa6ae8047f..1c96650f23131a13d06063228f25f003d5c2e951 100644 --- a/test/sun/util/calendar/zi/tzdata/VERSION +++ b/test/sun/util/calendar/zi/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2014a +tzdata2014b diff --git a/test/sun/util/calendar/zi/tzdata/africa b/test/sun/util/calendar/zi/tzdata/africa index 82d14a4a14d11c3325fbf1bcf52f2fd2a82cb90e..3198e1cc2094c44feac1e99a7e87eddde747960e 100644 --- a/test/sun/util/calendar/zi/tzdata/africa +++ b/test/sun/util/calendar/zi/tzdata/africa @@ -891,7 +891,10 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # Another source (specifying the time for start and end in the decree): # http://www.lemag.ma/Heure-d-ete-au-Maroc-jusqu-au-27-octobre_a75620.html -# From Paul Eggert (2013-10-03): +# From Sebastien Willemijns (2014-03-18): +# http://www.afriquinfos.com/articles/2014/3/18/maroc-heure-dete-avancez-tous-horloges-247891.asp + +# From Paul Eggert (2014-03-19): # To estimate what the Moroccan government will do in future years, # transition dates for 2014 through 2038 were determined by running # the following program under GNU Emacs 24.3: diff --git a/test/sun/util/calendar/zi/tzdata/antarctica b/test/sun/util/calendar/zi/tzdata/antarctica index f30cf747f10780b792d0dd25fdff1854c89940bd..e31bada94fb711b41f7bfba27d655c662d9b614e 100644 --- a/test/sun/util/calendar/zi/tzdata/antarctica +++ b/test/sun/util/calendar/zi/tzdata/antarctica @@ -253,24 +253,41 @@ Zone Antarctica/Syowa 0 - zzz 1957 Jan 29 # year-round base # Scott Base, Ross Island, since 1957-01. # See Pacific/Auckland. -# -# These rules for New Zealand are stolen from the 'australasia' file. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NZAQ 1974 only - Nov 3 2:00s 1:00 D -Rule NZAQ 1975 1988 - Oct lastSun 2:00s 1:00 D -Rule NZAQ 1989 only - Oct 8 2:00s 1:00 D -Rule NZAQ 1990 2006 - Oct Sun>=1 2:00s 1:00 D -Rule NZAQ 1975 only - Feb 23 2:00s 0 S -Rule NZAQ 1976 1989 - Mar Sun>=1 2:00s 0 S -Rule NZAQ 1990 2007 - Mar Sun>=15 2:00s 0 S -Rule NZAQ 2007 max - Sep lastSun 2:00s 1:00 D -Rule NZAQ 2008 max - Apr Sun>=1 2:00s 0 S # Norway - territories # Bouvet (never inhabited) # # claims # Peter I Island (never inhabited) +# +# year-round base +# Troll, Queen Maud Land, -720041+0023206, since 2005-02-12 +# +# From Paul-Inge Flakstad (2014-03-10): +# I recently had a long dialog about this with the developer of timegenie.com. +# In the absence of specific dates, he decided to choose some likely ones: +# GMT +1 - From March 1 to the last Sunday in March +# GMT +2 - From the last Sunday in March until the last Sunday in October +# GMT +1 - From the last Sunday in October until November 7 +# GMT +0 - From November 7 until March 1 +# The dates for switching to and from UTC+0 will probably not be absolutely +# correct, but they should be quite close to the actual dates. +# +# From Paul Eggert (2014-03-21): +# The CET-switching Troll rules require zic from tzcode 2014b or later, so as +# suggested by Bengt-Inge Larsson comment them out for now, and approximate +# with only UTC and CEST. Uncomment them when 2014b is more prevalent. +# +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +#Rule Troll 2005 max - Mar 1 1:00u 1:00 CET +Rule Troll 2005 max - Mar lastSun 1:00u 2:00 CEST +#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 CET +#Rule Troll 2004 max - Nov 7 1:00u 0:00 UTC +# Remove the following line when uncommenting the above '#Rule' lines. +Rule Troll 2004 max - Oct lastSun 1:00u 0:00 UTC +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone Antarctica/Troll 0 - zzz 2005 Feb 12 + 0:00 Troll %s # Poland - year-round base # Arctowski, King George Island, -620945-0582745, since 1977 diff --git a/test/sun/util/calendar/zi/tzdata/australasia b/test/sun/util/calendar/zi/tzdata/australasia index a0e8b5a2ce97edbf13e8d684723ab649f0b53047..94c9adb912c599e62ad8c29e7f4422135bec1a05 100644 --- a/test/sun/util/calendar/zi/tzdata/australasia +++ b/test/sun/util/calendar/zi/tzdata/australasia @@ -786,14 +786,29 @@ Zone Pacific/Funafuti 11:56:52 - LMT 1901 # Johnston # -# From Paul Eggert (2013-09-03): +# From Paul Eggert (2014-03-11): +# Sometimes Johnston kept Hawaii time, and sometimes it was an hour behind. +# Details are uncertain. We have no data for Johnston after 1970, so +# treat it like Hawaii for now. +# # In his memoirs of June 6th to October 4, 1945 # (2005), Herbert C. Bach writes, # "We started our letdown to Kwajalein Atoll and landed there at 5:00 AM # Johnston time, 1:30 AM Kwajalein time." This was in June 1945, and # confirms that Johnston kept the same time as Honolulu in summer 1945. -# We have no better information, so for now, assume this has been true -# indefinitely into the past. +# +# From Lyle McElhaney (2014-03-11): +# [W]hen JI was being used for that [atomic bomb] testing, the time being used +# was not Hawaiian time but rather the same time being used on the ships, +# which had a GMT offset of -11 hours. This apparently applied to at least the +# time from Operation Newsreel (Hardtack I/Teak shot, 1958-08-01) to the last +# Operation Fishbowl shot (Tightrope, 1962-11-04).... [See] Herman Hoerlin, +# "The United States High-Altitude Test Experience: A Review Emphasizing the +# Impact on the Environment", Los Alamos LA-6405, Oct 1976 +# . +# See the table on page 4 where he lists GMT and local times for the tests; a +# footnote for the JI tests reads that local time is "JI time = Hawaii Time +# Minus One Hour". # # See 'northamerica' for Pacific/Johnston. diff --git a/test/sun/util/calendar/zi/tzdata/europe b/test/sun/util/calendar/zi/tzdata/europe index 585e64d14fa713a22cae5be7bf2bb7025cc02d0f..2b0c5613e6098a5aaea07f68e2e5afabfe93daad 100644 --- a/test/sun/util/calendar/zi/tzdata/europe +++ b/test/sun/util/calendar/zi/tzdata/europe @@ -2986,7 +2986,11 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 # Assume it happened in March by not changing the clocks. 3:00 Russia MSK/MSD 1997 3:00 - MSK 1997 Mar lastSun 1:00u - 2:00 EU EE%sT +# From Alexander Krivenyshev (2014-03-17): +# time change at 2:00 (2am) on March 30, 2014 +# http://vz.ru/news/2014/3/17/677464.html + 2:00 EU EE%sT 2014 Mar 30 2:00 + 4:00 - MSK # Vatican City # See Europe/Rome. diff --git a/test/sun/util/calendar/zi/tzdata/leapseconds b/test/sun/util/calendar/zi/tzdata/leapseconds index faf5319d408b2f152d72b442ed27bcad95c73d9d..b423135b942d092c4a8f24eaac19f3c8db1bf021 100644 --- a/test/sun/util/calendar/zi/tzdata/leapseconds +++ b/test/sun/util/calendar/zi/tzdata/leapseconds @@ -20,7 +20,7 @@ # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. - +# # Allowance for leapseconds added to each timezone file. # This file is in the public domain. diff --git a/test/sun/util/calendar/zi/tzdata/zone.tab b/test/sun/util/calendar/zi/tzdata/zone.tab index b34cdb0dc7da153e903d33b908e637d34a897dbf..7cec627fd95862053bc8c9cd5e991a1309a42f6d 100644 --- a/test/sun/util/calendar/zi/tzdata/zone.tab +++ b/test/sun/util/calendar/zi/tzdata/zone.tab @@ -74,6 +74,7 @@ AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I +AQ -720041+0023206 Antarctica/Troll Troll Station, Queen Maud Land AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF) AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN) @@ -366,6 +367,7 @@ RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad RU +5545+03735 Europe/Moscow Moscow+00 - west Russia RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea RU +5312+05009 Europe/Samara Moscow+00 - Samara, Udmurtia +RU +4457+03406 Europe/Simferopol Moscow+00 - Crimea RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk @@ -421,7 +423,6 @@ TZ -0648+03917 Africa/Dar_es_Salaam UA +5026+03031 Europe/Kiev most locations UA +4837+02218 Europe/Uzhgorod Ruthenia UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk -UA +4457+03406 Europe/Simferopol central Crimea UG +0019+03225 Africa/Kampala UM +1645-16931 Pacific/Johnston Johnston Atoll UM +2813-17722 Pacific/Midway Midway Islands