提交 b1c852da 编写于 作者: D dholmes

Merge

......@@ -195,3 +195,4 @@ a996b57e554198f4592a5f3c30f2f9f4075e545d jdk8-b70
2a5af0f766d0acd68a81fb08fe11fd66795f86af jdk8-b71
32a57e645e012a1f0665c075969ca598e0dbb948 jdk8-b72
733885f57e14cc27f5a5ff0dffe641d2fa3c704a jdk8-b73
57d5d954462831ac353a1f40d3bb05ddb4620952 jdk8-b74
......@@ -237,6 +237,9 @@ SUBDIRS = tools java javax sun com jdk
ifeq ($(PLATFORM), macosx)
SUBDIRS += apple
endif
ifeq ($(PLATFORM), windows)
SUBDIRS += bridge
endif
SUBDIRS_tools = launchers
SUBDIRS_misc = org jpda
......
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building AccessBridge
#
BUILDDIR = ../..
PRODUCT = java
PACKAGE = com.sun.java.accessibility
include $(BUILDDIR)/common/Defs.gmk
JARFILE = $(EXTDIR)/access-bridge$(ABSUFFIX).jar
ifeq ($(ARCH_DATA_MODEL), 64)
ABPLATFORM = 64bit
ABSUFFIX = -64
else
ifeq ($(ARCH_DATA_MODEL), 32)
ifdef ABLEGACY
ABSUFFIX =
ABPLATFORM = legacy
else
ABPLATFORM = 32bit
ABSUFFIX = -32
endif
endif
endif
#
# Java files to compile.
#
FILES_java = com/sun/java/accessibility/AccessBridge.java
#
# Location for the newly built classfiles.
#
CLASSDESTDIR = $(TEMPDIR)/classes
#
# Rules
#
CLASSDESTDIR = $(TEMPDIR)/classes
FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)
build: prebuild
prebuild:
$(CP) $(CLOSED_PLATFORM_SRC)/classes/com/sun/java/accessibility/$(ABPLATFORM)/AccessBridge.java \
$(CLOSED_PLATFORM_SRC)/classes/com/sun/java/accessibility
all : build $(JARFILE)
#
# JAR file
#
$(JARFILE): \
$(FILES_class)
$(BOOT_JAR_CMD) -cf $(JARFILE) \
-C $(CLASSDESTDIR) com \
$(BOOT_JAR_JFLAGS)
@$(java-vm-cleanup)
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
clean clobber::
$(RM) -r $(CLASSDESTDIR) \
$(EXTDIR)/$(JARFILE)
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Native files to compile.
FILES_cpp = \
JAWTAccessBridge.cpp
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building JAWTAccessBridge
#
BUILDDIR = ../..
LIBRARY = JAWTAccessBridge$(ABSUFFIX)
include $(BUILDDIR)/common/Defs.gmk
# Indicate we want the C++ compiler to do the linking.
CPLUSPLUSLIBRARY=true
ifeq ($(ARCH_DATA_MODEL), 64)
ABSUFFIX = -64
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_64
ABRIDGE_MACHINE=X64
else
ifeq ($(ARCH_DATA_MODEL), 32)
ABRIDGE_MACHINE=I386
ifdef ABLEGACY
ABSUFFIX =
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_LEGACY
else
ABSUFFIX = -32
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_32
endif
endif
endif
include FILES_cpp.gmk
VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc
OTHER_CPPFLAGS += -D$(ACCESSBRIDGE_ARCH) -I "$(INCLUDEDIR)" -I "$(PLATFORM_INCLUDE)"
LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
uuid.lib odbc32.lib odbccp32.lib /subsystem:windows /dll /incremental:no /machine:$(ABRIDGE_MACHINE) \
/def:$(CLOSED_PLATFORM_SRC)/native/sun/bridge/JAWTAccessBridge.DEF /libpath:"$(LIBDIR)"
#
# Rules
#
include $(BUILDDIR)/common/Library.gmk
vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.RC $(CLOSED_PLATFORM_SRC)/native/sun/bridge
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building jabswitch.exe
#
BUILDDIR = ../..
PROGRAM = jabswitch
include $(BUILDDIR)/common/Defs.gmk
# Indicate we want the C++ compiler to do the linking.
CPLUSPLUSLIBRARY=true
VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc
VERSIONRES = $(TEMPDIR)/AccessBridgeStatusWindow.res
JAB_EXE= $(TEMPDIR)/jabswitch.exe
JAB_SRC = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/jabswitch.cpp
JAB_MANIFEST_INP = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/jabswitch.manifest
JAB_MANIFEST_OUT = $(TEMPDIR)/jabswitch.exe.intermediate.manifest
RC_FLAGS += /fo "$(VERSIONRES)"
OTHER_CPPFLAGS += /MD /Fo"$(TEMPDIR)/" /Fd"$(TEMPDIR)/" /analyze- /Od /Gd /nologo /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /RTC1 /W3 /ZI /Zc:wchar_t /EHsc
LDDFLAGS += Advapi32.lib Version.lib User32.lib
all: buildexe copyfilejab
buildexe :
$(CD) $(TEMPDIR)
$(RC) $(RC_FLAGS) $(VERSIONINFO_RESOURCE)
$(CC) $(CPPFLAGS) $(JAB_SRC) $(LDDFLAGS) $(VERSIONRES) -o $(JAB_EXE)
$(MT) /nologo /verbose /manifest $(JAB_MANIFEST_INP) /outputresource:$(JAB_EXE)
copyfilejab :
$(CP) $(JAB_EXE) $(BINDIR)
vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.rc $(CLOSED_PLATFORM_SRC)/native/sun/bridge
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building jaccess
#
BUILDDIR = ../..
PRODUCT = java
PACKAGE = com.sun.java.accessibility.jaccess
include $(BUILDDIR)/common/Defs.gmk
JARFILE = $(EXTDIR)/jaccess.jar
#
# Java files to compile.
#
#AUTO_FILES_JAVA_DIRS = $(CLOSED_PLATFORM_SRC)/bridge
FILES_java = \
com/sun/java/accessibility/util/AccessibilityEventMonitor.java \
com/sun/java/accessibility/util/AccessibilityListenerList.java \
com/sun/java/accessibility/util/AWTEventMonitor.java \
com/sun/java/accessibility/util/EventID.java \
com/sun/java/accessibility/util/EventQueueMonitor.java \
com/sun/java/accessibility/util/GUIInitializedListener.java \
com/sun/java/accessibility/util/GUIInitializedMulticaster.java \
com/sun/java/accessibility/util/SwingEventMonitor.java \
com/sun/java/accessibility/util/TopLevelWindowListener.java \
com/sun/java/accessibility/util/TopLevelWindowMulticaster.java \
com/sun/java/accessibility/util/Translator.java \
com/sun/java/accessibility/util/java/awt/ButtonTranslator.java \
com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java \
com/sun/java/accessibility/util/java/awt/LabelTranslator.java \
com/sun/java/accessibility/util/java/awt/ListTranslator.java \
com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java
#
# Rules
#
CLASSDESTDIR = $(TEMPDIR)/classes
FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)
all : build $(JARFILE)
#
# JAR file
#
$(JARFILE): \
$(FILES_class)
$(BOOT_JAR_CMD) -cf $(JARFILE) \
-C $(CLASSDESTDIR) com \
$(BOOT_JAR_JFLAGS)
@$(java-vm-cleanup)
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
clean clobber::
$(RM) -r $(CLASSDESTDIR) \
$(EXTDIR)/$(JARFILE)
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Native files to compile.
FILES_cpp = \
AccessBridgeATInstance.cpp \
AccessBridgeDebug.cpp \
AccessBridgeJavaEntryPoints.cpp \
AccessBridgeMessages.cpp \
JavaAccessBridge.cpp
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building JavaAccessBridge.DLL
#
BUILDDIR = ../..
LIBRARY = JavaAccessBridge$(ABSUFFIX)
include $(BUILDDIR)/common/Defs.gmk
# Indicate we want the C++ compiler to do the linking.
CPLUSPLUSLIBRARY=true
ifeq ($(ARCH_DATA_MODEL), 64)
ABSUFFIX = -64
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_64
ABRIDGE_MACHINE=X64
else
ifeq ($(ARCH_DATA_MODEL), 32)
ABRIDGE_MACHINE=I386
ifdef ABLEGACY
ABSUFFIX =
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_LEGACY
else
ABSUFFIX = -32
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_32
endif
endif
endif
include FILES_cpp.gmk
PLATFORM_INCLUDE_BRIDGE = $(PLATFORM_INCLUDE)/bridge
VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc
OTHER_CPPFLAGS += -D$(ACCESSBRIDGE_ARCH) -I "$(INCLUDEDIR)" -I "$(PLATFORM_INCLUDE)"
LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
odbc32.lib odbccp32.lib /subsystem:windows /dll /incremental:no /machine:$(ABRIDGE_MACHINE) \
/def:$(CLOSED_PLATFORM_SRC)/native/sun/bridge/JavaAccessBridge.DEF /libpath:"$(LIBDIR)"
all : build postbuild
postbuild :
$(MKDIR) -p $(PLATFORM_INCLUDE_BRIDGE)
$(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/accessibility.properties $(LIBDIR)
$(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeCallbacks.h $(PLATFORM_INCLUDE_BRIDGE)
$(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeCalls.h $(PLATFORM_INCLUDE_BRIDGE)
$(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgePackages.h $(PLATFORM_INCLUDE_BRIDGE)
$(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeCalls.c $(PLATFORM_INCLUDE_BRIDGE)
#
# Rules
#
include $(BUILDDIR)/common/Library.gmk
vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.DEF $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.rc $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.c $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.h $(CLOSED_PLATFORM_SRC)/native/sun/bridge
#
# Extra clean rule.
#
clean clobber::
$(RM) $(FILES_h)
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building Java Access Bridge
#
BUILDDIR = ..
include $(BUILDDIR)/common/Defs.gmk
#
#
ifndef OPENJDK
ifeq ($(PLATFORM), windows)
include $(BUILDDIR)/common/Subdirs.gmk
#
# build for 32 and 64 bit (new api)
#
SUBDIRS = Jaccess JavaAccessBridge WindowsAccessBridge JAWTAccessBridge AccessBridgeJava Jabswitch
#
# build for legacy
#
ifeq ($(ARCH_DATA_MODEL), 32)
OTHERSUBDIRS_MAKEFLAGS += ABLEGACY=true
OTHERSUBDIRS = JavaAccessBridge WindowsAccessBridge JAWTAccessBridge AccessBridgeJava
endif
ifeq ($(ARCH_DATA_MODEL), 32)
all build clean clobber ::
$(SUBDIRS-loop)
$(OTHERSUBDIRS-loop)
else
all build clean clobber ::
$(SUBDIRS-loop)
endif
clean::
$(RM) -r $(CLASSBINDIR) $(CLASSBINDIR)
endif # PLATFORM
endif #OPENJDK
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Native files to compile.
FILES_cpp = \
AccessBridgeJavaVMInstance.cpp \
AccessBridgeMessageQueue.cpp \
AccessBridgeMessages.cpp \
AccessBridgeWindowsEntryPoints.cpp \
WinAccessBridge.cpp \
AccessBridgeDebug.cpp \
AccessBridgeEventHandler.cpp
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building WindowsAccessBridge.dll
#
BUILDDIR = ../..
LIBRARY = WindowsAccessBridge$(ABSUFFIX)
include $(BUILDDIR)/common/Defs.gmk
# Indicate we want the C++ compiler to do the linking.
CPLUSPLUSLIBRARY=true
ifeq ($(ARCH_DATA_MODEL), 64)
ABSUFFIX = -64
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_64
ABRIDGE_MACHINE=X64
else
ifeq ($(ARCH_DATA_MODEL), 32)
ABRIDGE_MACHINE=I386
ifdef ABLEGACY
ABSUFFIX =
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_LEGACY
else
ABSUFFIX = -32
ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_32
endif
endif
endif
include FILES_cpp.gmk
VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc
OTHER_CPPFLAGS += -MT -D$(ACCESSBRIDGE_ARCH) -I "$(INCLUDEDIR)" -I "$(PLATFORM_INCLUDE)"
LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib \
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /subsystem:windows /dll /incremental:no /machine:$(ABRIDGE_MACHINE) \
/def:$(CLOSED_PLATFORM_SRC)/native/sun/bridge/WinAccessBridge.DEF /libpath:"$(LIBDIR)"
#
# Rules
#
include $(BUILDDIR)/common/Library.gmk
vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.DEF $(CLOSED_PLATFORM_SRC)/native/sun/bridge
vpath %.rc $(CLOSED_PLATFORM_SRC)/native/sun/bridge
......@@ -211,7 +211,9 @@ ifeq ($(ARCH_FAMILY),sparc)
MAPFILE_EXCEPTIONS = \
(libjdgaSUNWafb|libjdgaSUNWcg6|libjdgaSUNWffb|libjdgaSUNWm64|libxinerama)
else
MAPFILE_EXCEPTIONS = ()
# At present there are no exceptions for non
# SPARC. Use a harmless value.
MAPFILE_EXCEPTIONS = (NO_EXCEPTIONS)
endif
# Macro to check it's input file for banned dependencies and verify the
......
......@@ -127,6 +127,11 @@ CORE_PKGS = \
java.sql \
java.text \
java.text.spi \
java.time \
java.time.temporal \
java.time.calendar \
java.time.format \
java.time.zone \
java.util \
java.util.concurrent \
java.util.concurrent.atomic \
......
......@@ -207,6 +207,7 @@ COMMON_JAVADOCFLAGS = \
-quiet \
-use \
-keywords \
-Xdoclint:none \
-Xprofilespath $(JDK_TOPDIR)/makefiles/profile-rtjar-includes.txt \
$(ADDITIONAL_JAVADOCFLAGS)
......
......@@ -39,7 +39,7 @@ SUBDIRS += version jvm redist verify fdlibm java sun_nio jli main zip
# Others
# Note: java_crw_demo java_hprof_demo are demos but must be delivered built in sdk
SUBDIRS += security math util text net nio jar
SUBDIRS += security math util text net nio jar time
SUBDIRS_desktop = awt applet beans
SUBDIRS_management = management
......
#
# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2013, 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
......@@ -57,6 +57,7 @@ FILES_export = \
java/lang/reflect/Constructor.java \
java/lang/reflect/InvocationTargetException.java \
java/lang/reflect/Array.java \
java/lang/reflect/Executable.java \
java/lang/reflect/Proxy.java \
java/security/AccessController.java \
java/util/Date.java \
......@@ -129,6 +130,7 @@ FILES_export = \
java/lang/reflect/Constructor.java \
java/lang/reflect/InvocationTargetException.java \
java/lang/reflect/Array.java \
java/lang/reflect/Executable.java \
java/lang/reflect/Proxy.java \
java/lang/ref/Reference.java \
java/lang/ref/Finalizer.java \
......
#
# Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1996, 2013, 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
......@@ -32,6 +32,7 @@ FILES_c = \
Compiler.c \
Console_md.c \
Double.c \
Executable.c \
FileDescriptor_md.c \
FileInputStream.c \
FileInputStream_md.c \
......
......@@ -137,6 +137,7 @@ JAVA_JAVA_java = \
java/lang/Appendable.java \
java/lang/Comparable.java \
java/lang/Readable.java \
java/lang/FunctionalInterface.java \
java/lang/Override.java \
java/lang/SafeVarargs.java \
java/lang/SuppressWarnings.java \
......@@ -227,6 +228,7 @@ JAVA_JAVA_java = \
sun/util/locale/provider/LocaleResources.java \
sun/util/locale/provider/NumberFormatProviderImpl.java \
sun/util/locale/provider/RuleBasedBreakIterator.java \
sun/util/locale/provider/ResourceBundleBasedAdapter.java \
sun/util/locale/provider/SPILocaleProviderAdapter.java \
sun/util/locale/provider/TimeZoneNameProviderImpl.java \
sun/util/locale/provider/TimeZoneNameUtility.java \
......@@ -372,6 +374,11 @@ JAVA_JAVA_java = \
java/util/concurrent/atomic/AtomicReferenceArray.java \
java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java \
java/util/concurrent/atomic/AtomicStampedReference.java \
java/util/concurrent/atomic/DoubleAccumulator.java \
java/util/concurrent/atomic/DoubleAdder.java \
java/util/concurrent/atomic/LongAccumulator.java \
java/util/concurrent/atomic/LongAdder.java \
java/util/concurrent/atomic/Striped64.java \
java/util/concurrent/locks/AbstractOwnableSynchronizer.java \
java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java \
java/util/concurrent/locks/AbstractQueuedSynchronizer.java \
......
#
# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2013, 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
......@@ -189,6 +189,7 @@ SUNWprivate_1.1 {
Java_java_lang_reflect_Array_setInt;
Java_java_lang_reflect_Array_setLong;
Java_java_lang_reflect_Array_setShort;
Java_java_lang_reflect_Executable_getParameters0;
Java_java_lang_Runtime_freeMemory;
Java_java_lang_Runtime_maxMemory;
Java_java_lang_Runtime_gc;
......
#
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building jar utility.
#
BUILDDIR = ../../
PACKAGE = java.time
include $(BUILDDIR)/common/Defs.gmk
#
# Files
#
AUTO_FILES_JAVA_DIRS = java/time
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
......@@ -87,6 +87,7 @@ jprt.make.rule.core.test.targets= \
${jprt.my.test.target.set:TESTNAME=jdk_text}, \
${jprt.my.test.target.set:TESTNAME=jdk_tools}, \
${jprt.my.test.target.set:TESTNAME=jdk_jfr}, \
${jprt.my.test.target.set:TESTNAME=jdk_time}, \
${jprt.my.test.target.set:TESTNAME=jdk_other}
# All vm test targets (testset=all)
......
......@@ -70,7 +70,7 @@ else
endif
# nio need to be compiled before awt to have all charsets ready
SUBDIRS = jar security javazic misc net nio text util launcher cldr
SUBDIRS = jar security javazic misc net nio text util launcher cldr tzdb
ifdef BUILD_HEADLESS_ONLY
DISPLAY_LIBS = awt $(HEADLESS_SUBDIR)
......
#
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building tzdb compiler utility.
#
BUILDDIR = ../..
PACKAGE = sun.tzdb
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Time zone data file creation
#
TZDATA_DIR := ../javazic/tzdata
TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION))
TZFILE := africa antarctica asia australasia europe northamerica southamerica backward etcetera
TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZFILE))
TZDB_JAR = tzdb.jar
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
#
# Add to the build rule
#
build: $(LIBDIR)/$(TZDB_JAR)
$(LIBDIR)/$(TZDB_JAR): $(TZFILES)
$(prep-target)
echo build tzdb from version $(TZDATA_VER)
$(BOOT_JAVA_CMD) -jar $(BUILDTOOLJARDIR)/tzdb.jar -verbose \
-version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(LIBDIR) $(TZFILE)
clean clobber::
$(RM) $(LIBDIR)/$(TZDB_JAR)
......@@ -53,6 +53,7 @@ SUBDIRS = \
makeclasslist \
strip_properties \
spp \
tzdb \
CharsetMapping
ifndef DISABLE_NIMBUS
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, 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
......@@ -274,7 +274,7 @@ class Bundle {
handleDateTimeFormatPatterns(DATETIME_PATTERN_KEYS, myMap, parentsMap, calendarType, "DateTimePatterns");
}
// if myMap has any empty timezone or metazone names, weed out them.
// First, weed out any empty timezone or metazone names from myMap.
// Fill in any missing abbreviations if locale is "en".
for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
String key = it.next();
......@@ -426,7 +426,7 @@ class Bundle {
/*
* Adjusts String[] for era names because JRE's Calendars use different
* ERA value indexes in the Buddhist and Japanese Imperial calendars.
* ERA value indexes in the Buddhist, Japanese Imperial, and Islamic calendars.
*/
private void adjustEraNames(Map<String, Object> map, CalendarType type) {
String[][] eraNames = new String[ERA_KEYS.length][];
......@@ -458,6 +458,11 @@ class Bundle {
// Replace the value
value = new String[] {"BC", value[0]};
break;
case ISLAMIC:
// Replace the value
value = new String[] {"", value[0]};
break;
}
if (!key.equals(realKey)) {
map.put(realKey, value);
......@@ -479,6 +484,7 @@ class Bundle {
for (String k : patternKeys) {
if (myMap.containsKey(calendarPrefix + k)) {
int len = patternKeys.length;
List<String> rawPatterns = new ArrayList<>();
List<String> patterns = new ArrayList<>();
for (int i = 0; i < len; i++) {
String key = calendarPrefix + patternKeys[i];
......@@ -487,6 +493,7 @@ class Bundle {
pattern = (String) parentsMap.remove(key);
}
if (pattern != null) {
rawPatterns.add(i, pattern);
patterns.add(i, translateDateFormatLetters(calendarType, pattern));
}
}
......@@ -494,6 +501,9 @@ class Bundle {
return;
}
String key = calendarPrefix + name;
if (!rawPatterns.equals(patterns)) {
myMap.put("cldr." + key, rawPatterns.toArray(new String[len]));
}
myMap.put(key, patterns.toArray(new String[len]));
break;
}
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, 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
......@@ -58,6 +58,7 @@ public class CLDRConverter {
static final String LOCALE_NAME_PREFIX = "locale.displayname.";
static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol.";
static final String CURRENCY_NAME_PREFIX = "currency.displayname.";
static final String CALENDAR_NAME_PREFIX = "calendarname.";
static final String TIMEZONE_ID_PREFIX = "timezone.id.";
static final String ZONE_NAME_PREFIX = "timezone.displayname.";
static final String METAZONE_ID_PREFIX = "metazone.id.";
......@@ -519,35 +520,70 @@ public class CLDRConverter {
return calendarData;
}
static final String[] FORMAT_DATA_ELEMENTS = {
"MonthNames",
"standalone.MonthNames",
"MonthAbbreviations",
"standalone.MonthAbbreviations",
"MonthNarrow",
"standalone.MonthNarrows",
"DayNames",
"standalone.DayNames",
"DayAbbreviations",
"standalone.DayAbbreviations",
"DayNarrows",
"standalone.DayNarrows",
"AmPmMarkers",
"narrow.AmPmMarkers",
"long.Eras",
"Eras",
"narrow.Eras",
"field.era",
"field.year",
"field.month",
"field.week",
"field.weekday",
"field.dayperiod",
"field.hour",
"field.minute",
"field.second",
"field.zone",
"TimePatterns",
"DatePatterns",
"DateTimePatterns",
"DateTimePatternChars"
};
private static Map<String, Object> extractFormatData(Map<String, Object> map, String id) {
Map<String, Object> formatData = new LinkedHashMap<>();
for (CalendarType calendarType : CalendarType.values()) {
String prefix = calendarType.keyElementName();
copyIfPresent(map, prefix + "MonthNames", formatData); // default FORMAT since JDK8
copyIfPresent(map, prefix + "standalone.MonthNames", formatData);
copyIfPresent(map, prefix + "MonthAbbreviations", formatData);
copyIfPresent(map, prefix + "standalone.MonthAbbreviations", formatData);
copyIfPresent(map, prefix + "MonthNarrow", formatData);
copyIfPresent(map, prefix + "standalone.MonthNarrows", formatData);
copyIfPresent(map, prefix + "DayNames", formatData);
copyIfPresent(map, prefix + "standalone.DayNames", formatData);
copyIfPresent(map, prefix + "DayAbbreviations", formatData);
copyIfPresent(map, prefix + "standalone.DayAbbreviations", formatData);
copyIfPresent(map, prefix + "DayNarrows", formatData);
copyIfPresent(map, prefix + "standalone.DayNarrows", formatData);
copyIfPresent(map, prefix + "AmPmMarkers", formatData);
copyIfPresent(map, prefix + "narrow.AmPmMarkers", formatData);
copyIfPresent(map, prefix + "long.Eras", formatData);
copyIfPresent(map, prefix + "Eras", formatData);
copyIfPresent(map, prefix + "narrow.Eras", formatData);
copyIfPresent(map, prefix + "TimePatterns", formatData);
copyIfPresent(map, prefix + "DatePatterns", formatData);
copyIfPresent(map, prefix + "DateTimePatterns", formatData);
copyIfPresent(map, prefix + "DateTimePatternChars", formatData);
for (String element : FORMAT_DATA_ELEMENTS) {
String key = prefix + element;
copyIfPresent(map, "cldr." + key, formatData);
copyIfPresent(map, key, formatData);
}
}
// Copy available calendar names
for (String key : map.keySet()) {
if (key.startsWith(CLDRConverter.CALENDAR_NAME_PREFIX)) {
String type = key.substring(CLDRConverter.CALENDAR_NAME_PREFIX.length());
for (CalendarType calendarType : CalendarType.values()) {
if (type.equals(calendarType.lname())) {
Object value = map.get(key);
formatData.put(key, value);
String ukey = CLDRConverter.CALENDAR_NAME_PREFIX + calendarType.uname();
if (!key.equals(ukey)) {
formatData.put(ukey, value);
}
}
}
}
}
copyIfPresent(map, "DefaultNumberingSystem", formatData);
String defaultScript = (String) map.get("DefaultNumberingSystem");
@SuppressWarnings("unchecked")
List<String> numberingScripts = (List<String>) map.remove("numberingScripts");
if (numberingScripts != null) {
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -31,26 +31,42 @@ import java.util.Locale;
* Constants for the Calendars supported by JRE.
*/
enum CalendarType {
GREGORIAN, BUDDHIST, JAPANESE;
GREGORIAN("gregory"), BUDDHIST, JAPANESE, ROC, ISLAMIC, ISLAMIC_CIVIL("islamicc");
private static final int[][] ERA_DATA = {
// start index, array length
{0, 2}, // gregorian
{0, 1}, // buddhist
{232, 4}, // japanese (eras from Meiji)
{0, 2}, // roc (Minguo)
{0, 1}, // islamic (Hijrah)
{0, 1}, // islamicc (same as islamic)
};
private final String lname; // lowercase name
private final String uname; // unicode key name (e.g., "gregory" for GREGORIAN)
private CalendarType() {
lname = name().toLowerCase(Locale.ROOT);
this(null);
}
private CalendarType(String uname) {
String lname = name().toLowerCase(Locale.ROOT);
if (lname.equals("islamic_civil")) {
lname = "islamic-civil";
}
this.lname = lname;
this.uname = (uname != null) ? uname : lname;
}
String lname() {
return lname;
}
String uname() {
return uname;
}
String keyElementName() {
return (this == GREGORIAN) ? "" : lname + ".";
}
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, 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
......@@ -71,6 +71,13 @@ class LDMLParseHandler extends AbstractLDMLHandler<Object> {
// ignore this element - it has language and territory elements that aren't locale data
pushIgnoredContainer(qName);
break;
case "type":
if ("calendar".equals(attributes.getValue("key"))) {
pushStringEntry(qName, attributes, CLDRConverter.CALENDAR_NAME_PREFIX + attributes.getValue("type"));
} else {
pushIgnoredContainer(qName);
}
break;
case "language":
// for LocaleNames
// copy string
......@@ -98,20 +105,31 @@ class LDMLParseHandler extends AbstractLDMLHandler<Object> {
case "symbol":
// for CurrencyNames
// need to get the key from the containing <currency> element
pushStringEntry(qName, attributes, CLDRConverter.CURRENCY_SYMBOL_PREFIX + getContainerKey());
pushStringEntry(qName, attributes, CLDRConverter.CURRENCY_SYMBOL_PREFIX
+ getContainerKey());
break;
// Calendar or currency
case "displayName":
{
if (currentCalendarType != null) {
pushStringEntry(qName, attributes,
currentCalendarType.keyElementName() + "field." + getContainerKey());
} else {
// for CurrencyNames
// need to get the key from the containing <currency> element
// ignore if is has "count" attribute
String containerKey = getContainerKey();
if (containerKey != null && attributes.getValue("count") == null) {
pushStringEntry(qName, attributes,
CLDRConverter.CURRENCY_NAME_PREFIX + containerKey.toLowerCase(Locale.ROOT),
CLDRConverter.CURRENCY_NAME_PREFIX
+ containerKey.toLowerCase(Locale.ROOT),
attributes.getValue("type"));
} else {
pushIgnoredContainer(qName);
}
}
}
break;
//
......@@ -130,6 +148,35 @@ class LDMLParseHandler extends AbstractLDMLHandler<Object> {
}
}
break;
case "fields":
if (currentCalendarType != null) {
pushContainer(qName, attributes);
} else {
pushIgnoredContainer(qName);
}
break;
case "field":
{
String type = attributes.getValue("type");
switch (type) {
case "era":
case "year":
case "month":
case "week":
case "weekday":
case "dayperiod":
case "hour":
case "minute":
case "second":
case "zone":
pushKeyContainer(qName, attributes, type);
break;
default:
pushIgnoredContainer(qName);
break;
}
}
break;
case "monthContext":
{
// for FormatData
......
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
/**
* A standard set of date/time fields.
*
* @since 1.8
*/
enum ChronoField {
/**
* The second-of-minute.
* <p>
* This counts the second within the minute, from 0 to 59.
* This field has the same meaning for all calendar systems.
*/
SECOND_OF_MINUTE("SecondOfMinute", 0, 59),
/**
* The second-of-day.
* <p>
* This counts the second within the day, from 0 to (24 * 60 * 60) - 1.
* This field has the same meaning for all calendar systems.
*/
SECOND_OF_DAY("SecondOfDay", 0, 86400 - 1),
/**
* The minute-of-hour.
* <p>
* This counts the minute within the hour, from 0 to 59.
* This field has the same meaning for all calendar systems.
*/
MINUTE_OF_HOUR("MinuteOfHour", 0, 59),
/**
* The hour-of-day.
* <p>
* This counts the hour within the day, from 0 to 23.
* This is the hour that would be observed on a standard 24-hour digital clock.
* This field has the same meaning for all calendar systems.
*/
HOUR_OF_DAY("HourOfDay", 0, 23),
/**
* The day-of-month.
* <p>
* This represents the concept of the day within the month.
* In the default ISO calendar system, this has values from 1 to 31 in most months.
* April, June, September, November have days from 1 to 30, while February has days
* from 1 to 28, or 29 in a leap year.
* <p>
* Non-ISO calendar systems should implement this field using the most recognized
* day-of-month values for users of the calendar system.
* Normally, this is a count of days from 1 to the length of the month.
*/
DAY_OF_MONTH("DayOfMonth", 1, 31),
/**
* The month-of-year, such as March.
* <p>
* This represents the concept of the month within the year.
* In the default ISO calendar system, this has values from January (1) to December (12).
* <p>
* Non-ISO calendar systems should implement this field using the most recognized
* month-of-year values for users of the calendar system.
* Normally, this is a count of months starting from 1.
*/
MONTH_OF_YEAR("MonthOfYear", 1, 12),
/**
* The proleptic year, such as 2012.
* <p>
* This represents the concept of the year, counting sequentially and using negative numbers.
* The proleptic year is not interpreted in terms of the era.
* See {@link #YEAR_OF_ERA} for an example showing the mapping from proleptic year to year-of-era.
* <p>
* The standard mental model for a date is based on three concepts - year, month and day.
* These map onto the {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields.
* Note that there is no reference to eras.
* The full model for a date requires four concepts - era, year, month and day. These map onto
* the {@code ERA}, {@code YEAR_OF_ERA}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields.
* Whether this field or {@code YEAR_OF_ERA} is used depends on which mental model is being used.
* See {@link ChronoLocalDate} for more discussion on this topic.
* <p>
* Non-ISO calendar systems should implement this field as follows.
* If the calendar system has only two eras, before and after a fixed date, then the
* proleptic-year value must be the same as the year-of-era value for the later era,
* and increasingly negative for the earlier era.
* If the calendar system has more than two eras, then the proleptic-year value may be
* defined with any appropriate value, although defining it to be the same as ISO may be
* the best option.
*/
YEAR("Year", -999_999_999, 999_999_999);
private final String name;
private final int min;
private final int max;
private ChronoField(String name, int min, int max) {
this.name = name;
this.min= min;
this.max= max;
}
/**
* Checks that the specified value is valid for this field.
* <p>
*
* @param value the value to check
* @return the value that was passed in
*/
public int checkValidValue(int value) {
if (value >= min && value <= max) {
return value;
}
throw new DateTimeException("Invalid value for " + name + " value: " + value);
}
public String toString() {
return name;
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
/**
* Exception used to indicate a problem while calculating a date-time.
* <p>
* This exception is used to indicate problems with creating, querying
* and manipulating date-time objects.
*
* @since 1.8
*/
class DateTimeException extends RuntimeException {
/**
* Serialization version.
*/
private static final long serialVersionUID = -1632418723876261839L;
/**
* Constructs a new date-time exception with the specified message.
*
* @param message the message to use for this exception, may be null
*/
public DateTimeException(String message) {
super(message);
}
/**
* Constructs a new date-time exception with the specified message and cause.
*
* @param message the message to use for this exception, may be null
* @param cause the cause of the exception, may be null
*/
public DateTimeException(String message, Throwable cause) {
super(message, cause);
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import static build.tools.tzdb.Utils.*;
import static build.tools.tzdb.LocalTime.SECONDS_PER_DAY;
import static build.tools.tzdb.ChronoField.DAY_OF_MONTH;
import static build.tools.tzdb.ChronoField.MONTH_OF_YEAR;
import static build.tools.tzdb.ChronoField.YEAR;
import java.util.Objects;
/**
* A date without a time-zone in the ISO-8601 calendar system,
* such as {@code 2007-12-03}.
*
* @since 1.8
*/
final class LocalDate {
/**
* The minimum supported {@code LocalDate}, '-999999999-01-01'.
* This could be used by an application as a "far past" date.
*/
public static final LocalDate MIN = new LocalDate(YEAR_MIN_VALUE, 1, 1);
/**
* The maximum supported {@code LocalDate}, '+999999999-12-31'.
* This could be used by an application as a "far future" date.
*/
public static final LocalDate MAX = new LocalDate(YEAR_MAX_VALUE, 12, 31);
/**
* The number of days in a 400 year cycle.
*/
private static final int DAYS_PER_CYCLE = 146097;
/**
* The number of days from year zero to year 1970.
* There are five 400 year cycles from year zero to 2000.
* There are 7 leap years from 1970 to 2000.
*/
static final long DAYS_0000_TO_1970 = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L);
/**
* The year.
*/
private final int year;
/**
* The month-of-year.
*/
private final short month;
/**
* The day-of-month.
*/
private final short day;
/**
* Obtains an instance of {@code LocalDate} from a year, month and day.
* <p>
* The day must be valid for the year and month, otherwise an exception will be thrown.
*
* @param year the year to represent, from MIN_YEAR to MAX_YEAR
* @param month the month-of-year to represent, from 1 (January) to 12 (December)
* @param dayOfMonth the day-of-month to represent, from 1 to 31
* @return the local date, not null
* @throws DateTimeException if the value of any field is out of range
* @throws DateTimeException if the day-of-month is invalid for the month-year
*/
public static LocalDate of(int year, int month, int dayOfMonth) {
YEAR.checkValidValue(year);
MONTH_OF_YEAR.checkValidValue(month);
DAY_OF_MONTH.checkValidValue(dayOfMonth);
if (dayOfMonth > 28 && dayOfMonth > lengthOfMonth(month, isLeapYear(year))) {
if (dayOfMonth == 29) {
throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year");
} else {
throw new DateTimeException("Invalid date '" + month + " " + dayOfMonth + "'");
}
}
return new LocalDate(year, month, dayOfMonth);
}
/**
* Constructor, previously validated.
*
* @param year the year to represent, from MIN_YEAR to MAX_YEAR
* @param month the month-of-year to represent, not null
* @param dayOfMonth the day-of-month to represent, valid for year-month, from 1 to 31
*/
private LocalDate(int year, int month, int dayOfMonth) {
this.year = year;
this.month = (short) month;
this.day = (short) dayOfMonth;
}
/**
* Gets the year field.
* <p>
* This method returns the primitive {@code int} value for the year.
* <p>
* The year returned by this method is proleptic as per {@code get(YEAR)}.
* To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
*
* @return the year, from MIN_YEAR to MAX_YEAR
*/
public int getYear() {
return year;
}
/**
* Gets the month-of-year field as an int from 1 to 12.
*
* @return the month-of-year
*/
public int getMonth() {
return month;
}
/**
* Gets the day-of-month field.
* <p>
* This method returns the primitive {@code int} value for the day-of-month.
*
* @return the day-of-month, from 1 to 31
*/
public int getDayOfMonth() {
return day;
}
/**
* Gets the day-of-week field, which is an int from 1 to 7.
*
* @return the day-of-week
*/
public int getDayOfWeek() {
return (int)floorMod(toEpochDay() + 3, 7) + 1;
}
/**
* Returns a copy of this {@code LocalDate} with the specified number of days added.
* <p>
* This method adds the specified amount to the days field incrementing the
* month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2008-12-31 plus one day would result in 2009-01-01.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param daysToAdd the days to add, may be negative
* @return a {@code LocalDate} based on this date with the days added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDate plusDays(long daysToAdd) {
if (daysToAdd == 0) {
return this;
}
long mjDay = addExact(toEpochDay(), daysToAdd);
return LocalDate.ofEpochDay(mjDay);
}
/**
* Returns a copy of this {@code LocalDate} with the specified number of days subtracted.
* <p>
* This method subtracts the specified amount from the days field decrementing the
* month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2009-01-01 minus one day would result in 2008-12-31.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param daysToSubtract the days to subtract, may be negative
* @return a {@code LocalDate} based on this date with the days subtracted, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDate minusDays(long daysToSubtract) {
return (daysToSubtract == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-daysToSubtract));
}
/**
* Obtains an instance of {@code LocalDate} from the epoch day count.
* <p>
* The Epoch Day count is a simple incrementing count of days
* where day 0 is 1970-01-01. Negative numbers represent earlier days.
*
* @param epochDay the Epoch Day to convert, based on the epoch 1970-01-01
* @return the local date, not null
* @throws DateTimeException if the epoch days exceeds the supported date range
*/
public static LocalDate ofEpochDay(long epochDay) {
long zeroDay = epochDay + DAYS_0000_TO_1970;
// find the march-based year
zeroDay -= 60; // adjust to 0000-03-01 so leap day is at end of four year cycle
long adjust = 0;
if (zeroDay < 0) {
// adjust negative years to positive for calculation
long adjustCycles = (zeroDay + 1) / DAYS_PER_CYCLE - 1;
adjust = adjustCycles * 400;
zeroDay += -adjustCycles * DAYS_PER_CYCLE;
}
long yearEst = (400 * zeroDay + 591) / DAYS_PER_CYCLE;
long doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400);
if (doyEst < 0) {
// fix estimate
yearEst--;
doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400);
}
yearEst += adjust; // reset any negative year
int marchDoy0 = (int) doyEst;
// convert march-based values back to january-based
int marchMonth0 = (marchDoy0 * 5 + 2) / 153;
int month = (marchMonth0 + 2) % 12 + 1;
int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1;
yearEst += marchMonth0 / 10;
// check year now we are certain it is correct
int year = YEAR.checkValidValue((int)yearEst);
return new LocalDate(year, month, dom);
}
public long toEpochDay() {
long y = year;
long m = month;
long total = 0;
total += 365 * y;
if (y >= 0) {
total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400;
} else {
total -= y / -4 - y / -100 + y / -400;
}
total += ((367 * m - 362) / 12);
total += day - 1;
if (m > 2) {
total--;
if (isLeapYear(year) == false) {
total--;
}
}
return total - DAYS_0000_TO_1970;
}
/**
* Compares this date to another date.
* <p>
* The comparison is primarily based on the date, from earliest to latest.
* It is "consistent with equals", as defined by {@link Comparable}.
* <p>
* If all the dates being compared are instances of {@code LocalDate},
* then the comparison will be entirely based on the date.
* If some dates being compared are in different chronologies, then the
* chronology is also considered, see {@link java.time.temporal.ChronoLocalDate#compareTo}.
*
* @param other the other date to compare to, not null
* @return the comparator value, negative if less, positive if greater
*/
public int compareTo(LocalDate otherDate) {
int cmp = (year - otherDate.year);
if (cmp == 0) {
cmp = (month - otherDate.month);
if (cmp == 0) {
cmp = (day - otherDate.day);
}
}
return cmp;
}
/**
* Checks if this date is equal to another date.
* <p>
* Compares this {@code LocalDate} with another ensuring that the date is the same.
* <p>
* Only objects of type {@code LocalDate} are compared, other types return false.
* To compare the dates of two {@code TemporalAccessor} instances, including dates
* in two different chronologies, use {@link ChronoField#EPOCH_DAY} as a comparator.
*
* @param obj the object to check, null returns false
* @return true if this is equal to the other date
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LocalDate) {
return compareTo((LocalDate) obj) == 0;
}
return false;
}
/**
* A hash code for this date.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
int yearValue = year;
int monthValue = month;
int dayValue = day;
return (yearValue & 0xFFFFF800) ^ ((yearValue << 11) + (monthValue << 6) + (dayValue));
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import static build.tools.tzdb.Utils.*;
import static build.tools.tzdb.LocalTime.HOURS_PER_DAY;
import static build.tools.tzdb.LocalTime.MICROS_PER_DAY;
import static build.tools.tzdb.LocalTime.MILLIS_PER_DAY;
import static build.tools.tzdb.LocalTime.MINUTES_PER_DAY;
import static build.tools.tzdb.LocalTime.SECONDS_PER_DAY;
import static build.tools.tzdb.LocalTime.SECONDS_PER_MINUTE;
import static build.tools.tzdb.LocalTime.SECONDS_PER_HOUR;
import java.util.Objects;
/**
* A date-time without a time-zone in the ISO-8601 calendar system,
* such as {@code 2007-12-03T10:15:30}.
*
* @since 1.8
*/
final class LocalDateTime {
/**
* The minimum supported {@code LocalDateTime}, '-999999999-01-01T00:00:00'.
* This is the local date-time of midnight at the start of the minimum date.
* This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}.
* This could be used by an application as a "far past" date-time.
*/
public static final LocalDateTime MIN = LocalDateTime.of(LocalDate.MIN, LocalTime.MIN);
/**
* The maximum supported {@code LocalDateTime}, '+999999999-12-31T23:59:59.999999999'.
* This is the local date-time just before midnight at the end of the maximum date.
* This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}.
* This could be used by an application as a "far future" date-time.
*/
public static final LocalDateTime MAX = LocalDateTime.of(LocalDate.MAX, LocalTime.MAX);
/**
* The date part.
*/
private final LocalDate date;
/**
* The time part.
*/
private final LocalTime time;
/**
* Obtains an instance of {@code LocalDateTime} from year, month,
* day, hour and minute, setting the second and nanosecond to zero.
* <p>
* The day must be valid for the year and month, otherwise an exception will be thrown.
* The second and nanosecond fields will be set to zero.
*
* @param year the year to represent, from MIN_YEAR to MAX_YEAR
* @param month the month-of-year to represent, from 1 (January) to 12 (December)
* @param dayOfMonth the day-of-month to represent, from 1 to 31
* @param hour the hour-of-day to represent, from 0 to 23
* @param minute the minute-of-hour to represent, from 0 to 59
* @return the local date-time, not null
* @throws DateTimeException if the value of any field is out of range
* @throws DateTimeException if the day-of-month is invalid for the month-year
*/
public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute) {
LocalDate date = LocalDate.of(year, month, dayOfMonth);
LocalTime time = LocalTime.of(hour, minute);
return new LocalDateTime(date, time);
}
/**
* Obtains an instance of {@code LocalDateTime} from a date and time.
*
* @param date the local date, not null
* @param time the local time, not null
* @return the local date-time, not null
*/
public static LocalDateTime of(LocalDate date, LocalTime time) {
Objects.requireNonNull(date, "date");
Objects.requireNonNull(time, "time");
return new LocalDateTime(date, time);
}
/**
* Obtains an instance of {@code LocalDateTime} using seconds from the
* epoch of 1970-01-01T00:00:00Z.
* <p>
* This allows the {@link ChronoField#INSTANT_SECONDS epoch-second} field
* to be converted to a local date-time. This is primarily intended for
* low-level conversions rather than general application usage.
*
* @param epochSecond the number of seconds from the epoch of 1970-01-01T00:00:00Z
* @param nanoOfSecond the nanosecond within the second, from 0 to 999,999,999
* @param offset the zone offset, not null
* @return the local date-time, not null
* @throws DateTimeException if the result exceeds the supported range
*/
public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) {
Objects.requireNonNull(offset, "offset");
long localSecond = epochSecond + offset.getTotalSeconds(); // overflow caught later
long localEpochDay = floorDiv(localSecond, SECONDS_PER_DAY);
int secsOfDay = (int)floorMod(localSecond, SECONDS_PER_DAY);
LocalDate date = LocalDate.ofEpochDay(localEpochDay);
LocalTime time = LocalTime.ofSecondOfDay(secsOfDay); // ignore nano
return new LocalDateTime(date, time);
}
/**
* Constructor.
*
* @param date the date part of the date-time, validated not null
* @param time the time part of the date-time, validated not null
*/
private LocalDateTime(LocalDate date, LocalTime time) {
this.date = date;
this.time = time;
}
/**
* Returns a copy of this date-time with the new date and time, checking
* to see if a new object is in fact required.
*
* @param newDate the date of the new date-time, not null
* @param newTime the time of the new date-time, not null
* @return the date-time, not null
*/
private LocalDateTime with(LocalDate newDate, LocalTime newTime) {
if (date == newDate && time == newTime) {
return this;
}
return new LocalDateTime(newDate, newTime);
}
/**
* Gets the {@code LocalDate} part of this date-time.
* <p>
* This returns a {@code LocalDate} with the same year, month and day
* as this date-time.
*
* @return the date part of this date-time, not null
*/
public LocalDate getDate() {
return date;
}
/**
* Gets the year field.
* <p>
* This method returns the primitive {@code int} value for the year.
* <p>
* The year returned by this method is proleptic as per {@code get(YEAR)}.
* To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
*
* @return the year, from MIN_YEAR to MAX_YEAR
*/
public int getYear() {
return date.getYear();
}
/**
* Gets the month-of-year field as an int from 1 to 12.
*
* @return the month-of-year
*/
public int getMonth() {
return date.getMonth();
}
/**
* Gets the day-of-month field.
* <p>
* This method returns the primitive {@code int} value for the day-of-month.
*
* @return the day-of-month, from 1 to 31
*/
public int getDayOfMonth() {
return date.getDayOfMonth();
}
/**
* Gets the day-of-week field, which is an integer from 1 to 7.
*
* @return the day-of-week, from 1 to 7
*/
public int getDayOfWeek() {
return date.getDayOfWeek();
}
/**
* Gets the {@code LocalTime} part of this date-time.
* <p>
* This returns a {@code LocalTime} with the same hour, minute, second and
* nanosecond as this date-time.
*
* @return the time part of this date-time, not null
*/
public LocalTime getTime() {
return time;
}
/**
* Gets the hour-of-day field.
*
* @return the hour-of-day, from 0 to 23
*/
public int getHour() {
return time.getHour();
}
/**
* Gets the minute-of-hour field.
*
* @return the minute-of-hour, from 0 to 59
*/
public int getMinute() {
return time.getMinute();
}
/**
* Gets the second-of-minute field.
*
* @return the second-of-minute, from 0 to 59
*/
public int getSecond() {
return time.getSecond();
}
/**
* Converts this date-time to the number of seconds from the epoch
* of 1970-01-01T00:00:00Z.
* <p>
* This combines this local date-time and the specified offset to calculate the
* epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z.
* Instants on the time-line after the epoch are positive, earlier are negative.
* <p>
* This default implementation calculates from the epoch-day of the date and the
* second-of-day of the time.
*
* @param offset the offset to use for the conversion, not null
* @return the number of seconds from the epoch of 1970-01-01T00:00:00Z
*/
public long toEpochSecond(ZoneOffset offset) {
Objects.requireNonNull(offset, "offset");
long epochDay = getDate().toEpochDay();
long secs = epochDay * 86400 + getTime().toSecondOfDay();
secs -= offset.getTotalSeconds();
return secs;
}
/**
* Returns a copy of this {@code LocalDateTime} with the specified period in days added.
* <p>
* This method adds the specified amount to the days field incrementing the
* month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2008-12-31 plus one day would result in 2009-01-01.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to add, may be negative
* @return a {@code LocalDateTime} based on this date-time with the days added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDateTime plusDays(long days) {
LocalDate newDate = date.plusDays(days);
return with(newDate, time);
}
/**
* Returns a copy of this {@code LocalDateTime} with the specified period in seconds added.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param seconds the seconds to add, may be negative
* @return a {@code LocalDateTime} based on this date-time with the seconds added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDateTime plusSeconds(long seconds) {
return plusWithOverflow(date, 0, 0, seconds, 1);
}
/**
* Returns a copy of this {@code LocalDateTime} with the specified period added.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param newDate the new date to base the calculation on, not null
* @param hours the hours to add, may be negative
* @param minutes the minutes to add, may be negative
* @param seconds the seconds to add, may be negative
* @param nanos the nanos to add, may be negative
* @param sign the sign to determine add or subtract
* @return the combined result, not null
*/
private LocalDateTime plusWithOverflow(LocalDate newDate, long hours, long minutes, long seconds, int sign) {
if ((hours | minutes | seconds) == 0) {
return with(newDate, time);
}
long totDays = seconds / SECONDS_PER_DAY + // max/24*60*60
minutes / MINUTES_PER_DAY + // max/24*60
hours / HOURS_PER_DAY; // max/24
totDays *= sign; // total max*0.4237...
long totSecs = (seconds % SECONDS_PER_DAY) +
(minutes % MINUTES_PER_DAY) * SECONDS_PER_MINUTE +
(hours % HOURS_PER_DAY) * SECONDS_PER_HOUR;
long curSoD = time.toSecondOfDay();
totSecs = totSecs * sign + curSoD; // total 432000000000000
totDays += floorDiv(totSecs, SECONDS_PER_DAY);
int newSoD = (int)floorMod(totSecs, SECONDS_PER_DAY);
LocalTime newTime = (newSoD == curSoD ? time : LocalTime.ofSecondOfDay(newSoD));
return with(newDate.plusDays(totDays), newTime);
}
/**
* Compares this date-time to another date-time.
* <p>
* The comparison is primarily based on the date-time, from earliest to latest.
* It is "consistent with equals", as defined by {@link Comparable}.
* <p>
* If all the date-times being compared are instances of {@code LocalDateTime},
* then the comparison will be entirely based on the date-time.
* If some dates being compared are in different chronologies, then the
* chronology is also considered, see {@link ChronoLocalDateTime#compareTo}.
*
* @param other the other date-time to compare to, not null
* @return the comparator value, negative if less, positive if greater
*/
public int compareTo(LocalDateTime other) {
int cmp = date.compareTo(other.getDate());
if (cmp == 0) {
cmp = time.compareTo(other.getTime());
}
return cmp;
}
/**
* Checks if this date-time is equal to another date-time.
* <p>
* Compares this {@code LocalDateTime} with another ensuring that the date-time is the same.
* Only objects of type {@code LocalDateTime} are compared, other types return false.
*
* @param obj the object to check, null returns false
* @return true if this is equal to the other date-time
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LocalDateTime) {
LocalDateTime other = (LocalDateTime) obj;
return date.equals(other.date) && time.equals(other.time);
}
return false;
}
/**
* A hash code for this date-time.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
return date.hashCode() ^ time.hashCode();
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import static build.tools.tzdb.ChronoField.HOUR_OF_DAY;
import static build.tools.tzdb.ChronoField.MINUTE_OF_HOUR;
import static build.tools.tzdb.ChronoField.SECOND_OF_MINUTE;
import static build.tools.tzdb.ChronoField.SECOND_OF_DAY;
import java.util.Objects;
/**
* A time without time-zone in the ISO-8601 calendar system,
* such as {@code 10:15:30}.
*
*/
final class LocalTime {
/**
* The minimum supported {@code LocalTime}, '00:00'.
* This is the time of midnight at the start of the day.
*/
public static final LocalTime MIN;
/**
* The minimum supported {@code LocalTime}, '23:59:59.999999999'.
* This is the time just before midnight at the end of the day.
*/
public static final LocalTime MAX;
/**
* The time of midnight at the start of the day, '00:00'.
*/
public static final LocalTime MIDNIGHT;
/**
* The time of noon in the middle of the day, '12:00'.
*/
public static final LocalTime NOON;
/**
* Constants for the local time of each hour.
*/
private static final LocalTime[] HOURS = new LocalTime[24];
static {
for (int i = 0; i < HOURS.length; i++) {
HOURS[i] = new LocalTime(i, 0, 0);
}
MIDNIGHT = HOURS[0];
NOON = HOURS[12];
MIN = HOURS[0];
MAX = new LocalTime(23, 59, 59);
}
/**
* Hours per day.
*/
static final int HOURS_PER_DAY = 24;
/**
* Minutes per hour.
*/
static final int MINUTES_PER_HOUR = 60;
/**
* Minutes per day.
*/
static final int MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY;
/**
* Seconds per minute.
*/
static final int SECONDS_PER_MINUTE = 60;
/**
* Seconds per hour.
*/
static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
/**
* Seconds per day.
*/
static final int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
/**
* Milliseconds per day.
*/
static final long MILLIS_PER_DAY = SECONDS_PER_DAY * 1000L;
/**
* Microseconds per day.
*/
static final long MICROS_PER_DAY = SECONDS_PER_DAY * 1000_000L;
/**
* The hour.
*/
private final byte hour;
/**
* The minute.
*/
private final byte minute;
/**
* The second.
*/
private final byte second;
/**
* Obtains an instance of {@code LocalTime} from an hour and minute.
* <p>
* The second and nanosecond fields will be set to zero by this factory method.
* <p>
* This factory may return a cached value, but applications must not rely on this.
*
* @param hour the hour-of-day to represent, from 0 to 23
* @param minute the minute-of-hour to represent, from 0 to 59
* @return the local time, not null
* @throws DateTimeException if the value of any field is out of range
*/
public static LocalTime of(int hour, int minute) {
HOUR_OF_DAY.checkValidValue(hour);
if (minute == 0) {
return HOURS[hour]; // for performance
}
MINUTE_OF_HOUR.checkValidValue(minute);
return new LocalTime(hour, minute, 0);
}
/**
* Obtains an instance of {@code LocalTime} from an hour, minute and second.
* <p>
* The nanosecond field will be set to zero by this factory method.
* <p>
* This factory may return a cached value, but applications must not rely on this.
*
* @param hour the hour-of-day to represent, from 0 to 23
* @param minute the minute-of-hour to represent, from 0 to 59
* @param second the second-of-minute to represent, from 0 to 59
* @return the local time, not null
* @throws DateTimeException if the value of any field is out of range
*/
public static LocalTime of(int hour, int minute, int second) {
HOUR_OF_DAY.checkValidValue(hour);
if ((minute | second) == 0) {
return HOURS[hour]; // for performance
}
MINUTE_OF_HOUR.checkValidValue(minute);
SECOND_OF_MINUTE.checkValidValue(second);
return new LocalTime(hour, minute, second);
}
/**
* Obtains an instance of {@code LocalTime} from a second-of-day value.
* <p>
* This factory may return a cached value, but applications must not rely on this.
*
* @param secondOfDay the second-of-day, from {@code 0} to {@code 24 * 60 * 60 - 1}
* @return the local time, not null
* @throws DateTimeException if the second-of-day value is invalid
*/
public static LocalTime ofSecondOfDay(int secondOfDay) {
SECOND_OF_DAY.checkValidValue(secondOfDay);
int hours = secondOfDay / SECONDS_PER_HOUR;
secondOfDay -= hours * SECONDS_PER_HOUR;
int minutes = secondOfDay / SECONDS_PER_MINUTE;
secondOfDay -= minutes * SECONDS_PER_MINUTE;
return create(hours, minutes, secondOfDay);
}
/**
* Creates a local time from the hour, minute, second and nanosecond fields.
* <p>
* This factory may return a cached value, but applications must not rely on this.
*
* @param hour the hour-of-day to represent, validated from 0 to 23
* @param minute the minute-of-hour to represent, validated from 0 to 59
* @param second the second-of-minute to represent, validated from 0 to 59
* @return the local time, not null
*/
private static LocalTime create(int hour, int minute, int second) {
if ((minute | second) == 0) {
return HOURS[hour];
}
return new LocalTime(hour, minute, second);
}
/**
* Constructor, previously validated.
*
* @param hour the hour-of-day to represent, validated from 0 to 23
* @param minute the minute-of-hour to represent, validated from 0 to 59
* @param second the second-of-minute to represent, validated from 0 to 59
*/
private LocalTime(int hour, int minute, int second) {
this.hour = (byte) hour;
this.minute = (byte) minute;
this.second = (byte) second;
}
/**
* Gets the hour-of-day field.
*
* @return the hour-of-day, from 0 to 23
*/
public int getHour() {
return hour;
}
/**
* Gets the minute-of-hour field.
*
* @return the minute-of-hour, from 0 to 59
*/
public int getMinute() {
return minute;
}
/**
* Gets the second-of-minute field.
*
* @return the second-of-minute, from 0 to 59
*/
public int getSecond() {
return second;
}
/**
* Returns a copy of this {@code LocalTime} with the specified period in seconds added.
* <p>
* This adds the specified number of seconds to this time, returning a new time.
* The calculation wraps around midnight.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param secondstoAdd the seconds to add, may be negative
* @return a {@code LocalTime} based on this time with the seconds added, not null
*/
public LocalTime plusSeconds(long secondstoAdd) {
if (secondstoAdd == 0) {
return this;
}
int sofd = hour * SECONDS_PER_HOUR +
minute * SECONDS_PER_MINUTE + second;
int newSofd = ((int) (secondstoAdd % SECONDS_PER_DAY) + sofd + SECONDS_PER_DAY) % SECONDS_PER_DAY;
if (sofd == newSofd) {
return this;
}
int newHour = newSofd / SECONDS_PER_HOUR;
int newMinute = (newSofd / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
int newSecond = newSofd % SECONDS_PER_MINUTE;
return create(newHour, newMinute, newSecond);
}
/**
* Returns a copy of this {@code LocalTime} with the specified period in seconds subtracted.
* <p>
* This subtracts the specified number of seconds from this time, returning a new time.
* The calculation wraps around midnight.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param secondsToSubtract the seconds to subtract, may be negative
* @return a {@code LocalTime} based on this time with the seconds subtracted, not null
*/
public LocalTime minusSeconds(long secondsToSubtract) {
return plusSeconds(-(secondsToSubtract % SECONDS_PER_DAY));
}
/**
* Extracts the time as seconds of day,
* from {@code 0} to {@code 24 * 60 * 60 - 1}.
*
* @return the second-of-day equivalent to this time
*/
public int toSecondOfDay() {
int total = hour * SECONDS_PER_HOUR;
total += minute * SECONDS_PER_MINUTE;
total += second;
return total;
}
/**
* Compares this {@code LocalTime} to another time.
* <p>
* The comparison is based on the time-line position of the local times within a day.
* It is "consistent with equals", as defined by {@link Comparable}.
*
* @param other the other time to compare to, not null
* @return the comparator value, negative if less, positive if greater
* @throws NullPointerException if {@code other} is null
*/
public int compareTo(LocalTime other) {
int cmp = Integer.compare(hour, other.hour);
if (cmp == 0) {
cmp = Integer.compare(minute, other.minute);
if (cmp == 0) {
cmp = Integer.compare(second, other.second);
}
}
return cmp;
}
/**
* Checks if this time is equal to another time.
* <p>
* The comparison is based on the time-line position of the time within a day.
* <p>
* Only objects of type {@code LocalTime} are compared, other types return false.
* To compare the date of two {@code TemporalAccessor} instances, use
* {@link ChronoField#NANO_OF_DAY} as a comparator.
*
* @param obj the object to check, null returns false
* @return true if this is equal to the other time
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LocalTime) {
LocalTime other = (LocalTime) obj;
return hour == other.hour && minute == other.minute &&
second == other.second;
}
return false;
}
/**
* A hash code for this time.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
long sod = toSecondOfDay();
return (int) (sod ^ (sod >>> 32));
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import java.util.Objects;
/**
* A definition of the way a local time can be converted to the actual
* transition date-time.
* <p>
* Time zone rules are expressed in one of three ways:
* <p><ul>
* <li>Relative to UTC</li>
* <li>Relative to the standard offset in force</li>
* <li>Relative to the wall offset (what you would see on a clock on the wall)</li>
* </ul><p>
*/
public enum TimeDefinition {
/** The local date-time is expressed in terms of the UTC offset. */
UTC,
/** The local date-time is expressed in terms of the wall offset. */
WALL,
/** The local date-time is expressed in terms of the standard offset. */
STANDARD;
/**
* Converts the specified local date-time to the local date-time actually
* seen on a wall clock.
* <p>
* This method converts using the type of this enum.
* The output is defined relative to the 'before' offset of the transition.
* <p>
* The UTC type uses the UTC offset.
* The STANDARD type uses the standard offset.
* The WALL type returns the input date-time.
* The result is intended for use with the wall-offset.
*
* @param dateTime the local date-time, not null
* @param standardOffset the standard offset, not null
* @param wallOffset the wall offset, not null
* @return the date-time relative to the wall/before offset, not null
*/
public LocalDateTime createDateTime(LocalDateTime dateTime, ZoneOffset standardOffset, ZoneOffset wallOffset) {
switch (this) {
case UTC: {
int difference = wallOffset.getTotalSeconds() - ZoneOffset.UTC.getTotalSeconds();
return dateTime.plusSeconds(difference);
}
case STANDARD: {
int difference = wallOffset.getTotalSeconds() - standardOffset.getTotalSeconds();
return dateTime.plusSeconds(difference);
}
default: // WALL
return dateTime;
}
}
}
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import java.util.Objects;
class Utils {
// Returns the largest (closest to positive infinity)
public static long floorDiv(long x, long y) {
long r = x / y;
// if the signs are different and modulo not zero, round down
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return r;
}
// Returns the floor modulus of the {@code long} arguments.
public static long floorMod(long x, long y) {
return x - floorDiv(x, y) * y;
}
// Returns the sum of its arguments,
public static long addExact(long x, long y) {
long r = x + y;
// HD 2-12 Overflow iff both arguments have the opposite sign of the result
if (((x ^ r) & (y ^ r)) < 0) {
throw new ArithmeticException("long overflow");
}
return r;
}
// Year
// Returns true if the specified year is a leap year.
public static boolean isLeapYear(int year) {
return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0);
}
// The minimum supported year, '-999,999,999'.
public static final int YEAR_MIN_VALUE = -999_999_999;
// The maximum supported year, '+999,999,999'.
public static final int YEAR_MAX_VALUE = 999_999_999;
// Gets the length of the specified month in days.
public static int lengthOfMonth(int month, boolean leapYear) {
switch (month) {
case 2: //FEBRUARY:
return (leapYear ? 29 : 28);
case 4: //APRIL:
case 6: //JUNE:
case 9: //SEPTEMBER:
case 11: //NOVEMBER:
return 30;
default:
return 31;
}
}
// Gets the maximum length of the specified month in days.
public static int maxLengthOfMonth(int month) {
switch (month) {
case 2: //FEBRUARY:
return 29;
case 4: //APRIL:
case 6: //JUNE:
case 9: //SEPTEMBER:
case 11: //NOVEMBER:
return 30;
default:
return 31;
}
}
// DayOfWeek
// Returns the day-of-week that is the specified number of days after
// this one, from 1 to 7 for Monday to Sunday.
public static int plusDayOfWeek(int dow, long days) {
int amount = (int) (days % 7);
return (dow - 1 + (amount + 7)) % 7 + 1;
}
// Returns the day-of-week that is the specified number of days before
// this one, from 1 to 7 for Monday to Sunday.
public static int minusDayOfWeek(int dow, long days) {
return plusDayOfWeek(dow, -(days % 7));
}
// Adjusts the date to the first occurrence of the specified day-of-week
// before the date being adjusted unless it is already on that day in
// which case the same object is returned.
public static LocalDate previousOrSame(LocalDate date, int dayOfWeek) {
return adjust(date, dayOfWeek, 1);
}
// Adjusts the date to the first occurrence of the specified day-of-week
// after the date being adjusted unless it is already on that day in
// which case the same object is returned.
public static LocalDate nextOrSame(LocalDate date, int dayOfWeek) {
return adjust(date, dayOfWeek, 0);
}
// Implementation of next, previous or current day-of-week.
// @param relative whether the current date is a valid answer
private static final LocalDate adjust(LocalDate date, int dow, int relative) {
int calDow = date.getDayOfWeek();
if (relative < 2 && calDow == dow) {
return date;
}
if ((relative & 1) == 0) {
int daysDiff = calDow - dow;
return date.plusDays(daysDiff >= 0 ? 7 - daysDiff : -daysDiff);
} else {
int daysDiff = dow - calDow;
return date.minusDays(daysDiff >= 0 ? 7 - daysDiff : -daysDiff);
}
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* A time-zone offset from Greenwich/UTC, such as {@code +02:00}.
* <p>
* A time-zone offset is the period of time that a time-zone differs from Greenwich/UTC.
* This is usually a fixed number of hours and minutes.
*
* @since 1.8
*/
final class ZoneOffset implements Comparable<ZoneOffset> {
/** Cache of time-zone offset by offset in seconds. */
private static final ConcurrentMap<Integer, ZoneOffset> SECONDS_CACHE = new ConcurrentHashMap<>(16, 0.75f, 4);
/** Cache of time-zone offset by ID. */
private static final ConcurrentMap<String, ZoneOffset> ID_CACHE = new ConcurrentHashMap<>(16, 0.75f, 4);
/**
* The number of seconds per hour.
*/
private static final int SECONDS_PER_HOUR = 60 * 60;
/**
* The number of seconds per minute.
*/
private static final int SECONDS_PER_MINUTE = 60;
/**
* The number of minutes per hour.
*/
private static final int MINUTES_PER_HOUR = 60;
/**
* The abs maximum seconds.
*/
private static final int MAX_SECONDS = 18 * SECONDS_PER_HOUR;
/**
* Serialization version.
*/
private static final long serialVersionUID = 2357656521762053153L;
/**
* The time-zone offset for UTC, with an ID of 'Z'.
*/
public static final ZoneOffset UTC = ZoneOffset.ofTotalSeconds(0);
/**
* Constant for the maximum supported offset.
*/
public static final ZoneOffset MIN = ZoneOffset.ofTotalSeconds(-MAX_SECONDS);
/**
* Constant for the maximum supported offset.
*/
public static final ZoneOffset MAX = ZoneOffset.ofTotalSeconds(MAX_SECONDS);
/**
* The total offset in seconds.
*/
private final int totalSeconds;
/**
* The string form of the time-zone offset.
*/
private final transient String id;
//-----------------------------------------------------------------------
/**
* Obtains an instance of {@code ZoneOffset} using the ID.
* <p>
* This method parses the string ID of a {@code ZoneOffset} to
* return an instance. The parsing accepts all the formats generated by
* {@link #getId()}, plus some additional formats:
* <p><ul>
* <li>{@code Z} - for UTC
* <li>{@code +h}
* <li>{@code +hh}
* <li>{@code +hh:mm}
* <li>{@code -hh:mm}
* <li>{@code +hhmm}
* <li>{@code -hhmm}
* <li>{@code +hh:mm:ss}
* <li>{@code -hh:mm:ss}
* <li>{@code +hhmmss}
* <li>{@code -hhmmss}
* </ul><p>
* Note that &plusmn; means either the plus or minus symbol.
* <p>
* The ID of the returned offset will be normalized to one of the formats
* described by {@link #getId()}.
* <p>
* The maximum supported range is from +18:00 to -18:00 inclusive.
*
* @param offsetId the offset ID, not null
* @return the zone-offset, not null
* @throws DateTimeException if the offset ID is invalid
*/
@SuppressWarnings("fallthrough")
public static ZoneOffset of(String offsetId) {
Objects.requireNonNull(offsetId, "offsetId");
// "Z" is always in the cache
ZoneOffset offset = ID_CACHE.get(offsetId);
if (offset != null) {
return offset;
}
// parse - +h, +hh, +hhmm, +hh:mm, +hhmmss, +hh:mm:ss
final int hours, minutes, seconds;
switch (offsetId.length()) {
case 2:
offsetId = offsetId.charAt(0) + "0" + offsetId.charAt(1); // fallthru
case 3:
hours = parseNumber(offsetId, 1, false);
minutes = 0;
seconds = 0;
break;
case 5:
hours = parseNumber(offsetId, 1, false);
minutes = parseNumber(offsetId, 3, false);
seconds = 0;
break;
case 6:
hours = parseNumber(offsetId, 1, false);
minutes = parseNumber(offsetId, 4, true);
seconds = 0;
break;
case 7:
hours = parseNumber(offsetId, 1, false);
minutes = parseNumber(offsetId, 3, false);
seconds = parseNumber(offsetId, 5, false);
break;
case 9:
hours = parseNumber(offsetId, 1, false);
minutes = parseNumber(offsetId, 4, true);
seconds = parseNumber(offsetId, 7, true);
break;
default:
throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid");
}
char first = offsetId.charAt(0);
if (first != '+' && first != '-') {
throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Plus/minus not found when expected");
}
if (first == '-') {
return ofHoursMinutesSeconds(-hours, -minutes, -seconds);
} else {
return ofHoursMinutesSeconds(hours, minutes, seconds);
}
}
/**
* Parse a two digit zero-prefixed number.
*
* @param offsetId the offset ID, not null
* @param pos the position to parse, valid
* @param precededByColon should this number be prefixed by a precededByColon
* @return the parsed number, from 0 to 99
*/
private static int parseNumber(CharSequence offsetId, int pos, boolean precededByColon) {
if (precededByColon && offsetId.charAt(pos - 1) != ':') {
throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Colon not found when expected");
}
char ch1 = offsetId.charAt(pos);
char ch2 = offsetId.charAt(pos + 1);
if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') {
throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Non numeric characters found");
}
return (ch1 - 48) * 10 + (ch2 - 48);
}
//-----------------------------------------------------------------------
/**
* Obtains an instance of {@code ZoneOffset} using an offset in hours.
*
* @param hours the time-zone offset in hours, from -18 to +18
* @return the zone-offset, not null
* @throws DateTimeException if the offset is not in the required range
*/
public static ZoneOffset ofHours(int hours) {
return ofHoursMinutesSeconds(hours, 0, 0);
}
/**
* Obtains an instance of {@code ZoneOffset} using an offset in
* hours and minutes.
* <p>
* The sign of the hours and minutes components must match.
* Thus, if the hours is negative, the minutes must be negative or zero.
* If the hours is zero, the minutes may be positive, negative or zero.
*
* @param hours the time-zone offset in hours, from -18 to +18
* @param minutes the time-zone offset in minutes, from 0 to &plusmn;59, sign matches hours
* @return the zone-offset, not null
* @throws DateTimeException if the offset is not in the required range
*/
public static ZoneOffset ofHoursMinutes(int hours, int minutes) {
return ofHoursMinutesSeconds(hours, minutes, 0);
}
/**
* Obtains an instance of {@code ZoneOffset} using an offset in
* hours, minutes and seconds.
* <p>
* The sign of the hours, minutes and seconds components must match.
* Thus, if the hours is negative, the minutes and seconds must be negative or zero.
*
* @param hours the time-zone offset in hours, from -18 to +18
* @param minutes the time-zone offset in minutes, from 0 to &plusmn;59, sign matches hours and seconds
* @param seconds the time-zone offset in seconds, from 0 to &plusmn;59, sign matches hours and minutes
* @return the zone-offset, not null
* @throws DateTimeException if the offset is not in the required range
*/
public static ZoneOffset ofHoursMinutesSeconds(int hours, int minutes, int seconds) {
validate(hours, minutes, seconds);
int totalSeconds = totalSeconds(hours, minutes, seconds);
return ofTotalSeconds(totalSeconds);
}
/**
* Validates the offset fields.
*
* @param hours the time-zone offset in hours, from -18 to +18
* @param minutes the time-zone offset in minutes, from 0 to &plusmn;59
* @param seconds the time-zone offset in seconds, from 0 to &plusmn;59
* @throws DateTimeException if the offset is not in the required range
*/
private static void validate(int hours, int minutes, int seconds) {
if (hours < -18 || hours > 18) {
throw new DateTimeException("Zone offset hours not in valid range: value " + hours +
" is not in the range -18 to 18");
}
if (hours > 0) {
if (minutes < 0 || seconds < 0) {
throw new DateTimeException("Zone offset minutes and seconds must be positive because hours is positive");
}
} else if (hours < 0) {
if (minutes > 0 || seconds > 0) {
throw new DateTimeException("Zone offset minutes and seconds must be negative because hours is negative");
}
} else if ((minutes > 0 && seconds < 0) || (minutes < 0 && seconds > 0)) {
throw new DateTimeException("Zone offset minutes and seconds must have the same sign");
}
if (Math.abs(minutes) > 59) {
throw new DateTimeException("Zone offset minutes not in valid range: abs(value) " +
Math.abs(minutes) + " is not in the range 0 to 59");
}
if (Math.abs(seconds) > 59) {
throw new DateTimeException("Zone offset seconds not in valid range: abs(value) " +
Math.abs(seconds) + " is not in the range 0 to 59");
}
if (Math.abs(hours) == 18 && (Math.abs(minutes) > 0 || Math.abs(seconds) > 0)) {
throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00");
}
}
/**
* Calculates the total offset in seconds.
*
* @param hours the time-zone offset in hours, from -18 to +18
* @param minutes the time-zone offset in minutes, from 0 to &plusmn;59, sign matches hours and seconds
* @param seconds the time-zone offset in seconds, from 0 to &plusmn;59, sign matches hours and minutes
* @return the total in seconds
*/
private static int totalSeconds(int hours, int minutes, int seconds) {
return hours * SECONDS_PER_HOUR + minutes * SECONDS_PER_MINUTE + seconds;
}
//-----------------------------------------------------------------------
/**
* Obtains an instance of {@code ZoneOffset} specifying the total offset in seconds
* <p>
* The offset must be in the range {@code -18:00} to {@code +18:00}, which corresponds to -64800 to +64800.
*
* @param totalSeconds the total time-zone offset in seconds, from -64800 to +64800
* @return the ZoneOffset, not null
* @throws DateTimeException if the offset is not in the required range
*/
public static ZoneOffset ofTotalSeconds(int totalSeconds) {
if (Math.abs(totalSeconds) > MAX_SECONDS) {
throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00");
}
if (totalSeconds % (15 * SECONDS_PER_MINUTE) == 0) {
Integer totalSecs = totalSeconds;
ZoneOffset result = SECONDS_CACHE.get(totalSecs);
if (result == null) {
result = new ZoneOffset(totalSeconds);
SECONDS_CACHE.putIfAbsent(totalSecs, result);
result = SECONDS_CACHE.get(totalSecs);
ID_CACHE.putIfAbsent(result.getId(), result);
}
return result;
} else {
return new ZoneOffset(totalSeconds);
}
}
/**
* Constructor.
*
* @param totalSeconds the total time-zone offset in seconds, from -64800 to +64800
*/
private ZoneOffset(int totalSeconds) {
super();
this.totalSeconds = totalSeconds;
id = buildId(totalSeconds);
}
private static String buildId(int totalSeconds) {
if (totalSeconds == 0) {
return "Z";
} else {
int absTotalSeconds = Math.abs(totalSeconds);
StringBuilder buf = new StringBuilder();
int absHours = absTotalSeconds / SECONDS_PER_HOUR;
int absMinutes = (absTotalSeconds / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
buf.append(totalSeconds < 0 ? "-" : "+")
.append(absHours < 10 ? "0" : "").append(absHours)
.append(absMinutes < 10 ? ":0" : ":").append(absMinutes);
int absSeconds = absTotalSeconds % SECONDS_PER_MINUTE;
if (absSeconds != 0) {
buf.append(absSeconds < 10 ? ":0" : ":").append(absSeconds);
}
return buf.toString();
}
}
/**
* Gets the total zone offset in seconds.
* <p>
* This is the primary way to access the offset amount.
* It returns the total of the hours, minutes and seconds fields as a
* single offset that can be added to a time.
*
* @return the total zone offset amount in seconds
*/
public int getTotalSeconds() {
return totalSeconds;
}
/**
* Gets the normalized zone offset ID.
* <p>
* The ID is minor variation to the standard ISO-8601 formatted string
* for the offset. There are three formats:
* <p><ul>
* <li>{@code Z} - for UTC (ISO-8601)
* <li>{@code +hh:mm} or {@code -hh:mm} - if the seconds are zero (ISO-8601)
* <li>{@code +hh:mm:ss} or {@code -hh:mm:ss} - if the seconds are non-zero (not ISO-8601)
* </ul><p>
*
* @return the zone offset ID, not null
*/
public String getId() {
return id;
}
/**
* Compares this offset to another offset in descending order.
* <p>
* The offsets are compared in the order that they occur for the same time
* of day around the world. Thus, an offset of {@code +10:00} comes before an
* offset of {@code +09:00} and so on down to {@code -18:00}.
* <p>
* The comparison is "consistent with equals", as defined by {@link Comparable}.
*
* @param other the other date to compare to, not null
* @return the comparator value, negative if less, postive if greater
* @throws NullPointerException if {@code other} is null
*/
@Override
public int compareTo(ZoneOffset other) {
return other.totalSeconds - totalSeconds;
}
/**
* Checks if this offset is equal to another offset.
* <p>
* The comparison is based on the amount of the offset in seconds.
* This is equivalent to a comparison by ID.
*
* @param obj the object to check, null returns false
* @return true if this is equal to the other offset
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ZoneOffset) {
return totalSeconds == ((ZoneOffset) obj).totalSeconds;
}
return false;
}
/**
* A hash code for this offset.
*
* @return a suitable hash code
*/
@Override
public int hashCode() {
return totalSeconds;
}
/**
* Outputs this offset as a {@code String}, using the normalized ID.
*
* @return a string representation of this offset, not null
*/
@Override
public String toString() {
return id;
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* A transition between two offsets caused by a discontinuity in the local time-line.
*
* @since 1.8
*/
final class ZoneOffsetTransition implements Comparable<ZoneOffsetTransition> {
/**
* The local transition date-time at the transition.
*/
private final LocalDateTime transition;
/**
* The offset before transition.
*/
private final ZoneOffset offsetBefore;
/**
* The offset after transition.
*/
private final ZoneOffset offsetAfter;
/**
* Creates an instance defining a transition between two offsets.
*
* @param transition the transition date-time with the offset before the transition, not null
* @param offsetBefore the offset before the transition, not null
* @param offsetAfter the offset at and after the transition, not null
*/
ZoneOffsetTransition(LocalDateTime transition, ZoneOffset offsetBefore, ZoneOffset offsetAfter) {
Objects.requireNonNull(transition, "transition");
Objects.requireNonNull(offsetBefore, "offsetBefore");
Objects.requireNonNull(offsetAfter, "offsetAfter");
if (offsetBefore.equals(offsetAfter)) {
throw new IllegalArgumentException("Offsets must not be equal");
}
this.transition = transition;
this.offsetBefore = offsetBefore;
this.offsetAfter = offsetAfter;
}
/**
* Creates an instance from epoch-second and offsets.
*
* @param epochSecond the transition epoch-second
* @param offsetBefore the offset before the transition, not null
* @param offsetAfter the offset at and after the transition, not null
*/
ZoneOffsetTransition(long epochSecond, ZoneOffset offsetBefore, ZoneOffset offsetAfter) {
this.transition = LocalDateTime.ofEpochSecond(epochSecond, 0, offsetBefore);
this.offsetBefore = offsetBefore;
this.offsetAfter = offsetAfter;
}
/**
* Gets the transition instant as an epoch second.
*
* @return the transition epoch second
*/
public long toEpochSecond() {
return transition.toEpochSecond(offsetBefore);
}
/**
* Gets the local transition date-time, as would be expressed with the 'before' offset.
* <p>
* This is the date-time where the discontinuity begins expressed with the 'before' offset.
* At this instant, the 'after' offset is actually used, therefore the combination of this
* date-time and the 'before' offset will never occur.
* <p>
* The combination of the 'before' date-time and offset represents the same instant
* as the 'after' date-time and offset.
*
* @return the transition date-time expressed with the before offset, not null
*/
public LocalDateTime getDateTimeBefore() {
return transition;
}
/**
* Gets the local transition date-time, as would be expressed with the 'after' offset.
* <p>
* This is the first date-time after the discontinuity, when the new offset applies.
* <p>
* The combination of the 'before' date-time and offset represents the same instant
* as the 'after' date-time and offset.
*
* @return the transition date-time expressed with the after offset, not null
*/
public LocalDateTime getDateTimeAfter() {
return transition.plusSeconds(getDurationSeconds());
}
/**
* Gets the offset before the transition.
* <p>
* This is the offset in use before the instant of the transition.
*
* @return the offset before the transition, not null
*/
public ZoneOffset getOffsetBefore() {
return offsetBefore;
}
/**
* Gets the offset after the transition.
* <p>
* This is the offset in use on and after the instant of the transition.
*
* @return the offset after the transition, not null
*/
public ZoneOffset getOffsetAfter() {
return offsetAfter;
}
/**
* Gets the duration of the transition in seconds.
*
* @return the duration in seconds
*/
private int getDurationSeconds() {
return getOffsetAfter().getTotalSeconds() - getOffsetBefore().getTotalSeconds();
}
/**
* Does this transition represent a gap in the local time-line.
* <p>
* Gaps occur where there are local date-times that simply do not not exist.
* An example would be when the offset changes from {@code +01:00} to {@code +02:00}.
* This might be described as 'the clocks will move forward one hour tonight at 1am'.
*
* @return true if this transition is a gap, false if it is an overlap
*/
public boolean isGap() {
return getOffsetAfter().getTotalSeconds() > getOffsetBefore().getTotalSeconds();
}
/**
* Does this transition represent a gap in the local time-line.
* <p>
* Overlaps occur where there are local date-times that exist twice.
* An example would be when the offset changes from {@code +02:00} to {@code +01:00}.
* This might be described as 'the clocks will move back one hour tonight at 2am'.
*
* @return true if this transition is an overlap, false if it is a gap
*/
public boolean isOverlap() {
return getOffsetAfter().getTotalSeconds() < getOffsetBefore().getTotalSeconds();
}
/**
* Checks if the specified offset is valid during this transition.
* <p>
* This checks to see if the given offset will be valid at some point in the transition.
* A gap will always return false.
* An overlap will return true if the offset is either the before or after offset.
*
* @param offset the offset to check, null returns false
* @return true if the offset is valid during the transition
*/
public boolean isValidOffset(ZoneOffset offset) {
return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset));
}
/**
* Gets the valid offsets during this transition.
* <p>
* A gap will return an empty list, while an overlap will return both offsets.
*
* @return the list of valid offsets
*/
List<ZoneOffset> getValidOffsets() {
if (isGap()) {
return Collections.emptyList();
}
return Arrays.asList(getOffsetBefore(), getOffsetAfter());
}
/**
* Compares this transition to another based on the transition instant.
* <p>
* This compares the instants of each transition.
* The offsets are ignored, making this order inconsistent with equals.
*
* @param transition the transition to compare to, not null
* @return the comparator value, negative if less, positive if greater
*/
@Override
public int compareTo(ZoneOffsetTransition transition) {
return Long.compare(this.toEpochSecond(), transition.toEpochSecond());
}
/**
* Checks if this object equals another.
* <p>
* The entire state of the object is compared.
*
* @param other the other object to compare to, null returns false
* @return true if equal
*/
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (other instanceof ZoneOffsetTransition) {
ZoneOffsetTransition d = (ZoneOffsetTransition) other;
return transition.equals(d.transition) &&
offsetBefore.equals(d.offsetBefore) && offsetAfter.equals(d.offsetAfter);
}
return false;
}
/**
* Returns a suitable hash code.
*
* @return the hash code
*/
@Override
public int hashCode() {
return transition.hashCode() ^ offsetBefore.hashCode() ^ Integer.rotateLeft(offsetAfter.hashCode(), 16);
}
}
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of JSR-310 nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package build.tools.tzdb;
import static build.tools.tzdb.Utils.*;
import java.util.Objects;
/**
* A rule expressing how to create a transition.
* <p>
* This class allows rules for identifying future transitions to be expressed.
* A rule might be written in many forms:
* <p><ul>
* <li>the 16th March
* <li>the Sunday on or after the 16th March
* <li>the Sunday on or before the 16th March
* <li>the last Sunday in February
* </ul><p>
* These different rule types can be expressed and queried.
*
* <h3>Specification for implementors</h3>
* This class is immutable and thread-safe.
*
* @since 1.8
*/
final class ZoneOffsetTransitionRule {
/**
* The month of the month-day of the first day of the cutover week.
* The actual date will be adjusted by the dowChange field.
*/
final int month;
/**
* The day-of-month of the month-day of the cutover week.
* If positive, it is the start of the week where the cutover can occur.
* If negative, it represents the end of the week where cutover can occur.
* The value is the number of days from the end of the month, such that
* {@code -1} is the last day of the month, {@code -2} is the second
* to last day, and so on.
*/
final byte dom;
/**
* The cutover day-of-week, -1 to retain the day-of-month.
*/
final int dow;
/**
* The cutover time in the 'before' offset.
*/
final LocalTime time;
/**
* Whether the cutover time is midnight at the end of day.
*/
final boolean timeEndOfDay;
/**
* The definition of how the local time should be interpreted.
*/
final TimeDefinition timeDefinition;
/**
* The standard offset at the cutover.
*/
final ZoneOffset standardOffset;
/**
* The offset before the cutover.
*/
final ZoneOffset offsetBefore;
/**
* The offset after the cutover.
*/
final ZoneOffset offsetAfter;
/**
* Creates an instance defining the yearly rule to create transitions between two offsets.
*
* @param month the month of the month-day of the first day of the cutover week, from 1 to 12
* @param dayOfMonthIndicator the day of the month-day of the cutover week, positive if the week is that
* day or later, negative if the week is that day or earlier, counting from the last day of the month,
* from -28 to 31 excluding 0
* @param dayOfWeek the required day-of-week, -1 if the month-day should not be changed
* @param time the cutover time in the 'before' offset, not null
* @param timeEndOfDay whether the time is midnight at the end of day
* @param timeDefnition how to interpret the cutover
* @param standardOffset the standard offset in force at the cutover, not null
* @param offsetBefore the offset before the cutover, not null
* @param offsetAfter the offset after the cutover, not null
* @throws IllegalArgumentException if the day of month indicator is invalid
* @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
*/
ZoneOffsetTransitionRule(
int month,
int dayOfMonthIndicator,
int dayOfWeek,
LocalTime time,
boolean timeEndOfDay,
TimeDefinition timeDefnition,
ZoneOffset standardOffset,
ZoneOffset offsetBefore,
ZoneOffset offsetAfter) {
Objects.requireNonNull(time, "time");
Objects.requireNonNull(timeDefnition, "timeDefnition");
Objects.requireNonNull(standardOffset, "standardOffset");
Objects.requireNonNull(offsetBefore, "offsetBefore");
Objects.requireNonNull(offsetAfter, "offsetAfter");
if (month < 1 || month > 12) {
throw new IllegalArgumentException("month must be between 1 and 12");
}
if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
}
if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
}
this.month = month;
this.dom = (byte) dayOfMonthIndicator;
this.dow = dayOfWeek;
this.time = time;
this.timeEndOfDay = timeEndOfDay;
this.timeDefinition = timeDefnition;
this.standardOffset = standardOffset;
this.offsetBefore = offsetBefore;
this.offsetAfter = offsetAfter;
}
//-----------------------------------------------------------------------
/**
* Checks if this object equals another.
* <p>
* The entire state of the object is compared.
*
* @param otherRule the other object to compare to, null returns false
* @return true if equal
*/
@Override
public boolean equals(Object otherRule) {
if (otherRule == this) {
return true;
}
if (otherRule instanceof ZoneOffsetTransitionRule) {
ZoneOffsetTransitionRule other = (ZoneOffsetTransitionRule) otherRule;
return month == other.month && dom == other.dom && dow == other.dow &&
timeDefinition == other.timeDefinition &&
time.equals(other.time) &&
timeEndOfDay == other.timeEndOfDay &&
standardOffset.equals(other.standardOffset) &&
offsetBefore.equals(other.offsetBefore) &&
offsetAfter.equals(other.offsetAfter);
}
return false;
}
/**
* Returns a suitable hash code.
*
* @return the hash code
*/
@Override
public int hashCode() {
int hash = ((time.toSecondOfDay() + (timeEndOfDay ? 1 : 0)) << 15) +
(month << 11) + ((dom + 32) << 5) +
((dow == -1 ? 8 : dow) << 2) + (timeDefinition.ordinal());
return hash ^ standardOffset.hashCode() ^
offsetBefore.hashCode() ^ offsetAfter.hashCode();
}
}
此差异已折叠。
此差异已折叠。
#
# Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building the tzdb compiler tool
#
BUILDDIR = ../..
PACKAGE = build.tools.tzdb
PRODUCT = tzdb
PROGRAM = tzdb
include $(BUILDDIR)/common/Defs.gmk
BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
BUILDTOOL_MAIN = $(PKGDIR)/TzdbZoneRulesCompiler.java
#
# Build tool jar rules.
#
include $(BUILDDIR)/common/BuildToolJar.gmk
......@@ -59,6 +59,12 @@ ifndef OPENJDK
# This gets built on unix platforms implicitly in the old build even though
# it's excluded in the closed build.
EXCLUDES+=sun/java2d/pisces
# AccessBridge is compiled separately below.
EXFILES += AccessBridge.java \
com/sun/java/accessibility/util/java/awt/ChoiceTranslator.java
# This seems to never be built
EXCLUDES += com/sun/java/accessibility/extensions
endif
endif
......@@ -248,10 +254,8 @@ include CopyIntoClasses.gmk
# Now we have COPY_PATTERNS, COPY_FILES and COPY_EXTRA
ifndef OPENJDK
CLOSED_SRC_DIRS:=$(JDK_TOPDIR)/src/closed/share/classes
ifneq ($(OPENJDK_TARGET_OS_API_DIR),windows)
CLOSED_SRC_DIRS += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS_API_DIR)/classes
endif
CLOSED_SRC_DIRS:=$(JDK_TOPDIR)/src/closed/share/classes \
$(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS_API_DIR)/classes
endif
MACOSX_SRC_DIRS :=
......@@ -364,8 +368,44 @@ endif
##########################################################################################
# copy with -a to preserve timestamps so dependencies down the line aren't messed up
ifndef OPENJDK
ifeq ($(OPENJDK_TARGET_OS), windows)
ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
$(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_32,\
SETUP:=GENERATE_JDKBYTECODE,\
JAVAC_FLAGS:=-cp $(JDK_OUTPUTDIR)/classes,\
SRC:=$(JDK_OUTPUTDIR)/gensrc_ab/32bit,\
BIN:=$(JDK_OUTPUTDIR)/classes_ab/32bit))
$(BUILD_ACCESSBRIDGE_32): $(BUILD_JDK)
$(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_LEGACY,\
SETUP:=GENERATE_JDKBYTECODE,\
JAVAC_FLAGS:=-cp $(JDK_OUTPUTDIR)/classes,\
SRC:=$(JDK_OUTPUTDIR)/gensrc_ab/legacy,\
BIN:=$(JDK_OUTPUTDIR)/classes_ab/legacy))
$(BUILD_ACCESSBRIDGE_LEGACY): $(BUILD_JDK)
else
$(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_64,\
SETUP:=GENERATE_JDKBYTECODE,\
JAVAC_FLAGS:=-cp $(JDK_OUTPUTDIR)/classes,\
SRC:=$(JDK_OUTPUTDIR)/gensrc_ab/64bit,\
BIN:=$(JDK_OUTPUTDIR)/classes_ab/64bit))
$(BUILD_ACCESSBRIDGE_64): $(BUILD_JDK)
endif
endif
endif
##########################################################################################
all: $(BUILD_JDK) $(BUILD_ALTCLASSES) $(BUILD_JOBJC) $(BUILD_JOBJC_HEADERS) $(COPY_EXTRA) \
$(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin
$(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \
$(BUILD_ACCESSBRIDGE_32) $(BUILD_ACCESSBRIDGE_64) \
$(BUILD_ACCESSBRIDGE_LEGACY)
.PHONY: all
......@@ -590,6 +590,34 @@ else
$(CHMOD) a+x $@
endif
##########################################################################################
# jabswitch
ifndef OPENJDK
ifeq ($(OPENJDK_TARGET_OS),windows)
$(eval $(call SetupNativeCompilation,BUILD_JABSWITCH,\
SRC:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge,\
INCLUDE_FILES:=jabswitch.cpp,\
LANG:=C++,\
CFLAGS:=$(filter-out -Zc:wchar_t-,$(CFLAGS_JDKEXE)) -Zc:wchar_t \
-analyze- -Od -Gd -D_WINDOWS \
-D_UNICODE -DUNICODE -RTC1 -EHsc,\
LDFLAGS:=$(LDFLAGS_JDKEXE) \
Advapi32.lib Version.lib User32.lib,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jabswitch,\
OUTPUT_DIR:=$(JDK_OUTPUTDIR)/bin,\
PROGRAM:=jabswitch,\
DEBUG_SYMBOLS:=true,\
VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/AccessBridgeStatusWindow.rc,\
RC_FLAGS:=$(RC_FLAGS),\
MANIFEST:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/jabswitch.manifest))
BUILD_LAUNCHERS += $(BUILD_JABSWITCH)
endif
endif
##########################################################################################
$(BUILD_LAUNCHERS) : $(JDK_TOPDIR)/makefiles/CompileLaunchers.gmk
......
......@@ -59,6 +59,27 @@ COPY_FILES = $(H_TARGET_FILES)
##########################################################################################
ifndef OPENJDK
ifeq ($(OPENJDK_TARGET_OS), windows)
COPY_FILES += $(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgeCallbacks.h \
$(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgeCalls.h \
$(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgePackages.h \
$(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgeCalls.c \
$(JDK_OUTPUTDIR)/lib/accessibility.properties
$(OPENJDK_TARGET_OS_INCLUDE)/bridge/%: \
$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/%
$(install-file)
$(JDK_OUTPUTDIR)/lib/accessibility.properties: \
$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/accessibility.properties
$(install-file)
endif
endif
##########################################################################################
LIBDIR = $(JDK_OUTPUTDIR)/lib
SERVICETAG_LIBDIR = $(LIBDIR)/servicetag
......@@ -267,10 +288,12 @@ endif
ifeq ($(OPENJDK_TARGET_OS),windows)
MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL))
# Chmod to avoid permission issues if bundles are unpacked on unix platforms.
$(MSVCR_TARGET): $(MSVCR_DLL)
$(MKDIR) -p $(@D)
$(RM) $@
$(CP) $< $@
$(CHMOD) a+rx $@
COPY_FILES += $(MSVCR_TARGET)
endif
......
此差异已折叠。
此差异已折叠。
......@@ -47,6 +47,9 @@ GENDATA += $(GENDATA_FONT_CONFIG)
include GendataTimeZone.gmk
GENDATA += $(GENDATA_TIMEZONE)
include GendataTZDB.gmk
GENDATA += $(GENDATA_TZDB)
include GendataHtml32dtd.gmk
GENDATA += $(GENDATA_HTML32DTD)
......
此差异已折叠。
......@@ -71,7 +71,7 @@ SWINGBEAN_DEBUG_FLAG = false
$(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java $(BUILD_TOOLS)
$(ECHO) Generating beaninfo
$(MKDIR) -p $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing
$(JAVA) -Djava.awt.headless=true -jar $(JAVADOC_JARS) -doclet GenDocletBeanInfo \
$(JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) -doclet GenDocletBeanInfo \
-x $(SWINGBEAN_DEBUG_FLAG) -d $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing \
-t $(DOCLETSRC_DIR)/SwingBeanInfo.template -docletpath $(JDK_OUTPUTDIR)/btclasses \
-XDignore.symbol.file=true \
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册